Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Position.Avgprice

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Position.Avgprice

    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?

    #2
    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);
    Ryan M.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    68 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    39 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    63 views
    1 like
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    62 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    53 views
    0 likes
    Last Post CarlTrading  
    Working...
    X