Download MetaTrader 5

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

To add comments, please log in or register
HongDi s& t development co.,ltd.
1603
hongbin fei  

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 

 

Karlis Balcers
7283
Karlis Balcers  

Add it to 20min chart.

Is it really indicator? Sounds like EA.

Jinsong Zhang
16821
Jinsong Zhang  

2个方法:

1. Sleep(1200000) 

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

HongDi s& t development co.,ltd.
1603
hongbin fei  

it is an indicator, attached on H1 Chart.

thanks, I will try. 

 

Is  EventSetTimer() no use on Indicator? 

 

HongDi s& t development co.,ltd.
1603
hongbin fei  

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
Tjipke de Vries
6392
Tjipke de Vries  

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 ...... 

Rashid Umarov
Admin
12665
Rashid Umarov  
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.
HongDi s& t development co.,ltd.
1603
hongbin fei  
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
                )
To add comments, please log in or register