PDA

View Full Version : Indicator disappears


maxpi
09-21-2007, 10:20 PM
I wrote the following expression to plot pro rated volume during a bar:

protectedoverridevoid OnBarUpdate()
{
Value.Set(Volume[0] /Bars.PercentComplete);
}

at the beginning of every bar the indicator goes blank and the bar times on the bottom of the chart disappear. If I "Ctrl+I" and click "ok" the missing displays return until the open of the next bar. What is going on?

NinjaTrader_Josh
09-21-2007, 11:25 PM
Hi maxpi,

Take a look at your error logs and see what its spitting out. From your code I would suspect maybe something related to a division by 0 perhaps. At the open of the next bar your Bars.PercentComplete is 0 so you are doing a undefined division operation.

maxpi
09-22-2007, 09:40 AM
Thanks Josh, the following code works great so far:


protectedoverridevoid OnBarUpdate()
{
if (Bars.PercentComplete>0)
{
Value.Set(Volume[0] /Bars.PercentComplete);
}

}

cunparis
09-19-2011, 01:29 PM
Hi maxpi,

Take a look at your error logs and see what its spitting out. From your code I would suspect maybe something related to a division by 0 perhaps. At the open of the next bar your Bars.PercentComplete is 0 so you are doing a undefined division operation.

I thought I'd update this thread with my own experience. My plot was disappearing on the beginning of each bar. There were no errors in the log or output window. It turns out I was dividing by zero! I do not know why this doesn't appear in the logs (or even if that's possible) but if anyone has a problem of their plots disappearing, you may want to check to make sure you're not dividing by zero.