How to paint "Close[i]/High[i]" in seperate window?

 

hi everyone, when i try to draw a line of "(Close-Low)/(High-Low)", i get a very strange result. to my opinion, the line will wave between 0 and 1, but actual result is a straint line, i'm puzzled, can some one explain this?

here is my simple code:

//-----------------------------------------

#property indicator_separate_window

#property indicator_buffers 1

#property indicator_color1 White

double buffer1[];

int CountedBars=0;

int init()

{

SetIndexBuffer(0,buffer1);

return(0);

}

int start()

{

CountedBars=IndicatorCounted();

if(Bars<1) return(0);

for(int i=Bars-CountedBars;i>=0;i--)

{

buffer1=(Close-Low)/(High-Low);

}

}

 
inssuc:
hi everyone, when i try to draw a line of "(Close-Low)/(High-Low)", i get a very strange result. to my opinion, the line will wave between 0 and 1, but actual result is a straint line, i'm puzzled, can some one explain this?

here is my simple code:

//-----------------------------------------

#property indicator_separate_window

#property indicator_buffers 1

#property indicator_color1 White

double buffer1[];

int CountedBars=0;

int init()

{

SetIndexBuffer(0,buffer1);

return(0);

}

int start()

{

CountedBars=IndicatorCounted();

if(Bars<1) return(0);

for(int i=Bars-CountedBars;i>=0;i--)

{

if( (Close-Low) > 0 && (High-Low) > 0 )

}

}

add

if( (Close-Low) > 0 && (High-Low) > 0 )

above : if( (Close-Low) > 0 && (High-Low) > 0 )

like :

{

if( (Close-Low) > 0 && (High-Low) > 0 )

buffer1=(Close-Low)/(High-Low);

}

 

thanks

it works, thanks! but i still don't understand why the condition "High-Low>0" is needed? can High<=Low in sometime?

And, the line should be painted anyway, the condition is just tell mt4 when draw when not draw, why mt4 don't draw without the condition?

 
inssuc:
can High<=Low in sometime?

High may equal Low (first tick of a bar, or volume = 1 bar) then you divide by zero and the indic stops working.

Reason: