Hi everyone,
I was initially trying to edit the default RSI indicator code so that it displays RSI values from another currency pair on my current chart. However, I couldn't figure that out, so I am trying a workaround. I am trying to create a custom indicator that simply reads the RSI indicator from a different pair.
Here is my code so far, however it doesn't work correctly.
The values it displays are off by about roughly 2-5, and when I back test, it doesn't display correct values.
Would really appreciate any help and pointers.
I was initially trying to edit the default RSI indicator code so that it displays RSI values from another currency pair on my current chart. However, I couldn't figure that out, so I am trying a workaround. I am trying to create a custom indicator that simply reads the RSI indicator from a different pair.
Here is my code so far, however it doesn't work correctly.
The values it displays are off by about roughly 2-5, and when I back test, it doesn't display correct values.
Would really appreciate any help and pointers.
Inserted Code
//+------------------------------------------------------------------+ //| Test.mq4 | //| Copyright 2020, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2020, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.00" #property strict #property indicator_level1 30.0 #property indicator_level2 70.0 #property indicator_separate_window #property indicator_minimum 0 #property indicator_maximum 100 #property indicator_buffers 1 #property indicator_plots 1 //--- plot one #property indicator_label1 "Eur" #property indicator_type1 DRAW_LINE #property indicator_color1 clrRed #property indicator_style1 STYLE_SOLID #property indicator_width1 1 extern int num = 4; //--- indicator buffers double EurBuffer[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping SetIndexBuffer(0,EurBuffer); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { //--- int uncalculatedBar = rates_total - prev_calculated; for (int i=0; i<uncalculatedBar; i++) { EurBuffer[i] = Calc(i,"EURUSD"); } //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+ double Calc(int pos,string pair) { double Str = iRSI(pair,60,5,PRICE_CLOSE,pos); return(Str); }