Coding question

 

Hi everyone I want to ask a question.

I tried to make percent increase or percent decrease indicator.

So I made code like that


int limit=Bars-IndicatorCounted();

for(int i=limit-i;i>0;i--)

{

Buffer[i]=close[i]/Close[i+1];

}  


but that was never work.


I changed above code / to - like that

Buffer[i]=close[i]-Close[i+1];

I notice that is work and I checked

Comment(Close[0]/Close[1])

is working correctly

so I can't understand why Buffer[i]=close[i]/Close[i+1]; was not working.


 could anybody please suggest how to code? thanks a lot 

 
Apparently this is another 'zero divide' issue. See https://forum.mql4.com/21364
 
close[i]/Close[i+1] should draw in subwindow, since the value maybe not in range of Axes of main wondw
 
DxdCn:
close[i]/Close[i+1] should draw in subwindow, since the value maybe not in range of Axes of main wondw

Thanks every my mentors!! I solved the problem for you. thanks a lot

 

Replace

Buffer[i]=close[i]/Close[i+1];

to

Buffer[i]=Close[i]/Close[i+1];

Reason: