Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Changing Line color

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

    Changing Line color

    I have added an SMA to my chart and I would like to change the color of it based on the direction of the movement.

    I have added it using:
    TrendLine = SMA(33);
    TrendLine.Plots[0].Brush = Brushes.Red;
    AddChartIndicator(TrendLine);

    When I set it as above it is always Red.

    If I try to set is OnBarUpdate() as below it does not work.
    TrendLine.Plots[0].Brush = Brushes.Green;

    What is the Proper way to set the color during OnBarUpdate()?
    I've seen this done, but all my testing and searching hasn't helped.

    Thanks.

    #2
    Hello ATMtrader0001,

    Thanks for your post.

    PlotBrushes could be used to determine the color of a plot when certain conditions become true.

    See the attached example script demonstrating how to change the color of a plot in a strategy when certain conditions become true. In the example script, we add the SMA indicator on the chart using AddChartIndicator(). Then, when we have an up bar, we use PlotBrushes to change the plot color to blue. When we have a down bar, we use PlotBrushes to change the plot color to pink.

    Also, see this help guide page for more information: https://ninjatrader.com/support/help...lotbrushes.htm

    Let us know if we may assist further.
    Attached Files
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      Thanks. That was it.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      90 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      137 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      68 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      120 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      69 views
      0 likes
      Last Post PaulMohn  
      Working...
      X