//+------------------------------------------------------------------+ //| RSI.mq4 | //+------------------------------------------------------------------+ //---- indicator settings #property indicator_separate_window #property indicator_buffers 4 extern string pair1="EURUSD"; extern string pair2="USDCHF"; extern string pair3="USDJPY"; extern string pair4="GBPUSD"; extern int RSIPeriod=14; extern int TimeFrame=0; //1=1minute;5=5minutes;15=15minutes;30=30minutes;60=1Hour;240=4Hour;1440=Daily; extern double level1=25; extern double level2=50; extern double level3=75; double RSI_PAIR1[]; double RSI_PAIR2[]; double RSI_PAIR3[]; double RSI_PAIR4[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- drawing settings SetLevelStyle(STYLE_DOT,1,LightSlateGray); SetLevelValue(0,level1); SetLevelValue(1,level2); SetLevelValue(2,level3); SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1,RoyalBlue); SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,1,LimeGreen); SetIndexStyle(2,DRAW_LINE,STYLE_SOLID,1,Yellow); SetIndexStyle(3,DRAW_LINE,STYLE_SOLID,1,Red); IndicatorDigits(Digits+1); SetIndexDrawBegin(0,21); SetIndexDrawBegin(1,21); SetIndexDrawBegin(2,21); SetIndexDrawBegin(3,21); //---- 3 indicator buffers mapping SetIndexBuffer(0,RSI_PAIR1); SetIndexBuffer(1,RSI_PAIR2); SetIndexBuffer(2,RSI_PAIR3); SetIndexBuffer(3,RSI_PAIR4); //---- name for DataWindow and indicator subwindow label switch(TimeFrame) { case 1 : string TimeFrameStr="M1"; break; case 5 : TimeFrameStr="M5"; break; case 15 : TimeFrameStr="M15"; break; case 30 : TimeFrameStr="M30"; break; case 60 : TimeFrameStr="H1"; break; case 240 : TimeFrameStr="H4"; break; case 1440 : TimeFrameStr="D1"; break; case 10080 : TimeFrameStr="W1"; break; case 43200 : TimeFrameStr="MN1"; break; default : TimeFrameStr=""; } IndicatorShortName("RSI "+TimeFrameStr+" ("+RSIPeriod+")"); SetIndexLabel(0,pair1); SetIndexLabel(1,pair2); SetIndexLabel(2,pair3); SetIndexLabel(3,pair4); //---- initialization done return(0); } //+------------------------------------------------------------------+ //| Commodity Channel Index | //+------------------------------------------------------------------+ int start() { int i,limit=2000; double PAIR1[2000]; double PAIR2[2000]; double PAIR3[2000]; double PAIR4[2000]; //---- last counted bar will be recounted int limitPAIR1=ArraySize(PAIR1); ArraySetAsSeries(PAIR1,true); for(i=0; i<limitPAIR1; i++) PAIR1[i]=iClose(pair1,TimeFrame,i); int limitPAIR2=ArraySize(PAIR2); ArraySetAsSeries(PAIR2,true); for(i=0; i<limitPAIR2; i++) PAIR2[i]=iClose(pair2,TimeFrame,i); int limitPAIR3=ArraySize(PAIR3); ArraySetAsSeries(PAIR3,true); for(i=0; i<limitPAIR3; i++) PAIR3[i]=iClose(pair3,TimeFrame,i); int limitPAIR4=ArraySize(PAIR4); ArraySetAsSeries(PAIR4,true); for(i=0; i<limitPAIR4; i++) PAIR4[i]=iClose(pair4,TimeFrame,i); //---- RSI for(i=0; i<limit; i++) RSI_PAIR1[i]=iRSIOnArray(PAIR1,limit,RSIPeriod,i); for(i=0; i<limit; i++) RSI_PAIR2[i]=iRSIOnArray(PAIR2,limit,RSIPeriod,i); for(i=0; i<limit; i++) RSI_PAIR3[i]=iRSIOnArray(PAIR3,limit,RSIPeriod,i); for(i=0; i<limit; i++) RSI_PAIR4[i]=iRSIOnArray(PAIR4,limit,RSIPeriod,i); //---- done return(0); }
You should iBarShift(,, Time[i]) instead of i
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
Hi,
This is my first post here and I am looking for an indicator that would allow me to make one chart cover another to check for correlations.
Thanks in advance for your help.
Regards,
Omar Arnaout