Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

StrategyPlot() color change

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

    StrategyPlot() color change

    I'm trying to change a StrategyPlot color dynamically in OnBarUpdate(), eg:

    OnBarUpdate()
    {
    if (somecondition)
    StrategyPlot(0).Plots[0].Pen.Color = Color.Red;
    else
    StragegyPlot(0).Plots[0].Pen.Color = Color.Green;
    }

    This doesn't work. Someone else recently asked this question and he was given a link to sample code to change plot colors in an indicator, not a strategy.

    Thxs,

    Paul
    '

    #2
    Hello,

    First off are you using NinjaTrader 7 or NinjaTrader 6.5 as you need to use a different method depending on what version you are on.

    I look forward to assisting you further.
    BrettNinjaTrader Product Management

    Comment


      #3
      Sorry Brett - 7.0.0.23. I thought that StrategyPlot() was only available in 7.0.

      Paul

      Comment


        #4
        Hello,

        In 7 you will want to use the following sample to do this:



        Please see post number 1.

        Let me know if I can be of further assistance.
        BrettNinjaTrader Product Management

        Comment


          #5
          That sample shows how to change a plot color in an indicator. In a strategy "PlotColors" does not exist.

          Comment


            #6
            Hello,

            Ah understood.

            SMA(20).PlotColors[0][0] = Color.Black;

            Tested this on my side and this compiles for me.
            BrettNinjaTrader Product Management

            Comment


              #7
              Sure but that doesn't solve the problem of using StrategyPlot() in my strategy to plot my own data and being able to change the plot color in OnBarUpdate().

              Comment


                #8
                Not sure I follow. If you want it to run it on StrategyPlot, you can use it on StrategyPlot instead of SMA.

                StrategyPlot(0).PlotColors[0][0] = Color.Black;
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  Thanks Josh,

                  duh, me caveman!

                  Paul

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                  0 responses
                  647 views
                  0 likes
                  Last Post Geovanny Suaza  
                  Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                  0 responses
                  368 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by Mindset, 02-09-2026, 11:44 AM
                  0 responses
                  108 views
                  0 likes
                  Last Post Mindset
                  by Mindset
                   
                  Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                  0 responses
                  571 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by RFrosty, 01-28-2026, 06:49 PM
                  0 responses
                  573 views
                  1 like
                  Last Post RFrosty
                  by RFrosty
                   
                  Working...
                  X