PDA

View Full Version : OnBarUpdate


SystemTrading
08-20-2008, 10:20 AM
The following code only executes once when I initialize the strategy. Afterwards, I get nothing. I would like to see the code Print "OBU" on each tick. What would be the reason this isn't working?

protectedoverridevoid Initialize()
{
CalculateOnBarClose = false;
// TraceOrders = true;
}
///<summary>
/// Called on each bar update event (incoming tick)
///</summary>
protectedoverridevoid OnBarUpdate()
{
Print("OBU");
if (Historical)
return;
}

NinjaTrader_Ray
08-20-2008, 10:25 AM
Any error messages in the Log tab?

Provided that you have enough bars on your chart when you are running the strategy (make sure Min bars requires is set to 20 --> You could try setting to 1 to check) it will print. to the Output window.

SystemTrading
08-20-2008, 10:29 AM
I am getting the following error...

"Error on calling 'OnBarUpdate' method for strategy 'MyStrategy': Object reference not set to an instance of an object."

NinjaTrader_Ray
08-20-2008, 10:38 AM
Thanks, that would explain why you don't see anything. Somewhere in your strategy you have a logic error that causes this exception which terminates the strategy.

Here is a a tip we wrote up to help guide you to resolution.

http://www.ninjatrader-support.com/vb/showthread.php?t=4226