PDA

View Full Version : Absolute value


snake
08-26-2007, 06:35 PM
I've been trying to make this code work:

abs(Close[0]-Close[1]

but I get the following message:

The name 'abs' does not exist in the current context.

I searched the Help files and find 'Math.Abs' but that will not work either.

Can anyone help?

snake

NinjaTrader_Josh
08-26-2007, 09:45 PM
Math.Abs(Close[0]-Close[1])Because you are referencing an index of 1 you need to make sure you have this at the start of OnBarUpdate():
if (CurrentBar < 1)
return;
You need to do this because there is no "1" on the very first bar and that causes errors.