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

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 rtwave, 04-12-2024, 09:30 AM
          5 responses
          37 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by funk10101, Today, 12:02 AM
          1 response
          11 views
          0 likes
          Last Post NinjaTrader_LuisH  
          Started by GLFX005, Today, 03:23 AM
          1 response
          6 views
          0 likes
          Last Post NinjaTrader_Erick  
          Started by nandhumca, Yesterday, 03:41 PM
          1 response
          13 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by The_Sec, Yesterday, 03:37 PM
          1 response
          11 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Working...
          X