Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 judysamnt7, 03-13-2023, 09:11 AM
      4 responses
      55 views
      0 likes
      Last Post DynamicTest  
      Started by ScottWalsh, Today, 06:52 PM
      4 responses
      35 views
      0 likes
      Last Post ScottWalsh  
      Started by olisav57, Today, 07:39 PM
      0 responses
      7 views
      0 likes
      Last Post olisav57  
      Started by trilliantrader, Today, 03:01 PM
      2 responses
      19 views
      0 likes
      Last Post helpwanted  
      Started by cre8able, Today, 07:24 PM
      0 responses
      7 views
      0 likes
      Last Post cre8able  
      Working...
      X