You're calling the constructor wrong when instantiating the object. Show us how you are trying to do it.
I updated the question to include the call.
The problem is the way you're trying to define your constructor. Constructors don't have return types.
class CisNewBar { protected: string m_symbol; // Symbol name ENUM_TIMEFRAMES m_period; // Chart period public: //void CisNewBar(string symbol, int period); //<<<<<<<<<<<<<<< CisNewBar(string symbol, int period); }; CisNewBar::CisNewBar(string symbol, int period) //<<<<<<<<<<<<<<<<< { m_retcode=0; // Result code of detecting new bar m_lastbar_time=0; // Time of opening last bar m_new_bars=0; // Number of new bars m_comment=""; // Comment of execution m_symbol=symbol); //<<<<<<<<<<<<<<<<< m_period=period; // <<<<<<<<<<<<<<<<< }
The problem is the way you're trying to define your constructor. Constructors don't have return types.
Still gives the same error.
Still gives the same error.
class CisNewBar { protected: datetime m_lastbar_time; // Time of opening last bar uint m_retcode; // Result code of detecting new bar int m_new_bars; // Number of new bars string m_comment; // Comment of execution string m_symbol; // Symbol name ENUM_TIMEFRAMES m_period; // Chart period public: void CisNewBar(string symbol, int period); //<<<<<<<<<<<<<<< // more stuff }; void CisNewBar::CisNewBar(string symbol, int period) //<<<<<<<<<<<<<<<<< { m_retcode=0; // Result code of detecting new bar m_lastbar_time=0; // Time of opening last bar m_new_bars=0; // Number of new bars m_comment=""; // Comment of execution m_symbol=symbol; //<<<<<<<<<<<<<<<<< m_period=(ENUM_TIMEFRAMES)period; // <<<<<<<<<<<<<<<<< } void OnStart() { CisNewBar current_chart(_Symbol, _Period); }
Still gives the same error.
I'm not sure what you're doing then. Don't put a type in front of the constructor. It should look exactly like this.
class CisNewBar { protected: string m_symbol; // Symbol name int m_period; // Chart period public: CisNewBar(string symbol, int period); }; CisNewBar::CisNewBar(string symbol, int period) //<<<<<<<<<<<<<<<<< { m_symbol=symbol; m_period=period; }
Hi
Using the code in this article https://www.mql5.com/en/articles/159 to detect the new bar arrival. In the file lib_cisnewbar.mqh
Is there a way to "using the code in the link" to detect the arrival of one day bar when the chart in a smaller time frame? i.e. arrival of a new bar in a different time frame?
I figured if I change the constructor as below and pass in the _Period I like, but I get the compiler error CisNewBar Wrong parameters count. Any suggestions? Thanks
Original:
My modified versioin with the compiler complaining
And in the file.mq5 the call is outside the OnInt() at the start of the file like this
There is a ")" on "m_symbol=symbol);", i think it should be "m_symbol=symbol;".
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi
Using the code in this article https://www.mql5.com/en/articles/159 to detect the new bar arrival. In the file lib_cisnewbar.mqh
Is there a way to "using the code in the link" to detect the arrival of one day bar when the chart in a smaller time frame? i.e. arrival of a new bar in a different time frame?
I figured if I change the constructor as below and pass in the _Period I like, but I get the compiler error CisNewBar Wrong parameters count. Any suggestions? Thanks
Original:
My modified versioin with the compiler complaining
And in the file.mq5 the call is outside the OnInt() at the start of the file like this