Can someone please tell me how to do this. I am writing a strategy into code and
the instructions say to have a rsi(8) then add a EMA8 to the rsi and when the rsi
crosses the ema take the trade. Ok i know how to do a rsi and a EMA on the price
itself but how do i do an EMA on the rsi in a indicator. Thanks for your help.
- Experts: Multi Levels Trend Expert Advisor
- Experts: EMAplusWPR_V2
- how do i get macd signals for my ea
is this close to right?
Is This close to right? for (int x=0; x<=7;x++) { RSI[x]=iRSI(NULL,0,8,PRICE_CLOSE,x); EMA=iMAOnArray(RSI,0,8,0,MODE_EMA,0); } for (x=1; x<=8;x++) { RSI1[x]=iRSI(NULL,0,8,PRICE_CLOSE,x); EMA1=iMAOnArray(RSI1,0,8,0,MODE_EMA,1); } if (EMA<iRSI(NULL,0,8,PRICE_CLOSE,0) && EMA1>iRSI(NULL,0,8,PRICE_CLOSE,0)) EnterLong=true; if (EMA>iRSI(NULL,0,8,PRICE_CLOSE,0) && EMA1<iRSI(NULL,0,8,PRICE_CLOSE,0)) EnterShort=true;
I've used comments to show me the values and my RSI and RSI1 arrays are being filled
but I'm doing something wrong with the EMA and EMA1 because those show me a 0 value.
double RSI[8]; // 6 ArraySetAsSeries(RSI, true); // 1 for (int x=0; x<=7;x++) { RSI[x]=iRSI(NULL,0,8,PRICE_CLOSE,x); } EMA=iMAOnArray(RSI,0,8,0,MODE_EMA,0); // 2 for (x=1; x<=8;x++) { RSI1[x]=iRSI(NULL,0,8,PRICE_CLOSE,x); } EMA1=iMAOnArray(RSI1,0,8,0,MODE_EMA,1); // 2 if (EMA<iRSI[0] && EMA1>iRSI[0]) // 3,4 { EnterLong=true; EnterShort = false; // 5 } else if (EMA>iRSI[0] && EMA1<iRSI[0] // 3,4 { EnterShort=true; EnterLong = false; //5 } else { EnterShort = False; // 5 EnterLong = false; }
It's close.
1 ArraySetAsSeries should be set.
2 Take the EMA out of the loops.
3 You will have false signals for the cross, since Price (and therefore RSI and
EMA) is still moving on bar 0. You will detect a cross, then
it will be gone, come back, gone again.
4 You already calculated RSI for bar 0 in the loops, so you can use that array value in the EMA test instead of calculating again.
5 You might be specific on setting the booleans so you don't have old signals laying around
6 Always declare the size of an array, it is memory allocation ( not requred for arrays used as indicator buffers)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register