PDA

View Full Version : Position.Avgprice


james377
11-01-2010, 03:52 PM
Print ("Position.AvgPrice = " + Position.AvgPrice);
EnterLongStop(High[1] + (entry * ATR(14)[0]), "");

Why does this print a value before I have entered the trade?

is this Position.AvgPrice looking at my last trade or something???

how do i clear this value or set it to 0 as it seems to be messing up my calculations further on in my code..

or could somebody tell me why this is happening?

NinjaTrader_RyanM
11-01-2010, 04:24 PM
Hello James 377,

Position.Avg price returns zero when you're flat.

You could check that you are in a position prior to accessing it.

if (Position.MarketPosition != MarketPosition.Flat)
Print ("Position.AvgPrice = " + Position.AvgPrice);