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 NullPointStrategies, 03-13-2026, 05:17 AM
      0 responses
      99 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      154 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      82 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      55 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      72 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X