Moving Averange in array

Back to topics list To post a new topic, please log in or register
avatar
7
duddas90 2016.02.22 11:03
 

Good morning

I'm a newbie in mql4 and i still don't  understand how put value of moving averange in array. I get always some errors (like array out of range) 

I just need and alert when the value of moving averange in the previous candle is more high then actual candle in OnCalculate process.

Can someone make me this little piece of code?

however thank you 


Donato 

avatar
2017
gooly 2016.02.22 12:02 #
 

You need to read about the usage of arrays and the examples

avatar
7
duddas90 2016.02.22 12:45 #
 

Where i wrong?

 double clos[500];

   for(int k=0;k<500;k++)

   {

      clos[k]=iMAOnArray(clos,0,period,0,method,1);

   }

    ArraySetAsSeries(clos,true);

Alert(clos[0]); 

 (period = 12 and method = MODE_SMA)

The alert say me that clos[0] has 0.0 value.

I just want the last value of moving averange 

avatar
7
duddas90 2016.02.22 12:46 #
 
gooly:

You need to read about the usage of arrays and the examples

i read it but i don't understand where i wrong
avatar
12985
WHRoeder 2016.02.22 13:16 #
 
  1. Set the array as series before populating it.
  2. clos[k]=iMAOnArray(clos,0,period,0,method,1);
    What average do you think you are calculating?
avatar
7
duddas90 2016.02.22 14:40 #
 
WHRoeder:
  1. Set the array as series before populating it.
  2. What average do you think you are calculating

 

1. thank you

2.  Simple averange with 12 period or i'm wronging?


avatar
12985
WHRoeder 2016.02.22 15:09 #
 
duddas90: 2.  Simple averange with 12 period or i'm wronging?

Simple average of what? clos has no values. If it does you then clobber the array by assigning the iMA to it so subsequent iMAs are meaningless.



avatar
7
duddas90 2016.02.22 15:25 #
 
WHRoeder:

Simple average of what? clos has no values. If it does you then clobber the array by assigning the iMA to it so subsequent iMAs are meaningless.



oooh!! now i understand imaonarray what mean really!!! i tought that it was moving averange in 1 array!!

 I need moving averange value in K  (500) candles

 i must to use iMA process to populate array right??

Back to topics list  

To add comments, please log in or register