Current bar is bar 0, and the stochastic value at bar 0 will be unstable.
dStochMainCurr = iStochastic(NULL,0,KPeriod,DPeriod,Slowing,Method,Price,MODE_MAIN,0);
dStochMainPrev = iStochastic(NULL,0,KPeriod,DPeriod,Slowing,Method, Price, MODE_MAIN,
1);
dStochSignalCurr = iStochastic(NULL,0,KPeriod,DPeriod,Slowing,Method, Price, MODE_SIGNAL,
0);
dStochSignalPrev = iStochastic(NULL,0,KPeriod,DPeriod,Slowing,Method, Price, MODE_SIGNAL,
1);
This will take the values from the current bar and the first completed bar.
Thanks.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
extern int KPeriod = 15;
extern int DPeriod = 5;
extern int Slowing = 5;
extern int Method = MODE_EMA;
extern int Price = 1; // 0=Low/High, 1=Close/Close
dStochMainCurr = iStochastic(NULL,0,KPeriod,DPeriod,Slowing,Method, Price, MODE_MAIN, 1);
dStochMainPrev = iStochastic(NULL,0,KPeriod,DPeriod,Slowing,Method, Price, MODE_MAIN, 2);
dStochSignalCurr = iStochastic(NULL,0,KPeriod,DPeriod,Slowing,Method, Price, MODE_SIGNAL, 1);
dStochSignalPrev = iStochastic(NULL,0,KPeriod,DPeriod,Slowing,Method, Price, MODE_SIGNAL, 2);
Much thanks,
Ed