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 CaptainJack, 05-29-2026, 05:09 AM
          0 responses
          173 views
          0 likes
          Last Post CaptainJack  
          Started by CaptainJack, 05-29-2026, 12:02 AM
          0 responses
          91 views
          0 likes
          Last Post CaptainJack  
          Started by charlesugo_1, 05-26-2026, 05:03 PM
          0 responses
          130 views
          0 likes
          Last Post charlesugo_1  
          Started by DannyP96, 05-18-2026, 02:38 PM
          1 response
          209 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 05-11-2026, 05:56 AM
          0 responses
          186 views
          0 likes
          Last Post CarlTrading  
          Working...
          X