Help With Array

Benjamin David Hardman
444

Hello, I am working on being able to input an array of values into a moving average function to be able to create an MA of any set of data basically.

But before I get to that point, I am trying to improve my knowledge of arrays as I feel under-developed.

I am simply trying to put the Ask value into an array to be able to call the ask for the current candle and the ask for the previous candle, but both values are coming back as 0.

Here is the code:

void OnTick()
  {
   double data = NormalizeDouble(SymbolInfoDouble(Symbol(),SYMBOL_ASK),Digits());
   
   double array[];
   ArrayInitialize(array,0);
   ArraySetAsSeries(array,true);
   CopyBuffer(data, 0, 0, 10, array);
  
  
   Comment(DoubleToString(array[1],Digits()),"\n",
           DoubleToString(array[2],Digits()));
   
  } 
Moving Average - Trend Indicators - Technical Indicators - Price Charts, Technical and Fundamental Analysis - MetaTrader 5 Help
Moving Average - Trend Indicators - Technical Indicators - Price Charts, Technical and Fundamental Analysis - MetaTrader 5 Help
  • www.metatrader5.com
The Moving Average Technical Indicator shows the mean instrument price value for a certain period of time. When one calculates the moving average...
William Roeder
27511
William Roeder  
 double array[];
   ArrayInitialize(array,0);
The array has no size yet, you can't initialize it.