Get the RSI values into an array, use iMAonArray to get the MA of the RSI, find the cross.
int i; int limit; int counted_bars=IndicatorCounted(); //---- check for possible errors if(counted_bars<0) return(-1); //---- last counted bar will be recounted if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; //--- main loops 1 and 2 for(i=0; i < limit; i++) { RSIBuffer[i]=iRSI(Symbol(),0,RSIPeriod,PRICE_CLOSE,i); } for(i=0; i < limit; i++) { MAofRSIBuffer[i]=iMAOnArray(RSIBuffer,0,MAofRSI,0,MA_method,i); }
search for cross means RSIBuffer[i+1]>MAofRSIBuffer[i+1] and RSIBuffer[i]<MAofRSIBuffer[i]
or RSIBuffer[i+1]<MAofRSIBuffer[i+1] and RSIBuffer[i]>MAofRSIBuffer[i]
search for cross means RSIBuffer[i+1]>MAofRSIBuffer[i+1] and RSIBuffer[i]<MAofRSIBuffer[i]
or RSIBuffer[i+1]<MAofRSIBuffer[i+1] and RSIBuffer[i]>MAofRSIBuffer[i]
or
(RSIBuffer[i+1] - MAofRSIBuffer[i+1]) * (RSIBuffer[i] - MAofRSIBuffer[i]) < 0
or
bool wasAbove = RSIBuffer[i+1] > MAofRSIBuffer[i+1], isAbove = RSIBuffer[i] > MAofRSIBuffer[i], isCross = isAbove != wasAbove;
search for cross means RSIBuffer[i+1]>MAofRSIBuffer[i+1] and RSIBuffer[i]<MAofRSIBuffer[i]
or RSIBuffer[i+1]<MAofRSIBuffer[i+1] and RSIBuffer[i]>MAofRSIBuffer[i]
It doesn't work ! In my EA I have created the following function to check MA on RSI ARRAY. But I have only SELL signal.
Following there is my code. What I made wrong?
int CheckMaOnRsi() { int i; int limit; int counted_bars=IndicatorCounted(); double RSIBuffer[], MAofRSIBuffer[]; /* check for possible errors */ if(counted_bars<0) return(-1); /* last counted bar will be recounted */ if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; /* main loops 1 and 2 */ for(i=0; i < limit; i++) { RSIBuffer[i]=iRSI(Symbol(),0,ARRAY_RSI_PERIOD,ARRAY_RSI_PRICE,i); MAofRSIBuffer[i]=iMAOnArray(RSIBuffer,0,ARRAY_MA_PERIOD,0,ARRAY_MA_METHOD,i); if ((RSIBuffer[i+1] - MAofRSIBuffer[i+1]) * (RSIBuffer[i] - MAofRSIBuffer[i]) < 0) {return(-1);} if ((RSIBuffer[i+1] - MAofRSIBuffer[i+1]) * (RSIBuffer[i] - MAofRSIBuffer[i]) > 0) {return(1);} /* // OR if (RSIBuffer[i+1]>MAofRSIBuffer[i+1] && RSIBuffer[i]<MAofRSIBuffer[i]) {return(-1);} if (RSIBuffer[i+1]<MAofRSIBuffer[i+1] && RSIBuffer[i]>MAofRSIBuffer[i]) {return(1);} */ } return(0); }
It doesn't work ! In my EA I have created the following function to check MA on RSI ARRAY. But I have only SELL signal.
Following there is my code. What I made wrong?
You cannot use Indicator code in an EA. for example, IndicatorCounted(), from here: https://docs.mql4.com/customind
"These functions cannot be used in experts and scripts."
You cannot use Indicator code in an EA. for example, IndicatorCounted(), from here: https://docs.mql4.com/customind
"These functions cannot be used in experts and scripts."
Hi RaptorUK, Should I create the separate indicator with the following code? And after create indicator should I use iCustom() funtion in order to use it in my EA ?
int i; int limit; int counted_bars=IndicatorCounted(); //---- check for possible errors if(counted_bars<0) return(-1); //---- last counted bar will be recounted if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; //--- main loops 1 and 2 for(i=0; i < limit; i++) { RSIBuffer[i]=iRSI(Symbol(),0,RSIPeriod,PRICE_CLOSE,i); } for(i=0; i < limit; i++) { MAofRSIBuffer[i]=iMAOnArray(RSIBuffer,0,MAofRSI,0,MA_method,i); }
Hi RaptorUK, Should I create the separate indicator with the following code? And after create indicator should I use iCustom() funtion in order to use it in my EA ?

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
I have opened chart and under the bars there is RSI indicator and Moving Average indicator on RSI (not on the bars) as first or previous indicator data.
Question: Can I code the moment when the line of Moving Average cut RSI line or vice versa?
Rgds,