Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to Plot Realized P&L on Chart in Seperate Pannel

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

    How to Plot Realized P&L on Chart in Seperate Pannel

    Hi There,

    I have recently come over from the Neoticker Platform where I was for many years and had got comfortable writing code and trading systems in their custom language called "Formula".
    I am at a very basic level with Ninjascript and am getting slowly adjusted to it , but one of the simple functions in Neoticker was "plot := currentequity" . What this did was to plot the realized P&L of the trading system on the same chart but in a seperate panel .
    What would the code be to insert ( or copy and paste) into my system to plot the realized P&L of my system on the chart but in a seperate panel .
    Many thanks,
    Tim

    #2
    Hello raker22,

    "Out of the box", you can add your indicator to a secondary panel, and then set the indicator's DrawOnPricePanel property to "true"

    If you would like to draw on any other panel, you will have to write a "placeholder" indicator with a custom method like

    NT7

    Code:
    [FONT=Courier New]private static Indicator refIndicator;
    public static void DrawToMyTextFixed(string tag, string text, TextPosition textPosition, Color textColor, Font font, Color outlineColor, Color areaColor, int areaOpacity)
    {
      if (refIndicator == null)
      {
        return;
      }
      refIndicator.DrawTextFixed(tag, text, textPosition, textColor, font, outlineColor, areaColor, areaOpacity);
    }[/FONT]
    NT8
    Code:
    [FONT=Courier New]private static Indicator refIndicator;
    public static void DrawToMyTextFixed(string tag, string text, TextPosition textPosition)
    {
      if (refIndicator == null)
      {
        return;
      }
      Draw.TextFixed(refIndicator, tag, text, textPosition);
    }[/FONT]
    Please let us know if there are any other ways we can help.
    Jessica P.NinjaTrader Customer Service

    Comment


      #3
      Thanks for that , but what would the complete code be to insert into my trading system , I have seen on another thread this 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.Curre ncy.CumProfit.ToString(), TextPosition.TopRight);
      }

      Is this code correct for what I want and how do I input your part of the code..
      thanks ,
      Tim

      Comment


        #4
        Hello Raker,

        This isn't so much a matter of code as it is a setting. DrawOnPricePanel = true, in Initialize, will cause DrawText to draw in the first panel. DrawOnPricePanel = false will cause DrawText to draw in an indicator's own panel. DrawTextFixed is not the method you want to use.

        The only lines you will need to include in your trading system are

        Code:
        DrawOnPricePanel = false;
        and

        Code:
          refIndicator.DrawTextFixed(tag, text, textPosition, textColor, font, outlineColor, areaColor, areaOpacity);
        keeping the above in mind.

        Please let us know if there are any other ways we can help.
        Jessica P.NinjaTrader Customer Service

        Comment


          #5
          Thanks I will try that out

          Comment

          Latest Posts

          Collapse

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