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

referencing exitprice in strategy

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

    referencing exitprice in strategy

    How does one use the exitprice found on the performance table as a reference in a strategy?

    Thank you very much for any specifics you can send along.

    #2
    hilfreq, you can work with the TradeClass for this - http://www.ninjatrader-support.com/H...radeClass.html
    BertrandNinjaTrader Customer Service

    Comment


      #3
      exitprice?

      Truth is....when I look at the tradeclass, I don't see clearly how this ties back to the exitprice specifically, and how I can call that variable in my code. I would like to use the exitprice as a reference, for example, to re-enter a trade.

      Again, I feel confident that since the exitprice is captured and displayed on the performance table, it must be available as a specific value to use in the code.

      If you could help me tie these two pieces together a little more explicitly, I would be most grateful.

      Thanks again!!

      Comment


        #4
        You can try something like this after your entry / exit triggers -

        Code:
         
        if (Performance.RealtimeTrades.Count > 0) 
        { 
        Trade lastTrade =  [FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]Performance.RealtimeTrades[Performance.RealtimeTrades.Count - [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]];
        [/SIZE][/FONT][/SIZE][/FONT] 
        double lastExit = lastTrade.Exit.Price; 
         
        Print("The last trade's exit is " + lastExit); 
        }
        Last edited by NinjaTrader_Bertrand; 11-06-2009, 01:57 PM.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Bertrand,

          Thank you for this snippet.

          Wouldn't [0] mean the first trade of the session? Shouldn't it be count-1?

          Thanks,



          Originally posted by NinjaTrader_Bertrand View Post
          You can try something like this after your entry / exit triggers -

          Code:
           
          if (Performance.RealtimeTrades.Count > 0) 
          { 
          Trade lastTrade = Performance.RealtimeTrades[0]; 
           
          double lastExit = lastTrade.Exit.Price; 
           
          Print("The last trade's exit is " + lastExit); 
          }

          Comment


            #6
            Thanks for spotting this r2kTrader, you're correct - highest values are the most recent ones, will correct the snippet.
            BertrandNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by RubenCazorla, 08-30-2022, 06:36 AM
            3 responses
            77 views
            0 likes
            Last Post PaulMohn  
            Started by f.saeidi, Yesterday, 12:14 PM
            9 responses
            23 views
            0 likes
            Last Post f.saeidi  
            Started by Tim-c, Today, 03:54 AM
            0 responses
            3 views
            0 likes
            Last Post Tim-c
            by Tim-c
             
            Started by FrancisMorro, Today, 03:24 AM
            0 responses
            4 views
            0 likes
            Last Post FrancisMorro  
            Started by Segwin, 05-07-2018, 02:15 PM
            10 responses
            1,772 views
            0 likes
            Last Post Leafcutter  
            Working...
            X