Download MetaTrader 5

Help with array - struct undefined error

To add comments, please log in or register
James3567
347
James3567  

I've been attempting to average the High/Low range for a predefined number of previous price bars but cannot even get the array to compile without the error "struct member undefined"


Can someone inform me of what I am doing wrong here?


double candle_body[];
ArrayResize(candle_body,num_quiet_bars);

for (int i = 0; i < num_quiet_bars; i++)
{
        
        candle_body[i] = iHigh(_Symbol,_Period,i) - iLow(_Symbol,_Period,i);
        
}

I would like to obtain the average for all of the values in the array "candle_body[]" but cannot even get past this part.

whroeder1
17828
whroeder1  
James3567: Can someone inform me of what I am doing wrong here?
Click on the error message and the editor will scroll to the line in error. It's not in the code you posted.
James3567
347
James3567  
whroeder1:
Click on the error message and the editor will scroll to the line in error. It's not in the code you posted.
public: /* Custom methods */
        virtual double _ObjText_() {
                ObjText.Value = v::candle_body;

                return ObjText._execute_();
        }
MetaEditor found an error with the line in the above code --> ObjText.Value = v::candle_body;

The error message is 'candle_body' - struct member undefined

Any idea what is causing the issue? 
James3567
347
James3567  

I was able to figure it out. For anyone interested in doing this here is the code I used to calculate the average High/Low range of previous candles defined by the variable num_quiet_bars

ArrayResize(candle_body,num_quiet_bars);

for (int i = 0; i < num_quiet_bars; i++)
{
        
        candle_body[i] = (iHigh(_Symbol,_Period,i) - iLow(_Symbol,_Period,i))*10000;
        body = candle_body[i];
        
}
int ArrayIndex;
double ArraySum;

for (ArrayIndex = ArraySize(candle_body) - 1; ArrayIndex >= 0; ArrayIndex--)
   {ArraySum += candle_body[ArrayIndex];}

avg_candle_size = ArraySum/ArraySize(candle_body);
To add comments, please log in or register