- Looking for a way to allow MQL4 EA to write to file while file is being viewed.
- Requests & Ideas, the beginning
- Please help me solve this mystery!!
Do not double post!
I have deleted your duplicated topic.
-
int counted_bars=IndicatorCounted(); int limit=Bars-counted_bars; ⋮ for(int i=1; i<=limit; i++) {
First run IC is zero, limit==Bars, you access arrays[Bars], indicator crashes.
You should stop using the old event handlers (init, start, deinit) and IndicatorCounted() and start using new event handlers (OnInit, OnTick/OnCalculate, OnDeinit).
Event Handling Functions - MQL4 Reference
How to do your lookbacks correctly - MQL4 programming forum #9-14 & #19 (2016) -
opn = open[i+k]; cls = close[i+k];
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
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use