Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Change plot pen color

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

    Change plot pen color

    Im trying to get the pen (plot) line color to change depending if above or below 0.. The line plot itself does plot ok above and below 0 but no color change if line below 0.
    // change plot color
    if ((profit + Position.GetProfitLoss(Close[0], PerformanceUnit.Currency)) >= 0)
    StrategyPlot(0).Plots[0].Pen.Color = Color.Blue;
    else
    StrategyPlot(0).Plots[0].Pen.Color = Color.Red;


    // historical PNL
    StrategyPlot(0).Name ="PNL Today\n";
    StrategyPlot(0).Value.Set(profit + Position.GetProfitLoss(Close[0], PerformanceUnit.Currency));

    #2
    Please try via the PlotColors method in NT7 -

    if ((profit + Position.GetProfitLoss(Close[0], PerformanceUnit.Currency)) >= 0)
    StrategyPlot(0).Plots[0].PlotColors[0][0] = Color.Blue;
    else
    StrategyPlot(0).Plots[0].PlotColors[0][0] = Color.Red;

    Here's the link to the helpguide resources on this topic - http://www.ninjatrader.com/support/h...plotcolors.htm
    Last edited by NinjaTrader_Bertrand; 04-20-2012, 03:30 AM.

    Comment


      #3
      ok now

      works good now,, txs

      Comment


        #4
        This does not work for me

        I had this same issue, found this thread, and it does not work.

        In a strategy, using StrategyPlot. Using Bertrand's code above, I wrote:

        StrategyPlot(0).Plots[0].PlotColors[0][0] = Color.Green;

        and get an error upon compilation:
        'NinjaTrader.Gui.Chart.Plot' does not contain a definition for 'PlotColors'...

        Indeed, when I type the code above, I do not see the Intellisense option for PlotColors. Am I missing some sort of reference?

        Just to clarify, in the strategy initialization, I am

        Add(StrategyPlot(0));
        StrategyPlot(0).PanelUI = 1;
        StrategyPlot(0).Plots[0].Pen.Width = 2;
        StrategyPlot(0).Plots[0].Pen.Color = Color.Blue;

        and then on elsewhere in the strategy I am trying to change colors via PlotColors.

        Insight? Thanks!

        Comment


          #5
          StrategyPlot(0).PlotColors[0][0] = Color.Blue;
          Ended up working for me.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          558 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          324 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
          546 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