Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Tutorial Indicator-CustomROC

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

    Tutorial Indicator-CustomROC

    Hello All,

    This is regarding the tutorial indicator "CustomROC".

    I was able to code it just fine.

    However, for the life of me, I can not see the logic which (if ROC < 0 then plot RED else plot GREEN) allows for the plotting of red and green.

    Can someone please shine a light on this for me?

    Thanks in advance,
    Ron

    -----------------------------------------------------------------------------------------------------------------------
    protected override void Initialize()
    {
    Add(new Plot(Color.FromKnownColor(KnownColor.Green), PlotStyle.Line, "AboveZero"));
    Add(new Plot(Color.FromKnownColor(KnownColor.OrangeRed), PlotStyle.Line, "BelowZero"));
    Add(new Line(Color.FromKnownColor(KnownColor.Black), 0, "ZeroLine"));
    CalculateOnBarClose = true;
    Overlay = false;
    Plots[0].Min = 0;
    Plots[1].Max = 0;
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    // Use this method for calculating your indicator values. Assign a value to each
    // plot below by replacing 'Close[0]' with your own formula.
    if (CurrentBar < Period) return;

    AboveZero.Set(ROC(Period)[0]);
    BelowZero.Set(ROC(Period)[0]);

    #2
    Hi Ron,

    This sample uses multiple plots to set colors. It's the .Min and .Max that set the upper and lower bounds for the two plots, so that only one plot is visible at a time.

    This color changing technique is actually improved in version 7, and you can assign plot colors directly with PlotColors. This sample can help with the newer technique for multi colored plots.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_RyanM View Post
      Hi Ron,

      This sample uses multiple plots to set colors. It's the .Min and .Max that set the upper and lower bounds for the two plots, so that only one plot is visible at a time.

      This color changing technique is actually improved in version 7, and you can assign plot colors directly with PlotColors. This sample can help with the newer technique for multi colored plots.
      http://www.ninjatrader.com/support/f...ead.php?t=3227
      Hi Ryan,

      Thanks. I viewed the link you provided and I see clearly how it works using the rising and falling methods.

      However, I still do not see how the tutorial code evaluates less then or greater than 0 to plot.

      Regards,
      Ron

      Comment


        #4
        There's two plots. One is green and the other orange red.
        Code:
        Add(new Plot(Color.FromKnownColor(KnownColor.Green), PlotStyle.Line, "AboveZero"));
        Add(new Plot(Color.FromKnownColor(KnownColor.OrangeRed), PlotStyle.Line, "BelowZero"));
        First plot's lowest value is 0.
        Code:
        Plots[0].Min = 0;
        2nd plot's highest value is 0.
        Code:
        Plots[1].Max = 0;
        Both plots are set to the same value.
        Code:
        AboveZero.Set(ROC(Period)[0]);
        BelowZero.Set(ROC(Period)[0]);
        Ryan M.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        579 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        334 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
        551 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X