How to code MA of RSI in an EA?

 
Hello, sorry to bother you again.
I want to calculate a MA of RSI in my Expert Advisor, I try to make an array and then calculate it using iMAonArray, but it's not working.
Please look at my code

   double rsi[];
  
   for(int i=0 ; i<=60 ; i++)
    {
      rsi[i]=iRSI(Symbol(),0,13,PRICE_CLOSE,i);
    }
    
   double ma=iMAOnArray(rsi,0,60,0,MODE_EMA,0);
 
   print("MA value ",ma);
Thank you
 

See:

ArraySize(), maybe also ArrayResize()

ArraySetAsSeries()

 
DONE!! I'm using ArraySetAsSeries()
Thank you
 
phy:

See:

ArraySize(), maybe also ArrayResize()

ArraySetAsSeries()


Hi phy,

You seem to be an expert in this field, could you please help me with something simiar?

I would like to take a 20 LWMA on a 9 RSI - which I can do with Array - as shown above in previous message post

then I would like to take a 2 CCI on the already calculated 20 LWMA above - this I don't know how to do ?

Your help would be greatly appreciated,

Joe

 

Write your own CCI code to act upon the array holding the 20 LWMA values since there is not one built in that can be arbitrarily pointed at your LWMA array

or...

Plot the LWMA in the indicator window as a regular indicator index, and then attach the "Commodity Channel Index" Indicator to that subwindow using First Indicator's Data as the input

 
phy:

Write your own CCI code to act upon the array holding the 20 LWMA values since there is not one built in that can be arbitrarily pointed at your LWMA array

or...

Plot the LWMA in the indicator window as a regular indicator index, and then attach the "Commodity Channel Index" Indicator to that subwindow using First Indicator's Data as the input


Hi phy,

Thanks so far, Yes I can put the RSI on a new chart window as the first indicator, then attach a LWMA to look at the first indicator (i.e RSI) , then attach CCI to look at previous indicator (i.e LWMA). That all works well. But how do I code something like that for an EA?

 

In your code, you create an array of RSI values -- iRSI()

Use that as the input to create an array of LWMA. --- iMAonArray()

Use that as the input to a CCI function. Create your own CCIonArray() in the EA code.

There may be other ways, but that is my best guess.

 

Hi phy, thanks, I can create an LWMA array on the RSI, but dont know how to create a second array on the LWMA which I can use with CCI.

It's almost like an Array of an Array ....???

 

Not array on array. 3 arrays

rsiArray[] = iRSI(...); // store rsi values bar by bar

lwmaArrray[] = iMAonArray( ...rsiArray...); // store lwma of rsi values bar by bar

cciArray[] = yourCCIfunction( ... lwmaArray...); // store cci of lwma of rsi

 
phy:

Not array on array. 3 arrays

rsiArray[] = iRSI(...); // store rsi values bar by bar

lwmaArrray[] = iMAonArray( ...rsiArray...); // store lwma of rsi values bar by bar

cciArray[] = yourCCIfunction( ... lwmaArray...); // store cci of lwma of rsi


Hi phy, thanks very much for your help, looks great, I will try that :)
 

Hello Sir,

I am looking for EA for the following.

If the RSI= 52, open buy order

If the RSI=48 close the buy order

Please help me by sending the code in MQ4