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 agclub, Yesterday, 08:57 PM
        2 responses
        16 views
        0 likes
        Last Post agclub
        by agclub
         
        Started by cre8able, 04-17-2024, 04:16 PM
        6 responses
        55 views
        0 likes
        Last Post cre8able  
        Started by Mindset, 05-06-2023, 09:03 PM
        13 responses
        293 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by kaywai, 09-01-2023, 08:44 PM
        4 responses
        600 views
        0 likes
        Last Post joselube001  
        Started by dpolyakov, 03-29-2024, 11:30 AM
        3 responses
        135 views
        2 likes
        Last Post sonia0101  
        Working...
        X