Drawing Trend Line in separate indicator window causing issue

 

I am trying to draw a trend line in a separate indicator window , but the lines are being drawn in the main window instead of indicator window 

What am i doing wrong ?

here is my code :

 
#property indicator_separate_window
#property indicator_minimum 1
#property indicator_maximum 2
int OnInit()
  {   
    for(int i = 1000; i >= 0; i--)
     {
      if(iMA(NULL, PERIOD_CURRENT, 14, 0, MODE_SMA, PRICE_CLOSE, i) > iMA(NULL, PERIOD_CURRENT, 21, 0, MODE_SMA, PRICE_CLOSE, i))
        {
         double price1 =  1;
         double price2 = 1.5;

            ObjectCreate(0,i,OBJ_TREND,0, Time[i+15],price1 , Time[i] ,price2 );
            ObjectSetInteger(0,i,OBJPROP_COLOR,clrGreen);
            ObjectSetInteger(0,i,OBJPROP_STYLE,STYLE_SOLID);
            ObjectSetInteger(0,i,OBJPROP_WIDTH,1);
            ObjectSetInteger(0,i,OBJPROP_BACK,false);
            ObjectSetInteger(0,i,OBJPROP_SELECTABLE,false);
            ObjectSetInteger(0,i,OBJPROP_SELECTED,false);
            ObjectSetInteger(0,i,OBJPROP_RAY_RIGHT,false);
            ObjectSetInteger(0,i,OBJPROP_HIDDEN,true);        
 }
 }
   return(INIT_SUCCEEDED);
  }
 
int start( )
  {
    
  }
 
 
What is the first parameter of create?
 

William Roeder:
What is the first parameter of create?

Thanks William Roeder , and pardon my goofy mistake

 

I am trying to draw a horizontal line in a separate indicator window , but the lines are being drawn in the main window instead of indicator window 

What am i doing wrong ?

my code


    double X=1.9498;
   ObjectCreate(,"w0",OBJ_HLINE,0,  Time[i] ,X );
   ObjectSet("w0", OBJPROP_STYLE, 1);
   ObjectSet("w0",OBJPROP_WIDTH,2);
   ObjectSet("w0", OBJPROP_COLOR, clrNavy);

 
Zbynek Liska #:

I am trying to draw a horizontal line in a separate indicator window , but the lines are being drawn in the main window instead of indicator window 

What am i doing wrong ?

my code


    double X=1.9498;
   ObjectCreate(,"w0",OBJ_HLINE,0,  Time[i] ,X );
   ObjectSet("w0", OBJPROP_STYLE, 1);
   ObjectSet("w0",OBJPROP_WIDTH,2);
   ObjectSet("w0", OBJPROP_COLOR, clrNavy);

#property indicator_separate_window

checked this line?

 
do I have it, but the line is drawn in the main chart
 
Zbynek Liska #:
do I have it, but the line is drawn in the main chart

I mean you should have this line at the header part of your indicator codes.

Probably you have 

#property indicator_chart_window this.

 
Sagheer Asghar:

I am trying to draw a trend line in a separate indicator window , but the lines are being drawn in the main window instead of indicator window 

What am i doing wrong ?

here is my code :

Hi you must use parameter "sub_window"

At your code I see "0". It mean main window. Toi draw line at indocator window you must use number of sub_window your indicator. For this you can use function ChartWindowFind.


 

#property copyright ""
#property link      ""
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 OrangeRed

That's how I got it, is that right?
 
Zbynek Liska #:

#property copyright ""
#property link      ""
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 OrangeRed

That's how I got it, is that right?

yes

 
#property copyright ""
#property link      ""
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 OrangeRed


extern string Currency = "JPY";
extern string Select1 = "Select USD-EUR-GBP or AUD";
extern string Select2 = "Select CHF-JPY-CAD or NZD";

double EurUsd[],UsdChf[],GbpUsd[],UsdJpy[],AudUsd[],UsdCad[],NzdUsd[];
double Idx[];

int init()
{
   IndicatorShortName("Selected Index ("+Currency+")");
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,Idx);
   return(0);
}

void start()
{
  
   ArrayCopySeries(EurUsd,MODE_CLOSE,"EURUSD");
   ArrayCopySeries(GbpUsd,MODE_CLOSE,"GBPUSD");
   ArrayCopySeries(AudUsd,MODE_CLOSE,"AUDUSD");
   ArrayCopySeries(UsdChf,MODE_CLOSE,"USDCHF");
   ArrayCopySeries(UsdJpy,MODE_CLOSE,"USDJPY");
   ArrayCopySeries(UsdCad,MODE_CLOSE,"USDCAD");
   ArrayCopySeries(NzdUsd,MODE_CLOSE,"NZDUSD");

   int counted_bars=IndicatorCounted();
   double minArraySize;
   double USD;

   minArraySize = MathMin(ArraySize(EurUsd),ArraySize(GbpUsd));
   minArraySize = MathMin(ArraySize(AudUsd),minArraySize);
   minArraySize = MathMin(ArraySize(UsdChf),minArraySize);
   minArraySize = MathMin(ArraySize(UsdJpy),minArraySize);
   minArraySize = MathMin(ArraySize(UsdCad),minArraySize);
   minArraySize = MathMin(ArraySize(NzdUsd),minArraySize);
   
   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
   int limit=Bars-counted_bars;
       limit=MathMin(limit,NormalizeDouble(minArraySize,0));
   for(int i=0; i<limit; i++)
   {
      USD = MathPow(UsdChf[i]*UsdJpy[i]*UsdCad[i]/EurUsd[i]/GbpUsd[i]/AudUsd[i]/NzdUsd[i],1./8.);
      if (Currency == "USD_QCW") Idx[i] = USD; 
      if (Currency == "EUR") Idx[i] = USD*EurUsd[i];
      if (Currency == "GBP") Idx[i] = USD*GbpUsd[i];
      if (Currency == "AUD") Idx[i] = USD*AudUsd[i];
      if (Currency == "CHF") Idx[i] = USD/UsdChf[i];
      if (Currency == "JPY") Idx[i] = 1/USD*UsdJpy[i];
      if (Currency == "CAD") Idx[i] = USD/UsdCad[i];
      if (Currency == "NZD") Idx[i] = USD*NzdUsd[i];
   }
   double X=1.9498;
   ObjectCreate(0,"w0",OBJ_HLINE,0,0,X );
   ObjectSet("w0", OBJPROP_STYLE, 1);
   ObjectSet("w0",OBJPROP_WIDTH,2);
   ObjectSet("w0", OBJPROP_COLOR, clrNavy);
   
   
   
   
   
   
 }
this is what the whole code looks like, can't you fix it? thank you very much
Reason: