- Is there an error in the Heikin-Ashi indicator ?
- Get lowest Lows in 10 bar intervals from 100 previous bars
- Array out of range error
Please don't post code something like what is causing the problem. Post the actual code.
Too often we are trying to help people and then find that we have wasted out time because they have not posted the code that causes the problem.
Check Bars to make sure that there are enough bars on the chart
Unless there are less than 1201 bars on the chart, I can't imagine the posted code causing an array out of range error.
Sorry, this is my actual code, I want to get the average of High, Low and Open for all the 6'099,906 bars
#property copyright "Personal Codes"
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
int totalBars=0;
long countVolume=0;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
double averageHigh=0,averageLow=0,averageOpen=0;
totalBars=Bars;
for(int x=totalBars; x>1; x--)
{
averageHigh=averageHigh+High[x];
averageLow=averageLow+Low[x];
averageOpen=averageOpen+Open[x];
countVolume=countVolume+Volume[x];
}
averageHigh=averageHigh/totalBars;
averageLow=averageLow/totalBars;
averageOpen=averageOpen/totalBars;
Print("aHigh: ",averageHigh," aLow: ",averageLow," aOpen: ",averageOpen);
Print("Volume of all the bars is: ",countVolume);
}
//+------------------------------------------------------------------+
-
Play videoPlease edit your post.
For large amounts of code, attach it.
Of course you get array exceeded. x == TotalBars == Bars. The candles are numbered 0 .. Bars-1. Therefor High[x] is High[Bars] and that does not exist. totalBars=Bars; for(int x=totalBars; x>1; x--){ averageHigh=averageHigh+High[x];
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use