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 sjsj2732, Yesterday, 04:31 AM
          0 responses
          28 views
          0 likes
          Last Post sjsj2732  
          Started by NullPointStrategies, 03-13-2026, 05:17 AM
          0 responses
          284 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          281 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          132 views
          1 like
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          90 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Working...
          X