Reply

Some bugs? Difference between MQL and EL

3 replies

eastpeace

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

Visit profile

7 years ago #115663

I am still working with SQ3.8. And it can generate some simple good strategies really. It’s like many SQ’s users, I think.

 

And I make more futures contracts trading than forex.  I  found somethings difference between mql and el.

 

ex.

 

pseudo code:

 

====================================================================
== Entry conditions
====================================================================
LongEntryCondition = (Low(3) < High(2))
ShortEntryCondition = (High(3) > Low(2))

 

mql code:

 

  // ENTRY RULES

      // LONG: (Low(3) < High(2))
      if(TradeLong) {
         bool LongEntryCondition = (Low[3] < High[2]);
         if(LongEntryCondition == true) {
            openPosition(1);
         }
      }
  
      // SHORT: (High(3) > Low(2))
      if(TradeShort) {
         bool ShortEntryCondition = (High[3] > Low[2]);
         if(ShortEntryCondition == true) {
            openPosition(-1);
         }
      }

 

but in el:

        LongEntryCondition = (Low[2] < High[1]);
       
        ShortEntryCondition = (High[2] > Low[1]);

 

 

The backtrace periods in el is shorter than others.

 

But I know the index in TS/MC’s El, the last one is also Zero.

 

And another instance is barsinceentry/getOpenBarsForOrder.  El’s is shorter,too.

 

I think that they all start count from zero when open an order/ entry.

 

 

int getOpenBarsForOrder(int expBarsPeriod) {
   datetime opTime = OrderOpenTime();

   int numberOfBars = 0;
   for(int i=0; i<expBarsPeriod+10; i++) {
      if(opTime < Time[i]) {
         numberOfBars++;
      }
   }

   return(numberOfBars);
}

 

 

 

I have upload the str below.

 

When you have time, please check this!  I think most people still use SQ3.8 to generate strs.

0

tomas262

Administrator, sq-ultimate, 2 replies.

Visit profile

7 years ago #139772

Hello,

 

this is caused by the fact that in TradeStation bar timestamps represent the time at which a bar closes while in MetaTrade the same time represents time at which that bar opens

0

eastpeace

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

Visit profile

7 years ago #139780

Oh,  I understand a little what you mean.

 

But in Day timeframe, the bars’s open date&time and close date are the sameï¼Å’ I think.  Is the MT4’s current bar’s index is 1?

0

tomas262

Administrator, sq-ultimate, 2 replies.

Visit profile

7 years ago #139803

Hello,

 

more important thing is which engine you use for developing your strategies. If you use TradeStation engine and it finds a strategy that uses Close[10] then when you display MQL4 code it will always include Close[11] reference. StrategyQuant is set that way. Always develop strategies only in the engine you’â„¢ll be trading it later!

0

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