Download MetaTrader 5

How to test OnCalculate and OnTick on Sunday and Saturday

To add comments, please log in or register
Ma Yuliang
269
Ma Yuliang  

I am really busy on the trading day.

So could only code some script on Saturday and Sunday.

Then I found there is no sigle come in.OnCalculate and OnTick could only draw indicator on histroy data.

Could any one know how to test Indicator script on Sunday?

Marco vd Heijden
Moderator
5536
Marco vd Heijden  
//+------------------------------------------------------------------+
//| Timer function                                                   |
//+------------------------------------------------------------------+
void OnTimer()
  {
   OnTick();
  }
Ma Yuliang
269
Ma Yuliang  
Marco vd Heijden:

It's really a good idea.

I wrote OnCalculation in OnTimer too.

void OnTimer()
  {
//---

   datetime arrTime[];
   double   arrOpen[],arrHigh[],arrLow[],arrClose[];
   long      arrTickVolume[],arrVolume[];
   int      arrSpread[];
   ArrayCopy(arrTime,Time,0,0,WHOLE_ARRAY);
   ArrayCopy(arrOpen,Open,0,0,WHOLE_ARRAY);
   ArrayCopy(arrHigh,High,0,0,WHOLE_ARRAY);
   ArrayCopy(arrLow,Low,0,0,WHOLE_ARRAY);
   ArrayCopy(arrClose,Close,0,0,WHOLE_ARRAY);
   ArrayCopy(arrVolume,Volume,0,0,WHOLE_ARRAY);
   CopyTickVolume(Symbol(),0,0,Bars-1,arrTickVolume);
   CopySpread(Symbol(),0,0,Bars-1,arrSpread);
   OnCalculate(Bars,0,arrTime,arrOpen,arrHigh,arrLow,arrClose,arrTickVolume,arrVolume,arrSpread);
  }
To add comments, please log in or register