Ext.Expert.OnTick() calls the "OnTick" method of the ExtExpert object (of class CExpert). "OnTick" method is a function that is implemented in the CExpert class (Expert.mqh file) and it calls other functions, which also call other functions. So that line translates in a lot of stuff actually. Just don't be confused with the similarity of names void OnTick() is a global event that is present in all EAs, ExtExpert.OnTick() is a method of a given class and could have been called somewhat else - e.g. SuperOnTick(), or OnMegaTick().
Before I post, I did go on a search trail, I saw in Ontick(), that it calls Processing(). Then, I checked on Processing(), which in turns call all the checkforclose(), checkforopen(), etc, etc.
So I was baffled.
Am I right to say, that this one instance of CExpert, does all that which was coded in OnInit()?
I was thinking that OnInit() only executed once. So all those instructions in OnInit() is somewhat stored in some memory object, hence upon creating an object of CExpert, it all got executed, thru Ontick()?
Thank you very much, and that is a really pleasant rose to look at...;-)
stargazer:
Am I right to say, that this one instance of CExpert, does all that which was coded in OnInit()?
Not quite sure what you mean exactly, but yes, OnInit() contains only a call to CExpert's OnInit(), which does all the initialization here.
stargazer:
It is executed only once.
stargazer:
So all those instructions in OnInit() is somewhat stored in some memory object, hence upon creating an object of CExpert, it all got executed, thru Ontick()?
Not quite sure what you mean exactly, but yes, OnInit() contains only a call to CExpert's OnInit(), which does all the initialization here.
It is executed only once.
It's all executed not upon creation of the object, but on call of the object's OnInit() method from within the EA's OnInit() event.is this correct -
1) each time a new tick comes, the onTick() is executed.
2) each onTick() execution is only working on the cexpert methods, thanks to the only instance of cExpert object created at onInit()?
Im baffled by this.
How come there is no any signal check codes to buy, sell, in the onTick()? Where, upon every new tick, is the ea doing all the MA signals checking to buy/sell/close?
Thanks very much for your help....
codes to buy, sell,... all those inside ExtExpert class
Wrong. DxdCn ExtExpert is not even a class. It looks like 1 object of CExpert class. Now, correct me if I'm wrong...anyone.
My question is I dont see any signal checking done in OnTick()... though I see a signal object created in OnInit(). How does this two tie in, thats what I want to know and learn...
CExpert isn't the only used class.
It also uses CSignalMA, which is producing all the MA trading signals.
And CTrailingMA, which is used for trailing stop.
CMoneyNone - for money checks.
But ExtExpert object is used as a proxy for all this stuff, so eventually the trading functions in the resulting EA look like this
void OnTick() { ExtExpert.OnTick(); } //+------------------------------------------------------------------+ //| Function-event handler "trade" | //+------------------------------------------------------------------+ void OnTrade() { ExtExpert.OnTrade(); } //+------------------------------------------------------------------+ //| Function-event handler "timer" | //+------------------------------------------------------------------+ void OnTimer() { ExtExpert.OnTimer(); }
CExpert isn't the only used class. <---- ok
It also uses CSignalMA, which is producing all the MA trading signals. <---- signal object created in OnInit().
And CTrailingMA, which is used for trailing stop. <---- trailing object created in OnInit().
CMoneyNone - for money checks. <---- money object created in OnInit().
But ExtExpert object is used as a proxy for all this stuff, so eventually the trading functions in the resulting EA look like this
ExtExpert.OnTick();
gains access to all the above objects created in OnInit(), since init() executes once, wuld not all objects be destroyed, as soon as ontick() begins?
Also, I can see that in the onInit(), we have:
CSignalMA *signal=new CSignalMA; --> if(!ExtExpert.InitSignal(signal)) ---> which is basically found in the Expert.mqh
bool CExpert::InitSignal(CExpertSignal* signal) { if(m_signal!=NULL) delete m_signal; //--- if(signal==NULL) { if((m_signal=new CExpertSignal)==NULL) return(false); } else m_signal=signal; //--- initializing signal object if(!m_signal.Init(GetPointer(m_symbol),m_period,m_adjusted_point)) return(false); m_signal.EveryTick(m_every_tick); m_signal.Magic(m_magic); //--- ok return(true); }
I understand that the signal object is defined. Still, does it "live" on every new tick?
Thanks for helping, really appreciate it.
- 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
I was reading this cute name EA called expertMAMA.mq5 that comes together with the terminal. I am somewhat ok with logic that goes on in the OnInit(), but when it comes to the rest below:
My question is how is this ever possible that with just this one piece of line, as:
ExtExpert.OnTick();
the expert got executed? Same goes for the rest in onTrade(), etc, etc. I suspect I need some OOP "mind-bending" help, so can anyone guide me to the sequence of logic that goes on in onTick, onTrade, etc, etc? Many thx in advance