Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Entry price of and Order submitted by a Strategy

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

    Entry price of and Order submitted by a Strategy

    Hi,

    I would like to get to the price at which an Order, submitted via Strategy, was filled. Can you provide a link to the help ? Thank you.

    Anthony

    #2
    Hello Anthony_0709,

    Thank you for your post.

    Are you wanting to print the price of an order using a script made by the Strategy Builder or a script in the NinjaScript Editor?

    You could simply print the price of a position by checking if Position.MarketPosition != MarketPosition.Flat followed by printing the price using Position.AveragePrice. Please see the attached example 'GetMarketPosition' which demonstrates how this could be accomplished.

    Or, you could print the price of an account position by printing PositionAccount.AveragePrice.

    You could get the price of an account position when using AddOn Framework by looping through the positions in account.Position and print position.AveragePrice to see the price of the position. Please see the attached example 'PrintAccountPositions' which demonstrates how this could be done.

    Additionally, here are some help guide links below for more information,

    Position - https://ninjatrader.com/support/help...8/position.htm

    PositionAccount - https://ninjatrader.com/support/help...ionaccount.htm

    AddOn Framework Account Positon - https://ninjatrader.com/support/help...ns_account.htm

    Let us know if we may assist further.
    Attached Files
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      Hi,

      Good day !

      When does Position.AveragePrice get updated (populated) ? Because I'm getting zero (0).

      Calculate=OnEachTick, IsFirstTickOfBar=true, other conditions are met: -> EnterLong(), (I can see on the chart that the order was filled), myFillPrice = Position.AveragePrice, return;

      All of the above is done during the same cycle/instance. On the following tick "myFillPrice" reports zero (0). Is Position.AveragePrice available right after EnterLong() and during the same cycle/instance or upon the following tick(s) ? Do I have to use OnOrderUpdate() ?

      Thank you.

      Anthony

      Comment


        #4
        Hello Anthony_0709,

        Thank you for your note.

        Position.AveragePrice would get updated in OnBarUpdate on the next bar after an order is submitted. This means that you would need to place your print for Position.AveragePrice after checking that the order has been submitted. This ensures that the position was submitted and Position.AveragePrice has been updated.

        For example, in the GetMarketPosition example attached in post 2 we check if Position.MarketPosition == MarketPosition.Flat and EnterLong. Then, we check if the position is filled by checking if Position.MarketPosition == MarketPosition.Long followed by adding our print to get the Position.AveragePrice of the filled position.

        Please let us know if we may assist further.
        Brandon H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by JT2020, Today, 04:23 AM
        0 responses
        1 view
        0 likes
        Last Post JT2020
        by JT2020
         
        Started by aslane, Today, 02:50 AM
        0 responses
        3 views
        0 likes
        Last Post aslane
        by aslane
         
        Started by fx.practic, Today, 02:07 AM
        2 responses
        10 views
        0 likes
        Last Post fx.practic  
        Started by Ousher, Today, 01:29 AM
        0 responses
        9 views
        0 likes
        Last Post Ousher
        by Ousher
         
        Started by tonynt, Today, 01:23 AM
        0 responses
        4 views
        0 likes
        Last Post tonynt
        by tonynt
         
        Working...
        X