Reply

Difference between MQL and EL code!

3 replies

eastpeace

Customer, bbp_participant, community, sq-ultimate, 305 replies.

Visit profile

7 years ago #115293

Version:SQ 3.8.1  (What a tough period! SQ3 with no fixed update, and SQ4’s release with no schedule)

 

Back to this topic, I find that there is little difference between mql and el translated code. Which one is exact?

 

SQ’s pseudo code

====================================================================
== Entry conditions
==================================================================== 
LongEntryCondition = ((WMA(145) Crosses Below SMA(3)) And (Low(10) > Lowest(53)))
ShortEntryCondition = ((WMA(145) Crosses Above SMA(3)) And (High(10) < Highest(53)))

EL code

 if(MaxTradesPerDay = 0 or EntriesToday(Date) < MaxTradesPerDay) then begin
        LongEntryCondition = (((WAverage(Close,145)[1] > Average(Close,3)[1]) and (WAverage(Close,145)[0] <= Average(Close,3)[0])) and (Low[9] > Lowest(Low, 53+0)));
        if(LongEntryCondition = true) then begin

MT4’s code

 // ENTRY RULES

      // LONG: ((WMA(145) Crosses Below SMA(3)) And (Low(10) > Lowest(53)))
      if(TradeLong) {
         bool LongEntryCondition = (((iMA(NULL, 0, 145, 0, MODE_LWMA, PRICE_CLOSE, 2) > iMA(NULL, 0, 3, 0, MODE_SMA, PRICE_CLOSE, 2)) && (iMA(NULL, 0, 145, 0, MODE_LWMA, PRICE_CLOSE, 1) < iMA(NULL, 0, 3, 0, MODE_SMA, PRICE_CLOSE, 1))) && (Low[10] > getLowest(53, 1)));
         if(LongEntryCondition == true) {
            openPosition(1);
         }
      }

Low[10] in EL means:

 

 

 

 

So, the pseudo code, el code, mt4 code: low(10), low[9], low[10]. Are they equal?

0

eastpeace

Customer, bbp_participant, community, sq-ultimate, 305 replies.

Visit profile

7 years ago #138035

And the profit curve or equity line  in SQ backtest and MC, are huge different. 

 

I have upload the str file, Please check this. Thanks!

0

Mark Fric

Administrator, sq-ultimate, 2 replies.

Visit profile

7 years ago #138037

The differences in EasyLanguage is correct, because in EL the condition is checked at the end of bar, while in MT4 it is tested at the beginning of bar.

 

As for differences between SQ and MC, do you use the same data?

Mark
StrategyQuant architect

0

eastpeace

Customer, bbp_participant, community, sq-ultimate, 305 replies.

Visit profile

7 years ago #138048

NO, the data are similar, but from different source. Maybe it is my backtest software’s problem.

 

But I have another question yet.

 

The short exit condition as below

-- Short exit
if MarketPosition is Short {
   if (Bars Since Entry >= 42) {
      Close position at market;
   }
   
   if (Lowest(11) Crosses Below WMA(86)) {
      Close position at market;
   }
}

el code:

 // Exit rule
    ShortExitCondition = ((Lowest(Low, 11+1) > WAverage(Close,86)[1]) and (Lowest(Low, 11+0) <= WAverage(Close,86)[0]));

I think the correct code is :

 // Exit rule

 

    LowestValue = Lowest(Low, 11);

   
    ShortExitCondition = (( LowestValue[1] > WAverage(Close,86)[1]) and ( LowestValue <= WAverage(Close,86)[0]));

0

Viewing 3 replies - 1 through 3 (of 3 total)