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 bortz, 11-06-2023, 08:04 AM
            47 responses
            1,605 views
            0 likes
            Last Post aligator  
            Started by jaybedreamin, Today, 05:56 PM
            0 responses
            8 views
            0 likes
            Last Post jaybedreamin  
            Started by DJ888, 04-16-2024, 06:09 PM
            6 responses
            18 views
            0 likes
            Last Post DJ888
            by DJ888
             
            Started by Jon17, Today, 04:33 PM
            0 responses
            4 views
            0 likes
            Last Post Jon17
            by Jon17
             
            Started by Javierw.ok, Today, 04:12 PM
            0 responses
            13 views
            0 likes
            Last Post Javierw.ok  
            Working...
            X