Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Do not see the plot for indicator

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

    Do not see the plot for indicator


    Hello,

    I am writing a custom indicator for learning purposes. I am creating RSI indicator that will draw RSI of higher timeframe. When I put the indicator on chart, I do not see any plot being drawn. I have attached code with this email. What am I missing?

    #region Using declarations
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Gui;
    using NinjaTrader.Gui.Chart;
    using NinjaTrader.Gui.SuperDom;
    using NinjaTrader.Gui.Tools;
    using NinjaTrader.Data;
    using NinjaTrader.NinjaScript;
    using NinjaTrader.Core.FloatingPoint;
    using NinjaTrader.NinjaScript.DrawingTools;
    #endregion

    //This namespace holds Indicators in this folder and is required. Do not change it.
    namespace NinjaTrader.NinjaScript.Indicators.MyIndicators
    {
    public class RSIMulti : Indicator
    {
    private RSI _rsi;
    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"Enter the description for your new custom Indicator here.";
    Name = "RSIMulti";
    Calculate = Calculate.OnBarClose;
    IsOverlay = false;
    DisplayInDataBox = true;
    DrawOnPricePanel = true;
    DrawHorizontalGridLines = true;
    DrawVerticalGridLines = true;
    PaintPriceMarkers = true;
    ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
    //Disable this property if your indicator requires custom values that cumulate with each new market data event.
    //See Help Guide for additional information.
    IsSuspendedWhileInactive = true;
    RSIPeriod = 14;
    AddPlot(Brushes.DodgerBlue, "RSILine");

    AddLine(Brushes.DarkCyan, 48, NinjaTrader.Custom.Resource.NinjaScriptIndicatorLo wer);
    AddLine(Brushes.DarkCyan, 52, NinjaTrader.Custom.Resource.NinjaScriptIndicatorUp per);
    //AddLine(Brushes.DarkBlue, .52, "TryBuy");
    //AddLine(Brushes.DarkBlue, .48, "TrySell");
    //AddPlot(Brushes.Crimson, "RSILine");
    }
    else if (State == State.Configure)
    {
    AddDataSeries(Data.BarsPeriodType.Minute, 60);
    }
    else if (State == State.DataLoaded)
    {
    _rsi = RSI(BarsArray[1], RSIPeriod, 3);
    }
    }

    protected override void OnBarUpdate()
    {
    if (CurrentBars[0] < 12 || CurrentBars[1] < 20) // make sure there's at least one bar for primary series and at least 20 of the secondary series prior to processing
    return;

    if (BarsInProgress !=1)
    return;
    //Print(_rsi[0]);
    RSILine[0] = _rsi[0]; //_rsi[0];
    }

    #region Properties
    [NinjaScriptProperty]
    [Range(1, int.MaxValue)]
    [Display(Name="RSIPeriod", Order=1, GroupName="Parameters")]
    public int RSIPeriod
    { get; set; }

    [Browsable(false)]
    [XmlIgnore]
    public Series<double> RSILine
    {
    get { return Values[0]; }
    }
    #endregion

    }
    }

    #region NinjaScript generated code. Neither change nor remove.

    namespace NinjaTrader.NinjaScript.Indicators
    {
    public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
    {
    private MyIndicators.RSIMulti[] cacheRSIMulti;
    public MyIndicators.RSIMulti RSIMulti(int rSIPeriod)
    {
    return RSIMulti(Input, rSIPeriod);
    }

    public MyIndicators.RSIMulti RSIMulti(ISeries<double> input, int rSIPeriod)
    {
    if (cacheRSIMulti != null)
    for (int idx = 0; idx < cacheRSIMulti.Length; idx++)
    if (cacheRSIMulti[idx] != null && cacheRSIMulti[idx].RSIPeriod == rSIPeriod && cacheRSIMulti[idx].EqualsInput(input))
    return cacheRSIMulti[idx];
    return CacheIndicator<MyIndicators.RSIMulti>(new MyIndicators.RSIMulti(){ RSIPeriod = rSIPeriod }, input, ref cacheRSIMulti);
    }
    }
    }

    namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
    {
    public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
    {
    public Indicators.MyIndicators.RSIMulti RSIMulti(int rSIPeriod)
    {
    return indicator.RSIMulti(Input, rSIPeriod);
    }

    public Indicators.MyIndicators.RSIMulti RSIMulti(ISeries<double> input , int rSIPeriod)
    {
    return indicator.RSIMulti(input, rSIPeriod);
    }
    }
    }

    namespace NinjaTrader.NinjaScript.Strategies
    {
    public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
    {
    public Indicators.MyIndicators.RSIMulti RSIMulti(int rSIPeriod)
    {
    return indicator.RSIMulti(Input, rSIPeriod);
    }

    public Indicators.MyIndicators.RSIMulti RSIMulti(ISeries<double> input , int rSIPeriod)
    {
    return indicator.RSIMulti(input, rSIPeriod);
    }
    }
    }

    #endregion



    #2
    Hello milindpaward,

    Thanks for your post.

    I see in your script that you are checking if (BarsInProgress != 1) and calling return. This is checking if the series that the script is processing is the added series and if not, calls return. If you remove this condition from your code so that the primary series is processed, the plot will display on the chart.

    Please let us know if we may assist further.

    <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
      Thank you Brandon. One more Question. My RSI is not showing only up to active range not total range. Please see the attached screenshot. It shows window from 34 tp 52.42. How can I make it from 0 to 100?
      Attached Files

      Comment


        #4
        Hello milindpaward,

        Thanks for your note.

        You could override the OnCalculateMinMax() to set the minimum and maximum Y-Axis values. This method is used to determine the highest and lowest value that can be used for the chart scale.

        See this help guide documentation for more information about using OnCalculateMinMax(): https://ninjatrader.com/support/help...lateminmax.htm

        Let us know if we may assist further.
        <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


          #5
          Thank you very much.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          647 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          368 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          108 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          571 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          573 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X