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

Trade Entry Price

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

    Trade Entry Price

    Hi ... need to access the entry price of an executed trade from within my code. what function do I use to achieve this? thank you!

    #2
    Hello,

    If this is for a particular order, you can track this information by accessing the IOrder object:

    MatthewNinjaTrader Product Management

    Comment


      #3
      thank you Matthew ... can you give me an example on how I access the filled price?

      Comment


        #4
        You need to first create an IOrder object as per our help guide. Once you've done that, you can get this information using order.AvgFillPrice

        Code:
        			protected override void OnOrderUpdate(IOrder order)
        			{
          			  if (entryOrder != null && entryOrder == order)
          			  {
         
             			    Print(order.AvgFillPrice);
        			}
        This is the Filled Price for the position.

        If you're instead looking for the execution price of a single order, you can use OnExecution to get the IExecution property .Price



        Code:
        			protected override void OnExecution(IExecution execution)
        			{
        				if (entryOrder != null && entryOrder == execution.Order)
        					Print("Execution Price: " + execution.Price);
        			}
        MatthewNinjaTrader Product Management

        Comment


          #5
          Entry Price of the order

          Have you ever find this answer? because I look for entry price function of the order all over but could not find the answer
          Last edited by craigtran; 06-18-2016, 12:49 PM. Reason: update

          Comment


            #6
            Hello craigtran,

            Thank you for writing in and welcome to the NinjaTrader Support Forum!

            NinjaTrader_Matthew has provided a sample of how to obtain the entry price.

            Can you please clarify what you are needing assistance with?
            Zachary G.NinjaTrader Customer Service

            Comment


              #7
              Thanks for replying,

              I am writing a strategy and does not want close the position if the gain did not reach a minimum number.

              So to do that, I need the entry price so I can calculate the gain at that moment.

              Thanks

              Craig

              Comment


                #8
                Hello craigtran,

                Position.AvgPrice will provide the average entry price of your position: https://ninjatrader.com/support/help.../?avgprice.htm
                Zachary G.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by vecnopus, Today, 06:15 AM
                0 responses
                1 view
                0 likes
                Last Post vecnopus  
                Started by Aviram Y, Today, 05:29 AM
                0 responses
                5 views
                0 likes
                Last Post Aviram Y  
                Started by quantismo, 04-17-2024, 05:13 PM
                3 responses
                27 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Started by ScottWalsh, 04-16-2024, 04:29 PM
                7 responses
                36 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Started by cls71, Today, 04:45 AM
                0 responses
                6 views
                0 likes
                Last Post cls71
                by cls71
                 
                Working...
                X