Don't double post! You already had another thread open.
General rules and best pratices of the Forum. - General - MQL5 programming forum (2017)Hi William, Keith,
Noted on the double post.
Thanks for the removing of it.
By any chance would you know where the issue lies in?
Thank you.
Regards,
John
If an error occurs. Is there a compilation error? If yes, what compilation error does your IDE print? If no, the indicator is not working the way you want it to. So, to get an answer, you need to explain what exactly is not working.
Apart from that, it is always recommended to print output in case of errors. E.g. >> if (first_operation_was_successful) Print("Step 1 successful. Value:", calculatedValue) << And then you can look at the output and see where the error occurs, look in the associated code and discover and fix the error there.
-
You have your buffers (that default to as-series), the OHLCV arrays (that default to non-series), and your loop (non-series).
-
Arrays must be manually sized. They have no direction. You must move elements if you want a stack/as-series (set non-series, enlarge the array, set as-series).
-
Buffers are automatically size, are as-series, and elements are moved for you, new elements are set to EMPTY_VALUE (or your designated. They can also draw on the chart automatically.
-
In MT4, buffers and the predefined arrays are all ordered AsSeries. There is a difference between the arrays passed to OnCalculate (e.g. low[]) and the MT4 predefined variables (e.g. Low[].) The passed arrays have no default direction, just like MT5.
To determine the indexing direction of time[], open[], high[], low[], close[], tick_volume[], volume[] and spread[], call ArrayGetAsSeries(). In order not to depend on default values, you should unconditionally call the ArraySetAsSeries() function for those arrays, which are expected to work with.
Event Handling Functions - Functions - Language Basics - MQL4 Reference -
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 5
-
-
See How to do your lookbacks correctly #9 — #14 & #19. (2016)
- 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 All,
Can i trouble you to look into this?
Cant seem to find the error in this, the indicator repaints/recalculates.
Thank you.
Regards,
John