Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Displaying Profit/Loss on Chart in a Strategy

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

    Displaying Profit/Loss on Chart in a Strategy

    Hello.

    I'm writing a strategy to keep track of cumulative profit and loss.

    I want to have a real time display of the profit and loss on the chart while the strategy is running.

    Would you have a code snippet lying around that would accomplish that?

    Regards,
    R. C.

    #2
    RC, what kind of Pnl? The one of the current open position, this would be simply be GetProfitLoss() - http://www.ninjatrader-support.com/H...rofitLoss.html

    For example for the daily one, or the RealTimeTrades taken one since strategy start, you would need to work with the Performance class -

    Comment


      #3
      Thanks for the reply.

      I will take a look at that information. But I really was interested in some help with the code to display the profit and loss on the chart.

      So as an example, lets say I have a strategy running against SIM101, and I want to test out the strategy against the ES real time data for the day.

      As the trades are being executed, managed, and closed out, I want the profit and loss displayed, in a large font, on the chart. Not just to the output window.

      So in the upper left corner of the chart, I would like the following displayed and updated:

      ProfitnLoss for closed trades : (displayed in currency)
      ProfitnLoss for open trades : (displayed in currency)

      Can you direct me to the code that handles putting that display on the chart?

      Thanks

      Comment


        #4
        RC, as an example for the current open PnL and closed realtime Pnl you could add this to your strategy -
        Code:
         
         
        if (Position.MarketPosition != MarketPosition.Flat) 
        {
        DrawTextFixed("PnL1", "Open PnL: " + Position.GetProfitLoss(Close[0], PerformanceUnit.Currency), TextPosition.TopLeft); 
        DrawTextFixed("PnL2", "Closed PnL: " + Performance.RealtimeTrades.TradesPerformance.Currency.CumProfit.ToString(), TextPosition.TopRight); 
        }
        Last edited by NinjaTrader_Bertrand; 03-10-2010, 09:21 AM.

        Comment


          #5
          That's what I needed.

          Thanks much

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          647 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          369 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          108 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          572 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          573 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X