読み取り専用

フォーラムは現在、読み取り専用のアーカイブとなっています。.

バグ報告やプラットフォームに関する質問はこちら → [email protected]

私たちのコミュニティはDiscordとYouTubeで活動しています。ぜひ参加してください!

ご参加ください Discord YouTube

Lets share SQ’s custom MQL4 functions here!

10件の返信

カリス

カスタマー、bpb_participant、コミュニティ、sq-ultimate、414件の回答。.

プロフィールを表示

10年前 #114883

Hi there fellow SQ users,

because few of us come from MQL4 programming prospective we have our own ideas how to improve the original SQ’s MQL4 functionalities,

so.., i wanted to share some of mine “add-ons” that i’ve implemented into the original SQ’s MQL4 files..

plus i want that everyone that had their SQ’s MQL4 files somehow modified to share their modifications here with everyone also 🙂

 

ill start by sharing some of mine.. have fun!:

 

 

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

¢ BACKTEST MUCH MORE FASTER WHEN USING MT4 (WITHOUT VISUAL MODE):

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Open your “Main.tpl” file and insert the following code line somewhere under the “int start() {” and above the “drawStats();”:

if(IsTesting()&&IsVisualMode()==false){ObjectsDeleteAll();} //Deletes all objects for faster MT4 backtesting..

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

 

 

 

 

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

¢ SPREAD LIMITER:

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Search for “MaxSlippage = 3;” inside the “PrintParameters.inc” file, then under that line insert the following code line:

extern double MaxSpread = 1.5; // << enter your maximum spread in PIPs here

Search for “void openPosition” inside the “MT4Functions.inc” file, then under the “if(sqIsTradeAllowed() == 1) {” insert the following peace of code:

         string OrderTypeString;
         if(orderType==OP_BUY)       OrderTypeString="#BUY";
         if(orderType==OP_SELL)      OrderTypeString="#SELL";
         if(orderType==OP_BUYLIMIT)  OrderTypeString="#BUY_LIMIT";
         if(orderType==OP_SELLLIMIT) OrderTypeString="#SELL_LIMIT";
         if(orderType==OP_BUYSTOP)   OrderTypeString="#BUY_STOP";
         if(orderType==OP_SELLSTOP)  OrderTypeString="#SELL_STOP";
         //
         int orderStartPointInTime = GetTickCount();
         if(orderType==OP_BUY||orderType==OP_SELL){if(DoubleToStr((Ask - Bid)*gPointPow, 1)>DoubleToStr(MaxSpread, 1)){Log("#ERROR!: Order's ("+OrderTypeString+") Spread was too high, - (Current Spread: ("+DoubleToStr((Ask - Bid)*gPointPow, 1)+")>("+DoubleToStr(MaxSpread, 1)+" Maximum), Delayed.");Sleep(500);return(0);}}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

 

 

 

 

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

¢ Determine if order closed by Stoploss/Takeprofit LOG NOTIFIER:

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Open your “Main.tpl” file and insert the following code line somewhere under the “int start() {” and above the “drawStats();”:

Order_Closure_OfSLTP_Notifier();

Open your “CustomCodeMT4,mq4” file and insert the following peace of code somewhere under the rest of the existing code that is already there..:

void Order_Closure_OfSLTP_Notifier()
{
   for(int i=OrdersHistoryTotal()-1;i>=0;i--){
   if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==true&&OrderSymbol()==Symbol()){
   if(OrderMagicNumber()==MagicNumber){
   if(TimeCurrent()-OrderCloseTime()==0) //<< (ANTI LOOP FLOOD!)
   //
      //________________________________________________________
      //#Determine if order closed by Stoploss/Takeprofit:
      if(OrderTakeProfit()!=0||OrderStopLoss()!=0){
         string OrderTypeString;
         if(OrderType()==OP_BUY)       OrderTypeString="#BUY";
         if(OrderType()==OP_SELL)      OrderTypeString="#SELL";
         if(OrderType()==OP_BUYLIMIT)  OrderTypeString="#BUY_LIMIT";
         if(OrderType()==OP_SELLLIMIT) OrderTypeString="#SELL_LIMIT";
         if(OrderType()==OP_BUYSTOP)   OrderTypeString="#BUY_STOP";
         if(OrderType()==OP_SELLSTOP)  OrderTypeString="#SELL_STOP";
         //--
            if(OrderType()==OP_BUY&&OrderClosePrice()>=OrderTakeProfit()){Log("#Order: ("+OrderTypeString+" [Ticket: "+OrderTicket()+"]) was Closed By TP.");}
            if(OrderType()==OP_BUY&&OrderClosePrice()<=OrderStopLoss()){Log("#Order: ("+OrderTypeString+" [Ticket: "+OrderTicket()+"]) was Closed By SL.");}
            //
            if(OrderType()==OP_SELL&&OrderClosePrice()<=OrderTakeProfit()){Log("#Order: ("+OrderTypeString+" [Ticket: "+OrderTicket()+"]) was Closed By TP.");}
            if(OrderType()==OP_SELL&&OrderClosePrice()>=OrderStopLoss()){Log("#Order: ("+OrderTypeString+" [Ticket: "+OrderTicket()+"]) was Closed By SL.");}
         //
      //________________________________________________________         
   }}}}
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

 

 

0

カリス

カスタマー、bpb_participant、コミュニティ、sq-ultimate、414件の回答。.

プロフィールを表示

10年前 #135833

Please if any one got a BreakEven & TrailingStop by TICKS please share..,

thank you..

0

カリス

カスタマー、bpb_participant、コミュニティ、sq-ultimate、414件の回答。.

プロフィールを表示

10年前 #135874

Please if any one got a BreakEven & TrailingStop by TICKS please share..,

thank you..

Somebody?..

0

ステアノ

カスタマー、bbp_participant、コミュニティ、379件の返信。.

プロフィールを表示

10年前 #135903

Karish,

I am sorry for such a simple question.  Where is the “Main.tpl?”  

0

カリス

カスタマー、bpb_participant、コミュニティ、sq-ultimate、414件の回答。.

プロフィールを表示

10年前 #135904

Karish,

I am sorry for such a simple question.  Where is the “Main.tpl?”  

All files located inside the “SQ\code” folder,

the “Main.tpl” located inside the “SQ\code\Mql_MT4” folder.

 

there is a Main.tpl inside the “SQ\code\Mql_MT4_BarOpen” folder also, but i don’t use the “BarOpen” feature.., only Tick based, so referee to the “SQ\code\Mql_MT4” folder.

0

ステアノ

カスタマー、bbp_participant、コミュニティ、379件の返信。.

プロフィールを表示

10年前 #135905

ありがとうございます!

0

ハンキーズ

Customer, bbp_participant, community, sq-ultimate, 465件の返信。.

プロフィールを表示

9年前 #141012

has anyone done modifications to the MQL4 code from SQ to get past through the validation process on MQL Market? I am stuck on this problem https://www.mql5.com/en/articles/2555#invalid_lot

利益を上げるアルゴトレーダーになりたいですか?私たちは2014年序盤からStrateQuantソフトウェアを使い始めました。現在では、あらゆるタイプの市場に対応するEA構築に関する膨大なノウハウを持っています。私たちはこのノウハウ、アプリ、ツール、そしてすべての最終的な戦略をリアル・トレーダーの皆様と共有しています。参加したい方は、以下にご記入ください フォーム.

0

ダベンゲ

顧客、bpb_participant、コミュニティ、92件の回答。.

プロフィールを表示

9年前 #141066

Yes, it is part of MQL requirement to check the lot size to ensure it stays within the minimum and maximum lot size range of the broker. And the lot step needs to be checked as well.

You can use the following code (for MT4) which I’ve modified from the original MQL’s code:

============================================================================

bool CheckLotSizeValue(double volume)
{
//— minimal allowed volume for trade operations
   if(volume<min_volume)
   {
      Print(“Lot Size volume is less than the minimal allowed. Minimum allowed lot size is “,min_volume);
      return(false);
   }

//— maximal allowed volume of trade operations
   if(volume>max_volume)
   {
      Print(“Lot Size volume is greater than the maximum allowed. Maximum allowed lot size is “,max_volume);
      return(false);
   }

//— get minimal step of volume changing
   int ratio=(int)MathRound(volume/volume_step);
   if(MathAbs(ratio*volume_step-volume)>0.0000001)
   {
      PrintFormat(“Lot Size volume is not a multiple of the minimal step SYMBOL_VOLUME_STEP=%.2f, the closest correct volume is %.2f”,volume_step,ratio*volume_step);
      return(false);
   }
   
   return(true);
}

 

========================================================

 

And than insert these into your “Init” section:

 

min_volume=MarketInfo(Symbol(),MODE_MINLOT);
max_volume=MarketInfo(Symbol(),MODE_MAXLOT);
volume_step=MarketInfo(Symbol(),MODE_LOTSTEP);

 

========================================================

 

And also insert the function call command into your “start” section:

 

   if(!CheckLotSizeValue(LotSize))return;

 

Usually you will need to insert this right at the start so that your EA checks the lot size first before going to the rest of the codes…

=========================================================

 

And this is just one of the checks, there are quite a number of other checks that MQL admin would expect you to put in as well which includes free margin check, stop level check, freeze level check, pending order limit check, lot volume limit check, and Ordermodify error 1 check. Basically all these are mentioned in the MQL article.

Also not forgetting all your extern parameters need to have a check function to check each parameter value so that when a user keys in invalid value, your EA will automatically prompt an error in journal to alert the user and stop the EA.

 

よろしくお願いいたします。,

デイブ

 

0

ハンキーズ

Customer, bbp_participant, community, sq-ultimate, 465件の返信。.

プロフィールを表示

9年前 #143499

is anyone capable of doing custom MQL modification of MQ4 code to the SQ, so the approriate lotsize is going right from SQ to the strategy code? So if i have in SQ lotsize 0.08 it will put this size right after i click generate MQ4 code? if i need to change this in 100+ strs its very upsetting

利益を上げるアルゴトレーダーになりたいですか?私たちは2014年序盤からStrateQuantソフトウェアを使い始めました。現在では、あらゆるタイプの市場に対応するEA構築に関する膨大なノウハウを持っています。私たちはこのノウハウ、アプリ、ツール、そしてすべての最終的な戦略をリアル・トレーダーの皆様と共有しています。参加したい方は、以下にご記入ください フォーム.

0

ダベンゲ

顧客、bpb_participant、コミュニティ、92件の回答。.

プロフィールを表示

9年前 #143502

is anyone capable of doing custom MQL modification of MQ4 code to the SQ, so the approriate lotsize is going right from SQ to the strategy code? So if i have in SQ lotsize 0.08 it will put this size right after i click generate MQ4 code? if i need to change this in 100+ strs its very upsetting

If you’re implying to manually change the default value of the lot size in the codes, that’s easy.

In the codes, look for “extern double Lots = 0.1;” which is usually located at the top part of the codes, then manually change the value to “0.08”.

Save it, and then every time when you run the EA it will be using a default lot size of “0.08”.

But if you’ve 100 EAs, you’ll need to do this manually for every EA. I don’t know if there’s any easy way to mass change this.

 

よろしくお願いいたします。,

デイブ

0

ハンキーズ

Customer, bbp_participant, community, sq-ultimate, 465件の返信。.

プロフィールを表示

9年前 #143503

This advice is useless, i know how to do it manually, i know how to do it together for 100+ strs in one click if the lotsize is the same value – but for me every strategy trading different lotsize, which is already used in SQ and is stored in STR file. and i want simple way how to put this exact value right to the MQL code

 

if we cant write samething like this discussed – custom MQL funkction

 

we can run some script (R, python, what so ever) – which will look for lotsize in STR file and put it automatically to the MQ4 file

利益を上げるアルゴトレーダーになりたいですか?私たちは2014年序盤からStrateQuantソフトウェアを使い始めました。現在では、あらゆるタイプの市場に対応するEA構築に関する膨大なノウハウを持っています。私たちはこのノウハウ、アプリ、ツール、そしてすべての最終的な戦略をリアル・トレーダーの皆様と共有しています。参加したい方は、以下にご記入ください フォーム.

0

10件の返信を表示中 - 1 - 10件目 (全10件中)