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 trilliantrader, 04-18-2024, 08:16 AM
        5 responses
        22 views
        0 likes
        Last Post trilliantrader  
        Started by Davidtowleii, Today, 12:15 AM
        0 responses
        3 views
        0 likes
        Last Post Davidtowleii  
        Started by guillembm, Yesterday, 11:25 AM
        2 responses
        9 views
        0 likes
        Last Post guillembm  
        Started by junkone, 04-21-2024, 07:17 AM
        9 responses
        70 views
        0 likes
        Last Post jeronymite  
        Started by mgco4you, Yesterday, 09:46 PM
        1 response
        14 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Working...
        X