How do I get EA to draw horizontal line in indicator window rather than main chart window.

 

Hi All,


I'm using the boilerplate code to create Horizontal line without any trouble in the main chart (snippet below), but can't figure out how to get them to draw in the RSI window. I assume it has to do with Chart ID, but I can't figure out how to find the Chart ID of the RSI window.


Any help would be greatly appreciated. 


 if(!ObjectCreate(chart_ID,name,OBJ_HLINE,0,0,price))
     {
      Print(__FUNCTION__,
            ": failed to create a horizontal line! Error code = ",GetLastError());
      ;
     }
 

Read the documentation.

bool  ObjectCreate( 
   long         chart_id,      // chart identifier 
   string       name,          // object name 
   ENUM_OBJECT  type,          // object type 
   sub_window   nwin,          // window index 
   datetime     time1,         // time of the first anchor point 
   double       price1,        // price of the first anchor point 
   ... 
   datetime     timeN=0,       // time of the N-th anchor point 
   double       priceN=0,      // price of the N-th anchor point 
   ... 
   datetime     time30=0,      // time of the 30th anchor point 
   double       price30=0      // price of the 30th anchor point 
   );
 
Thanks for that. 
 
alexpekar:

Hi All,


I'm using the boilerplate code to create Horizontal line without any trouble in the main chart (snippet below), but can't figure out how to get them to draw in the RSI window. I assume it has to do with Chart ID, but I can't figure out how to find the Chart ID of the RSI window.


Any help would be greatly appreciated. 


string symbol="YourSymbol";
string period="YourSymbolPeriod";

long a=ChartOpen(symbol,period);
 
if(!ObjectCreate(a,"name",OBJ_HLINE,0,0,MarketInfo(symbol,MODE_ASK)))
     {
      Print(__FUNCTION__,
            ": failed to create a horizontal line! Error code = ",GetLastError());
      ;
     }

Goodluck!!!!

 
Tan Ek Kun #:

Goodluck!!!!

Why have you posted basically the same code as the OP that draws a  line in the main chart window?

 
alexpekar: I'm using the boilerplate code to create Horizontal line without any trouble in the main chart (snippet below), but can't figure out how to get them to draw in the RSI window. I assume it has to do with Chart ID, but I can't figure out how to find the Chart ID of the RSI window.
  1. Perhaps you should read the manual; nothing to do with Chart ID. ChartWindowFind - Chart Operations - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
       How To Ask Questions The Smart Way. (2004)
          How To Interpret Answers.
             RTFM and STFW: How To Tell You've Seriously Screwed Up.

  2. if(!ObjectCreate(chart_ID,name,OBJ_HLINE,0,0,price))

    Now that you know how, the question is why? The RSI window is always in the range [0 … 100]. A price (1.23450±) will be a straight line at the bottom. Useless.

Reason: