Accessing High[] array from outside of OnCalculate() indicator function?
-
You are trying to fill an array using WHOLE_ARRAY. The array has no size. You've got it backwards. Fill then process.
Constant Description Usage WHOLE_ARRAY Means the number of items remaining until the end of the array, i.e., the entire array will be processed Other Constants -
Perhaps you should read the manual, including the examples. CopyHigh - Timeseries and Indicators Access - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
How To Ask Questions The Smart Way. 2004
How To Interpret Answers.
RTFM and STFW: How To Tell You've Seriously Screwed Up.
You can pass the High array to any function that is supposed to do the calculations like so:
//+------------------------------------------------------------------+ //| Calculate maximum from given array | //+------------------------------------------------------------------+ double calculateMaximum(const double &arr[]) { int i = ArrayMaximum(arr); return arr[i]; } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { double highestHigh = calculateMaximum(high); ...
I really appreciate for your both answer , i fixed the code now and also i understand what i am doing . Thank you
Hi, sorry for my newbie question, i try to explore mql5 envronment. Here is the my question, thanks in advance :
is anyway to get High[] array outside of OnCalculate in indicator ?
When i write like this, array is out of range because the WHOLE_ARRAY return the -1 value. :