But if add code inside OnTick(), every new tick happens, the handle will renew a new value not like inside OnInit(). Is it right for changing time fram for indicator handle?

- 2010.02.25
- MetaQuotes Software Corp.
- www.mql5.com
But if add code inside OnTick(), every new tick happens, the handle will renew a new value not like inside OnInit(). Is it right for changing time fram for indicator handle?
In general, it's better to have handle(s) initialized 1 time in OnInit(). If you need data of an other timeframe, simply add a new handle. You need an handle for each set of parameters (symbol, timeframe, indicator parameters) you need data from.
you mean i can add below code inside OnTick() to replace KDHandle that set in OnInit(), right?
KDHandle=iStochastic(NULL,time_frame,K_Period,D_Period,3,MODE_SMA,STO_LOWHIGH);
you mean i can add below code inside OnTick() to replace KDHandle that set in OnInit(), right?
KDHandle=iStochastic(NULL,time_frame,K_Period,D_Period,3,MODE_SMA,STO_LOWHIGH);
you mean i can add below code inside OnTick() to replace KDHandle that set in OnInit(), right?
KDHandle=iStochastic(NULL,time_frame,K_Period,D_Period,3,MODE_SMA,STO_LOWHIGH);
No.
Where to set time frame for indicator handle
angevoyageur, 2013.11.11 12:51
In general, it's better to have handle(s) initialized 1 time in OnInit(). If you need data of an other timeframe, simply add a new handle. You need an handle for each set of parameters (symbol, timeframe, indicator parameters) you need data from.Yes, i understand your answer and write below code. Thank you very muh!
int OnInit() { //--- Get handle for KD indicator KDHandle1=iStochastic(NULL,PERIOD_M5,K_Period,D_Period,3,MODE_SMA,STO_LOWHIGH); KDHandle2=iStochastic(NULL,PERIOD_H1,K_Period,D_Period,3,MODE_SMA,STO_LOWHIGH);
But new question is coming, when the time frame is set to 1 hour in EA but the chart also is in 5 mintues and we have two KD handles so when we open order it will open two order both in 5 mintues and 1 hour, OnTick() is by every tick in 5 minutes or in 1 hour?
Yes, i understand your answer and write below code. Thank you very muh!
But new question is coming, when the time frame is set to 1 hour in EA but the chart also is in 5 mintues and we have two KD handles so when we open order it will open two order both in 5 mintues and 1 hour, OnTick() is by every tick in 5 minutes or in 1 hour?

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use