Please use the code buttons instead of an image.
Works as expected. Did you run your code?
Dear all,
Sorry as I am fairly new to the mql5 forum. Besides, I started learning programming like 2 months ago so I am very much new to any type of forum discussion. I'll take note on the topic and also post as code format next time.
//+------------------------------------------------------------------+ //| Testing.mq4 | //| Copyright 2020, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2020, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.00" #property strict //+------------------------------------------------------------------+ //| Script program start function | //+------------------------------------------------------------------+ void OnStart() { double array[10] = {23, 54, 64, 32, 31, 54, 87, 12, 54, 12}; double ma = iMAOnArray(array, 0, 5, 0, MODE_SMA, 3); Alert(ma); } //+------------------------------------------------------------------+
I drag the script to the chart, and here's a snipshot on the output.
Dear all,
Sorry as I am fairly new to the mql5 forum. Besides, I started learning programming like 2 months ago so I am very much new to any type of forum discussion. I'll take note on the topic and also post as code format next time.
I drag the script to the chart, and here's a snipshot on the output.
double array[10] = {23, 54, 64, 32, 31, 54, 87, 12, 54, 12}; //Move array here. //+------------------------------------------------------------------+ //| Script program start function | //+------------------------------------------------------------------+ void OnStart() { double ma = iMAOnArray(array, 0, 5, 0, MODE_SMA, 3); Alert(ma); } //+------------------------------------------------------------------+
Declaring the array in OnStart() results in an Invalid array range error.
I don't know why.
Declaring the array in OnStart() results in an Invalid array range error.
I don't know why.
Hey Nagisa, it worked! That code is actually a simplified version so that people can understand my question better. Previously, I got that array out of range error as well in the EA that I am building because I need the moving average buffer of an indicator to confirm trend. Not sure why but putting the array declaration out of the function, it's working now. Thanks a lot.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Dear all,
I am unable to get the iMAOnArray work as it's always returning either 0.0 or out of range on me. Does anyone know why the codes as per screenshot below always have 0.0 output?