Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Sorry to ask! IF (x - y > o ) plot a Dot color Red

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

    Sorry to ask! IF (x - y > o ) plot a Dot color Red

    Hello,
    I have never asked for help in a NinjaTrader forum before, I hope I can provide enough info to get a helpful answer with minimal effort from the answer-er. I have a basic understanding of C#. I wrote software in SAS; building expert systems in it for a career. I have learned the basics of C# by working though various books. I've built separate indicators which work with the Market Analyzer flagging conditions of interest to me and they work well. I've worked through the examples provided by NinjaTrader, however I am at an impasse, and somewhat embarrassed, clearly missing something(s).
    So in real life all I want to do is build an indicator which will display colored dots in its own panel based on a complex series of tests. I can do that myself if someone could provide some insights or perhaps solving this simpler version.
    So I built the first example as it seems at first glance to be very close. I worked through the other examples as well.

    However I don't have any need for a scale, I'm wanting to plot dots varying the color depending on the conditions tested for. I could find no example of such.
    To start I tried working with setting Plot0.Set(1) and changing the line color so the line, plotted much like volume is displayed would change color but the line did not change color, and was one continuous line unlike volume. I tried other things but have had no luck advancing. Here is the code frag.
    I'm not passing in Period, just using 3 to start with a trivial example.
    Thanks.

    protected override void OnBarUpdate()
    {
    // Are there enough bars
    if (CurrentBar < 3) return;

    if (SMA(3)[0] > SMA(3)[1]) Plots[0].Pen = new Pen(Color.Green);
    else if (SMA(3)[0] < SMA(3)[1]) Plots[0].Pen = new Pen(Color.Red);
    else Plots[0].Pen = new Pen(Color.Yellow);

    Plot0.Set(1);
    }

    #2
    Hello Redeagle9,

    Thank you for your note.

    Try using the PlotColors[0][0] to change the color at the specific Plot and Bar that it was called on.
    Code:
    if (SMA(3)[0] > SMA(3)[1]) PlotColors[0][0] = Color.Green;
    else if (SMA(3)[0] < SMA(3)[1]) PlotColors[0][0] = Color.Red;
    else PlotColors[0][0] = Color.Yellow;
    http://www.ninjatrader.com/support/h...plotcolors.htm
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Wonderful, thanks so much!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      580 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      335 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      101 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      554 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      552 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X