Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Order Entry Price

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

    Order Entry Price

    I've tried to get this numerous ways, but can't figure out quite how to get the entry price of an order.

    What is the best way to get the entry price of an order?

    Thanks.

    #2
    Hello ATMtrader0001,

    Thanks for your post.

    You could access Position.AveragePrice in OnBarUpdate() as the actual entry price, when the MarketPosition is not flat.

    See this help guide page for more information: https://ninjatrader.com/support/help...erageprice.htm

    Alternately, you can check Order.AverageFillPrice in OnExecutionUpdate()

    See the help guide documentation below for more information.
    OnExecutionUpdate(): https://ninjatrader.com/support/help...tionupdate.htm
    Order: https://ninjatrader.com/support/help...nt8/?order.htm

    Let me know if I may assist further.
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      I tried that and I get the result as 0.

      The code is:
      EnterLong(iOrderSize, szOrderName);
      dOrderPrice = Position.AveragePrice;

      And it returns a 0. Do I need to wait until the next bar/tick for it to update?

      Comment


        #4
        Hello ATMtrader0001,

        Thanks for your note.

        Please see the attached example script which is a modified version of the SampleMACrossover strategy demonstrating how to use Position.AveragePrice.

        Note that we check if Position.MarketPosition == MarketPosition.Long and Position.MarketPosition == MarketPosition.Short to ensure we are in a Long or Short position before printing Position.AveragePrice. If you are in a Flat position, Position.AveragePrice will return 0.

        See this help guide page for more information about Position.MarketPosition: https://ninjatrader.com/support/help...etposition.htm

        Let me know if I may assist further.
        Attached Files
        Brandon H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by dylansmoo, Today, 07:04 PM
        1 response
        5 views
        0 likes
        Last Post NinjaTrader_Kennedy  
        Started by Zinger357, Today, 11:50 AM
        4 responses
        20 views
        0 likes
        Last Post Zinger357  
        Started by WalterSkinner, 02-07-2022, 09:22 AM
        6 responses
        78 views
        0 likes
        Last Post Lance El Camino  
        Started by shorty, Today, 06:20 PM
        1 response
        19 views
        0 likes
        Last Post Tasker-182  
        Started by dweems, Yesterday, 02:11 PM
        1 response
        46 views
        0 likes
        Last Post NinjaTrader_Angelica  
        Working...
        X