some question about the section of codes

 

About below Indicator, I have some questions as below:

1. when "#property indicator_chart_window" is available, we get the result is:

when "#property indicator_separate_window" is available, we get the result is:

the first picture shows the indicator draw "dot" between x1 and x2 area; the second picture shows the indicator draws both "dot" from lowest point to x1 and "dot" from lowest point to x2 which is covered the "dots" from lowest point to x1; I don't know why? maybe this is defined by MT4? In addition, when the indicator is attached to chart, and we get the "dot" lines, then if I compile the indicator's code(whatever I have changed some codes or not, or changed right or wrong), the "dot" lines will become solid lines at once, why?

2. shall I get more information about SetLevelValue(), in the fact I don't know what is its exactly effect after view its introduction in MQL4 and other place; when we should use it? for what?

In this indicator, I find nothing changes when I delete it or change its parameters.

3. In addition, some time I find some Indicator made by others, in which "SetIndexBuffer(n,x);" will be written two times in" int init()", or /and "SetIndexStyle(n,DRAW_ARROW,STYLE_SOLID,2);" is written in "int start()" when it has been written" in int init()", I want to know the reason to do these?


//#property  indicator_separate_window
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Tan//Red
#property indicator_color2 Tan

//---- buffers
double x1[];
double x2[];

int init()
  {

   SetLevelValue(0,0.0);
   IndicatorBuffers(2);
   SetIndexBuffer(0,x1);
   SetIndexBuffer(1,x2);
   SetIndexStyle(0,DRAW_HISTOGRAM,2, 1);
   SetIndexStyle(1,DRAW_HISTOGRAM,2, 1);
   return(0);
  }

int deinit()
  {
   return(0);
  }

int start()
  {
int counted_bars=IndicatorCounted();
for (int i= Bars-counted_bars-1;i>=0;i--)
{
x1[i]= High[i]+200*Point;
x2[i]= High[i]+100*Point;
}
   return(0);
  }
 
Nobody knows?
 
vx0532: About below Indicator, I have some questions as below:
1) the first picture shows the indicator draw "dot" between x1 and x2 area; the second picture shows the indicator draws both "dot" from lowest point to x1 and "dot" from lowest point to x2 which is covered the "dots" from lowest point to x1; I don't know why?
Here: https://www.mql5.com/en/forum/131068.
maybe this is defined by MT4? In addition, when the indicator is attached to chart, and we get the "dot" lines, then if I compile the indicator's code(whatever I have changed some codes or not, or changed right or wrong), the "dot" lines will become solid lines at once, why?

It probably goes through Un_Initialize REASON_RECOMPILE without going through init() where it would see dot. Search the forum for more information of what happen during these phases.

https://docs.mql4.com/check/UninitializeReason

2. shall I get more information about SetLevelValue(), in the fact I don't know what is its exactly effect after view its introduction in MQL4 and other place; when we should use it? for what?

Yes you shall get more information. Last time I checked, it drew a Horizontal_Line at 70 or 30 like in RSI_Indicator. If you cannot see the level then perhaps the level isn't on the chart. Example EurUsd price is usually 1.2345. If you plot RSI 70|30 on price chart, you'll never see the levels ... because they're too far away from price of 1.

3. In addition, some time I find some Indicator made by others, in which "SetIndexBuffer(n,x);" will be written two times in" int init()", or /and "SetIndexStyle(n,DRAW_ARROW,STYLE_SOLID,2);" is written in "int start()" when it has been written" in int init()", I want to know the reason to do these?

What ever you can do within init() you usually can also do within start(). Some programmers do-not trust/understand the UninitializeReason process and might rather choose start. You'll be better off asking the authors the why questions.

 
ubzen:
Here: https://www.mql5.com/en/forum/131068.

It probably goes through Un_Initialize REASON_RECOMPILE without going through init() where it would see dot. Search the forum for more information of what happen during these phases.

https://docs.mql4.com/check/UninitializeReason

Yes you shall get more information. Last time I checked, it drew a Horizontal_Line at 70 or 30 like in RSI_Indicator. If you cannot see the level then perhaps the level isn't on the chart. Example EurUsd price is usually 1.2345. If you plot RSI 70|30 on price chart, you'll never see the levels ... because they're too far away from price of 1.

What ever you can do within init() you usually can also do within start(). Some programmers do-not trust/understand the UninitializeReason process and might rather choose start. You'll be better off asking the authors the why questions.


Thanks for all your details.