MT4 in a virtual machine ? - page 5

 
DayTrader:

Yes that good in itself, but until atleast MY broker (and preferably more of them) offer MT5 I won't even think of rewriting all my code.

In the mean time I'll get the job done by the +4-fold increase in speed in W7/64, combined with the 10-fold increase from tick skipping.... combined we get some 40-fold increase in speed.

You code does skip ticks, but it does that in a way possible important informations might get lost.

Use code like this:

bool SkipTick(){
   static datetime curr=0;
   static double askHi=0;
   static double askLo=0;
   static double bidHi=0;
   static double bidLo=0;
   if(curr!=Time[0]){
      curr=Time[0];
      askHi=Ask;
      askLo=Ask;
      bidHi=Bid;
      bidLo=Bid;
      return (false);
   }else{
      if(Ask>askHi || Ask<askLo){
         askHi=MathMax(Ask,askHi);
         askLo=MathMin(Ask,askLo);
         return(false);
      }
      if(Bid>bidHi || Bid<bidLo){
         bidHi=MathMax(Bid,bidHi);
         bidLo=MathMin(Bid,bidLo);
         return(false);
      }
   }
   return(true);
}

to skip ticks without loosing important informations.

All Bar openings, as well as new highs and new lows are not skipped.

 
Good idea!
 
zzuegg:

You code does skip ticks, but it does that in a way possible important informations might get lost.

Use code like this:

to skip ticks without loosing important informations.

All Bar openings, as well as new highs and new lows are not skipped.


I don't know if this would be an equivalent. However, one could remove the Volume information while importing data into mt4. By default, it'll use the minimum O-H-L-C or 4-Ticks, this helps speed up the back-testing.

Along those lines, have anyone tried entering Volume(s) of say 100 during a M1-data import?. My guess is that this should be a viable alternative to Tick-Data if it works. I planed to test it but never gotten around to it :)

 
zzuegg:
All Bar openings, as well as new highs and new lows are not skipped.
Alternatively, see increase speed for strategy tester - MQL4 forum
 

My broker has now enabled MT5 on Live accounts and that makes it less academic. I wrote my first MQL5 indicator (to display the spread) last night and this evening I had a go at converting the speed test EA from the first page of this thread. Here it is ...

// MQL5 code

const int SECONDSPERHOUR=3600;

input int stops = 250;

double lots= 0.0;

//+-------------------------------------------------------------------------------------------+
int OnInit(){
    lots = SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MIN);
    return(0);
}
//+-------------------------------------------------------------------------------------------+
void OnDeinit(const int reason){ 
}
//+-------------------------------------------------------------------------------------------+
void OnTick(){
    static long lastHour=0;
    
    datetime now= TimeCurrent();
    long hourNow = SECONDSPERHOUR *(((long)now) / SECONDSPERHOUR); 
    
    if( lastHour== hourNow )
        return;
    
    lastHour= hourNow;
    
    MqlTick lastTick;
    SymbolInfoTick(_Symbol,lastTick);
    
    MqlTradeResult result={0};
    
    MqlTradeRequest requestA={0};
    requestA.action=TRADE_ACTION_DEAL;
    requestA.symbol= Symbol();
    requestA.type = ORDER_TYPE_BUY;
    requestA.volume= lots;                  
    requestA.sl=    NormalizeDouble( lastTick.ask - stops*_Point, _Digits );
    requestA.tp=    NormalizeDouble( lastTick.ask + stops*_Point, _Digits );

    OrderSend(requestA,result);
    if( result.retcode != TRADE_RETCODE_DONE )
        Print("BUY order failed: " + IntegerToString(result.retcode));
    
    SymbolInfoTick(_Symbol,lastTick);
      
    MqlTradeRequest requestB={0};
    requestB.action=TRADE_ACTION_DEAL;
    requestB.symbol= Symbol();
    requestB.type = ORDER_TYPE_SELL;

    requestB.volume= lots;                  
    requestB.sl=    NormalizeDouble( lastTick.bid + stops*_Point, _Digits );
    requestB.tp=    NormalizeDouble( lastTick.bid - stops*_Point, _Digits );
    
    OrderSend(requestB,result);
    if( result.retcode != TRADE_RETCODE_DONE )
        Print("SELL order failed: " + IntegerToString(result.retcode));
    
    return;
}

Now the idea was to compare speeds in the strategy tester doing like-for-like trades. Of course I forget the most fundamental change in MQL5. You can't hedge. In fact you can only ever have one position open per symbol by the looks of it. That means multi-strategy, separated by MAGIC_NUMBERS, seems to be impossible.

My test EA failed miserably as it just places a trade every hour to see how long it takes. Doing a like-for-like comparison this way is not possible :-(

Reason: