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 pechtri, 06-22-2023, 02:31 AM
        10 responses
        124 views
        0 likes
        Last Post Leeroy_Jenkins  
        Started by judysamnt7, 03-13-2023, 09:11 AM
        4 responses
        59 views
        0 likes
        Last Post DynamicTest  
        Started by ScottWalsh, Yesterday, 06:52 PM
        4 responses
        36 views
        0 likes
        Last Post ScottWalsh  
        Started by olisav57, Yesterday, 07:39 PM
        0 responses
        7 views
        0 likes
        Last Post olisav57  
        Started by trilliantrader, Yesterday, 03:01 PM
        2 responses
        22 views
        0 likes
        Last Post helpwanted  
        Working...
        X