-
First run prev_calculated is zero, so you process all bars. After that, you only process Bars-Bars_Plot most recent bars. Remove your variable and process only changed bars.
How to do your lookbacks correctly #9 — #14 & #19 (2016) -
Your loop is processing in as-series order. Are you using any of those arrays? Did you set them to as-series?
In MT5, you must set the direction.
To define the indexing direction in the time[], open[], high[], low[], close[], tick_volume[], volume[] and spread[] arrays, call the ArrayGetAsSeries() function. In order not to depend on defaults, call the ArraySetAsSeries() function for the arrays to work with.
Event Handling / OnCalculate - Reference on algorithmic/automated trading language for MetaTrader 5Always post all relevant code (using Code button) or attach the source file.
How To Ask Questions The Smart Way. (2004)
Be precise and informative about your problem - Why are you calling RefreshRates?
-
First run prev_calculated is zero, so you process all bars. After that, you only process Bars-Bars_Plot most recent bars. Remove your variable and process only changed bars.
How to do your lookbacks correctly #9 — #14 & #19 (20 16 ) -
Your loop is processing in as-series order. Are you using any of those arrays? Did you set them to as-series?
In MT5, you must set the direction.
Always post all relevant code (using Code button ) or attach the source file.
How To Ask Questions The Smart Way . (20 04 )
Be precise and informative about your problem - Why are you calling RefreshRates ?
Hi William,
Thanks for your feedback, I'll try to update you by points.
I'll start by saying that in this message I'll post the file with the entire code and then the version containing the comments you reported (Fixed Version). The indicator I'm trying to make works on MT4.
Answering you in points:
- Can you tell me if the fixed version is correct?
- The code shows the fact that I set them as Series.
- RefreshRates is an error on my copy and paste, it has been removed.
I await your kind feedback.
A thousand thanks
- 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 everyone,
I need support because I'm noticing a problem with my custom indicator.
The indicator provides me with a KPI that updates for each new bar.
I based an expert on it who, based on the value of the previous bar compared to the current one, must do or not do operations.
I had the doubt that correct values were not being generated, in fact this was the case, by printing the KPI as soon as the new bar was triggered I noticed that the values returned by the indicator were not correct.
Following the code, can you help me understand what's wrong?
Cutting pieces of code (OnCalculate Function) for convenience.
Many thanks guys!!!