Stochastic Crossover is not detected when the crossover occurs exactly at the opening of a new candle
Is this normal or is it a bug in my code?
-
How To Ask Questions The Smart Way. (2004
Don't rush to claim that you have found a bug.
Questions Not To Ask
My program doesn't work. I think system facility X is broken.It is almost always your code.
- Always post all relevant code. You get the handle in OnInit (or on load). Where do you declare your class objects?
-
How To Ask Questions The Smart Way. (2004
Don't rush to claim that you have found a bug.
Questions Not To Ask
My program doesn't work. I think system facility X is broken.It is almost always your code.
- Always post all relevant code. You get the handle in OnInit (or on load). Where do you declare your class objects?
Hi Mr William.
I have selected the part of my code that I think is most relevant. I am using the SOLID principles and I have my code divided into a large number of classes. (too many files to post here).
Yes, I'm calling the indicators functions in the constructors of classes and the classes are instantiated in the OnInit () function.
I was thinking that maybe something is missing in my code for it to work correctly ... but I don't know what it could be ...
This is the only code that I have in the OnInit function. Everything else is instantiated in the class constructors.
//+------------------------------------------------------------------+ EA1 *ea1; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { ea1 = new EA1(); return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { if(ea1.OnDeinit(reason)) { delete ea1; ExpertRemove(); } }
Thank you so much!!
-
How To Ask Questions The Smart Way. (2004
Don't rush to claim that you have found a bug.
Questions Not To Ask
My program doesn't work. I think system facility X is broken.It is almost always your code.
- Always post all relevant code. You get the handle in OnInit (or on load). Where do you declare your class objects?
Ok, I'm sorry, maybe this is necessary too.
//+------------------------------------------------------------------+ class Test { Stochastic *stochastic; MACD *macd; public: //+------------------------------------------------------------------+ void Test ( string pSymbol, ENUM_TIMEFRAMES pTimeFrame, //------------ MACD int pFastEmaPeriod, int pSlowEmaPeriod, int pSignalPeriod, ENUM_APPLIED_PRICE pAppliedPrice, //-----------STO int pKPeriod, int pDPeriod, int pSlowling, ENUM_MA_METHOD pMaMethod, ENUM_STO_PRICE pStoPrice ) { macd = new MACD ( pSymbol, pTimeFrame, pFastEmaPeriod, pSlowEmaPeriod, pSignalPeriod, pAppliedPrice ); stochastic = new Stochastic ( pSymbol, pTimeFrame, pKPeriod, pDPeriod, pSlowling, pMaMethod, pStoPrice ); } //+------------------------------------------------------------------+ ~Test() { delete macd; delete stochastic; } //+------------------------------------------------------------------+ void Update() { stochastic.Update(); macd.Update(); } //+------------------------------------------------------------------+ bool CanSell( ) { Update(); return //macd.CanSell(1) && stochastic.CanSell(1); } //+------------------------------------------------------------------+ bool CanBuy( ) { Update(); return //macd.CanBuy(1) && stochastic.CanBuy(1); } //+------------------------------------------------------------------+ bool CloseBuy() { Update(); return stochastic.CanSell(1); } //+------------------------------------------------------------------+ bool CloseSell() { Update(); return stochastic.CanBuy(1); } }; //+------------------------------------------------------------------+
-
How To Ask Questions The Smart Way. (2004
Don't rush to claim that you have found a bug.
Questions Not To Ask
My program doesn't work. I think system facility X is broken.It is almost always your code.
- Always post all relevant code. You get the handle in OnInit (or on load). Where do you declare your class objects?
Mr. William
I think this guy have the same issue like me. Maybe is not a coding problem... Maybe the EA needs a special configuration type to works to 100%? Thank you so much!!
https://www.mql5.com/en/forum/375318#comment_23955865

- 2021.08.10
- www.mql5.com
Mr. William
I think this guy have the same issue like me. Maybe is not a coding problem... Maybe the EA needs a special configuration type to works to 100%? Thank you so much!!
https://www.mql5.com/en/forum/375318#comment_23955865
Ok, i was investigating and i think the problem is to programing with "close prices"... it is not so precise as "Every tick" and is logic to losse a lot of signal between bar and bar. (It is the difference between obtaining a continuous signal and a discrete one).
The question is ... Is it worth programming the "open prices" and saving time? Or is it better to program every tick?
I have found an interesting article although it does not answer that question
- 2013.08.21
- www.mql5.com

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I am testing Stochastic crosses and I have noticed that sometimes it fails when the cross occurs exactly when a new candle opens. This happens very often and I think too much precision is lost.
Is this normal or is it a bug in my code?
Is there any way that this does not happen?
Here is my code, and I also attach an image.
Thank you so much!!