how can I let indicator every 20 min to execute OnCalculate() function?

 

how can I let indicator every 20 min to execute OnCalculate() function? '

 

In my indicator,  I donot want it check on every ticket, only for 20 min to do it ,

My I use EventSetTimer()?

Please guide.

 

thanks 

 

 

Add it to 20min chart.

Is it really indicator? Sounds like EA.

 

2个方法:

1. Sleep(1200000) 

2. 你可设一变量,假设为Time_1, 当TimeCurrent-Time_1<20分钟,就Sleep().

 

it is an indicator, attached on H1 Chart.

thanks, I will try. 

 

Is  EventSetTimer() no use on Indicator? 

 

 

Note

The Sleep() function can't be called for custom indicators, because indicators are executed in the interface thread and must not slow down it.

sleep cannot use in indicator! 

Documentation on MQL5: Common Functions / Sleep
  • www.mql5.com
Common Functions / Sleep - Documentation on MQL5
 

Use  datetime

datetime  xxxxx;

 

start 

datetime yyyyy =  datetime now

 

if yyyyy >  xxxxxx  + 1200000   

then   do indicator its job

followed by   xxxxxx =  yyyyy      

 

Now your way to code   Good Luck ...... 

 
codeidea:

In my indicator,  I donot want it check on every ticket, only for 20 min to do it ,

My I use EventSetTimer()?


Yes, it is possible. You should just keep in mind that every timer works for concrete copy of EA or indicator.
 
Rosh:
Yes, it is possible. You should just keep in mind that every timer works for concrete copy of EA or indicator.

how to call OnCalculate()  function from OnTimer(), because there is more parameter for  OnCalculate() 

I donot know how to write these parameters, wish you can help me.

int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime& time[],     // Time
                const double& open[],       // Open
                const double& high[],       // High
                const double& low[],        // Low
                const double& close[],      // Close
                const long& tick_volume[],  // Tick Volume
                const long& volume[],       // Real Volume
                const int& spread[]         // Spread
                )
Reason: