MQL+ OnCalculate in expert - page 2

 
Ovo:


Wow, I am not yet so advanced. Good clue. I have to read it later, now is the time to give a lift kids from schools.

There are a lot of features I missed...

Perfectly normal, mql5, and now mql4+, is very rich in features. This is why I am always asking you "why are you doing that this way".
 

I wonder why an event such as OnTradeAction, or OnAccountBalanceChange ...etc is not thought of.

It's very important when such an event occurs and we know to react with trading. Any thoughts?

Cung

 
You could give the suggestions to Service Desk at mql5.com
 
Ovo:

If I prefer to include indicator calculation into EA rather than the iCustom call, probably the easiest way is setting correct parameters for OnCalculate() function.

Did anyone already invest some effort into coding? I guess it should use CopyClose(), CopyHigh() etc. to create the parameter arrays, but I am not familiar with them. I found an article about inclusion of indicators, which might help.

In OnCalculate(), the use of prev_calculated and rates_total just replicates the old IndicatorCounted() function and Bars. The other parameters passed to it are the same as are in the series arrays. I dont really see the point of the change. But anyway, you can use the regular High[] Low[] etc series arrays and make the equivalent of indicator buffers by identify first tick of newbar and use ArraySetAsSeries() and ArrayResize(). You probably dont need to size the arrays to the entire chart like you would in a real indicator, just big enough to cover lookbacks.

 
SDC:

In OnCalculate(), the use of prev_calculated and rates_total just replicates the old IndicatorCounted() function and Bars. The other parameters passed to it are the same as are in the series arrays. I dont really see the point of the change. But anyway, you can use the regular High[] Low[] etc series arrays and make the equivalent of indicator buffers by identify first tick of newbar and use ArraySetAsSeries() and ArrayResize(). You probably dont need to size the arrays to the entire chart like you would in a real indicator, just big enough to cover lookbacks.


I don't see the point of the change either, especially as the new arrays can't be used easily outside of OnCalculate and not used at all in EAs and Scripts.

Added to which errors such as mistyping High[i] instead of high[i] can mess things up big time and the compiler will not detect the error.

 
Yes I know, and I have made the mistake you mentioned too. Ive been passing the new arrays from OnCalculate as parameters to other functions to keep them all using the same new arrays, angevoyageurs comment was interesting I did not know indicators can now be embedded ...
 
GumRai:


I don't see the point of the change either, especially as the new arrays can't be used easily outside of OnCalculate and not used at all in EAs and Scripts.

Added to which errors such as mistyping High[i] instead of high[i] can mess things up big time and the compiler will not detect the error.

The main point in my opinion is you can build indicator for MT4 and MT5 with the same code if you are using the new syntax.
 
cungchoidi:

I wonder why an event such as OnTradeAction, or OnAccountBalanceChange ...etc is not thought of.

It's very important when such an event occurs and we know to react with trading. Any thoughts?

Cung

You can manage your own custom events, see EventChartCustom.
 
deysmacro:
You could give the suggestions to Service Desk at mql5.com


Thanks deysmacro, I will try

angevoyageur:
You can manage your own custom events, see EventChartCustom.


Hmm,

I am not sure I made myself clear. E.g when your trade gets stop triggered, how would you know if the system does not fire an event?

 
deysmacro:
You could give the suggestions to Service Desk at mql5.com

Could you or somebody send me the link to such Service Desk? I could not find a clue.
Reason: