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 Enter and Exit Prices

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

    Trade Enter and Exit Prices

    Hello

    How can I get my position entry price using for a position that was executed with the EnterLong command?
    I have tried the following, however, the realEntryPrice value was set to zero. Am I doing something wrong or is it because I'm using a demo account?

    Code:
    IOrder _realEntryOrder = EnterLong();
    double _realEntryPrice = _realEntryOrder.AvgFillPrice;
    The same way I tried to get the exit value but I got the value zero again:

    Code:
    IOrder _realExitOrder = ExitLong();
    double _realExitOrder = ExitShort();
    Thanks

    #2
    Hello Kiss987,

    Where are you calling these methods from? OnBarUpdate(), OnOrderUpdate(), OnExecution()
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      OnBarUpdate

      Comment


        #4
        Hello,

        Thank you for the reply.

        Based on the code this would not report a value if you are calling this directly after the EnterLong statement.

        The order will need a chance to be submitted and filled which you would not directly see after calling it.

        You could declare the variable _realEntryOrder outside of OnBarUpdate so after it is filled you could check the value on future calls to OnBarUpdate. Or you could use OnExectuion or OnOrderUpdate to view the orders progress and values.





        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Are the two events triggered for orders that were made out side of the strategy (for example, on a different strategy)?

          Comment


            #6
            Hello,

            Thank you for the question.

            Each strategy is its own instance so the events in a NinjaScript file would only be related to that strategies orders. Other strategies can not provide data to this strategy, and this strategy can not see data from other strategies.

            I look forward to being of further assistance.
            JesseNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by traderqz, Today, 12:06 AM
            6 responses
            12 views
            0 likes
            Last Post traderqz  
            Started by Skifree, Today, 03:41 AM
            3 responses
            12 views
            0 likes
            Last Post Skifree
            by Skifree
             
            Started by traderqz, Yesterday, 09:06 AM
            5 responses
            33 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by guillembm, Today, 11:25 AM
            1 response
            6 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by owensd, 04-21-2024, 11:34 PM
            9 responses
            34 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Working...
            X