Download MetaTrader 5
To add comments, please log in or register
Your conversation partner speaks foreign language? Automatic translation will help you!
HongDi s& t development co.,ltd.
1529
hongbin fei 2011.09.30 20:01 

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
6379
Karlis Balcers 2011.09.30 23:10  

Add it to 20min chart.

Is it really indicator? Sounds like EA.

Jinsong Zhang
14610
Jinsong Zhang 2011.10.01 10:42  

2个方法:

1. Sleep(1200000) 

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

HongDi s& t development co.,ltd.
1529
hongbin fei 2011.10.01 10:44  

it is an indicator, attached on H1 Chart.

thanks, I will try. 

 

Is  EventSetTimer() no use on Indicator? 

 

HongDi s& t development co.,ltd.
1529
hongbin fei 2011.10.03 07:28  

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
6275
Tjipke de Vries 2011.10.22 13:29  

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
6598
Rashid Umarov 2011.10.25 12:48  
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.
1529
hongbin fei 2011.12.30 07:15  
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