Draw trendline on RSI

 

i, I am trying to make an indicator that draws a horizontal line from current RSI value and plotting X bars back. I have made an indicator that does it on price, but I am not sure how to do the same thing on the RSI indicator. Can anyone guide me in the right direction? 

attached is a screenshot of what I am trying to create.

Here is the indicator that plots the line on the main chart: 

#property indicator_chart_window

string lineName = "Line";

input int BarsBack = 10;


void OnDeinit(const int reason)
{
    // Delete the trendline when the indicator is closed
    ObjectDelete(0, lineName);
}

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[])
{
    // Calculate the start time
    datetime start_ =   iTime(Symbol(),PERIOD_CURRENT,BarsBack) ;
    
     // Calculate the finish time
    datetime finish_ =   iTime(Symbol(),PERIOD_CURRENT,0) ;

    // Calculate the current price
    double PriceNow = iClose(_Symbol, PERIOD_CURRENT, 0);

    // Remove the previous trendline
    ObjectDelete(0, lineName);

    // Draw the line using OBJ_TREND
    ObjectCreate(0, lineName, OBJ_TREND, 0, start_, PriceNow, finish_, PriceNow);
    ObjectSetInteger(0, lineName, OBJPROP_COLOR, clrWhite);
    ObjectSetInteger(0, lineName, OBJPROP_STYLE, STYLE_SOLID);
    ObjectSetInteger(0, lineName, OBJPROP_WIDTH, 1);
    ObjectSetInteger(0, lineName, OBJPROP_RAY, false);

    // Bring the line to the foreground
    ObjectMove(0, lineName, 0, start_, PriceNow);

    return(rates_total);
}
Documentation on MQL5: Constants, Enumerations and Structures / Objects Constants / Object Types
Documentation on MQL5: Constants, Enumerations and Structures / Objects Constants / Object Types
  • www.mql5.com
Object Types - Objects Constants - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
altmql:

i, I am trying to make an indicator that draws a horizontal line from current RSI value and plotting X bars back. I have made an indicator that does it on price, but I am not sure how to do the same thing on the RSI indicator. Can anyone guide me in the right direction? 

attached is a screenshot of what I am trying to create.

Here is the indicator that plots the line on the main chart: 

Never mind, found a solution

 
altmql #: Never mind, found a solution

Don't do that. Someone searching might find this thread and still be clueless. What was the problem? What solved what?
     How To Ask Questions The Smart Way. (2004)
       When You Ask.
          Follow up with a brief note on the solution.

 
altmql #:

Never mind, found a solution

what is it?

 
    ObjectCreate(0, lineName, OBJ_TREND, 0, start_, PriceNow, finish_, PriceNow);
OP is creating the line on the main chart, not on the RSI sub-chart.