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 Hwop38, 05-04-2026, 07:02 PM
          0 responses
          177 views
          0 likes
          Last Post Hwop38
          by Hwop38
           
          Started by CaptainJack, 04-24-2026, 11:07 PM
          0 responses
          332 views
          0 likes
          Last Post CaptainJack  
          Started by Mindset, 04-21-2026, 06:46 AM
          0 responses
          254 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by M4ndoo, 04-20-2026, 05:21 PM
          0 responses
          356 views
          0 likes
          Last Post M4ndoo
          by M4ndoo
           
          Started by M4ndoo, 04-19-2026, 05:54 PM
          0 responses
          184 views
          0 likes
          Last Post M4ndoo
          by M4ndoo
           
          Working...
          X