about executing order for Indicator/EA/Script

 

now I have make an Indicator, besides the indicator line, also drawing another line -- x.

the code as below:

when I attached to the chart. the line x will not be drawn(Expert complain unknown window), but if I compile the code again, the line x will shown.

Then I want to know get some explanation about this, and know the exact executing order for codes.

Thanks.

#property indicator_separate_window
#property  indicator_buffers 1
#property  indicator_color1  Red

  double   PT_Buffer[];

  int init()
  {     
    IndicatorBuffers      (1);
    SetIndexBuffer        (0, PT_Buffer);
    SetIndexStyle         (0,DRAW_SECTION, STYLE_SOLID, 2);
    SetIndexDrawBegin     (0,10);
    SetIndexLabel         (0,"Swing_Ratio 1");
    
    ObjectCreate ("UpLine",OBJ_HLINE,1,0,10);  // for the line x
    ObjectSet    ("UpLine",OBJPROP_STYLE,STYLE_SOLID);
    ObjectSet    ("UpLine",OBJPROP_COLOR,Red);
    ObjectSet    ("UpLine",OBJPROP_WIDTH,1);
   
    return(0);
  }
  
  int deinit()
  {
    ObjectsDeleteAll();
    return(0);
  }

  int start()
  {    
.......
.........

    return(0) ;
  }

 


 
vx0532:

now I have make an Indicator, besides the indicator line, also drawing another line -- x.

the code as below:

when I attached to the chart. the line x will not be drawn(Expert complain unknown window), but if I compile the code again, the line x will shown.

Then I want to know get some explanation about this, and know the exact executing order for codes.

Thanks.


Are you drawing lines using Indicator buffers or using Objects ? or are you drawing one line with a buffer and another with Objects ? the separate window probably doesn't exist when init() is called, move your Object code to start and check if the window exists.
 
RaptorUK:
Are you drawing lines using Indicator buffers or using Objects ? or are you drawing one line with a buffer and another with Objects ? the separate window probably doesn't exist when init() is called, move your Object code to start and check if the window exists.

yes, I drawing one line with a buffer and anther with Object. I know when I move the "Object " into start(), it works well.

but I want to know when the separate window exist ?

 
vx0532:

yes, I drawing one line with a buffer and anther with Object. I know when I move the "Object " into start(), it works well.

but I want to know when the separate window exist ?

I don't know for certain but probably when the Indicator buffer is first used and a value written to it, so the first tick that calls start() . . . . I think.
 
RaptorUK:
I don't know for certain but probably when the Indicator buffer is first used and a value written to it, so the first tick that calls start() . . . . I think.


Ok, Thanks

I guest the executing order for the codes in Indicator is as below:

int init() function run at the first of all the codes, then the start() function and #property, and then int deinit().

Reason: