Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicator has been perfect but now Issues

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

    Indicator has been perfect but now Issues

    Hello NT Community,

    I have a simple indicator that tells me if the volume of the current is greater than the volume of the two previous candle added together

    It has been working perfect but today it has stopped, the problem is the Input series in the indicator properties it is showing as "Close".
    I edit Input and make it NQ 12-21(5 Minute) but no deal it reverts straight back to "Close".
    The only chart that it works on is the 60 minute chart because the Input Series stays set to "NQ 12-21(60 Minute)"

    Any Ideas would be appreciated.
    Last edited by Christopher Leggit; 11-02-2021, 02:54 AM.

    #2
    This is the code

    #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 ClimacticCandles : Indicator
    {
    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"Enter the description for your new custom Indicator here.";
    Name = "ClimacticCandles";
    Calculate = Calculate.OnBarClose;
    IsOverlay = true;
    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;
    }
    else if (State == State.Configure)
    {
    }
    }

    protected override void OnBarUpdate()
    {
    if (BarsInProgress != 0)
    return;

    if (CurrentBars[0] < 1)
    return;

    // Set 1 Long
    if ((Close[0] > Open[0]) // Green Candle
    && (Volume[0] > (Volume[1] + Volume[2]))) // Volume of current has more volume than [1] & [2] combined
    {
    BarBrush = Brushes.ForestGreen;
    }

    // Set 2 Short
    if ((Open[0] > Close[0]) // Red Candle
    && (Volume[0] > (Volume[1] + Volume[2]))) // Volume of current has more volume than [1] & [2] combined
    {

    BarBrush = Brushes.DarkOrange;
    }
    }
    }
    }

    Comment


      #3
      OK I've narrowed down the issue, It works when I have less days loaded on the chart but when I load 28days or more the Indicator says no

      Comment


        #4
        Hello Christopher Leggit,

        I would suggest to check the control center log tab to see if you are getting any errors when running it with more data. The input series would be determined by the series which you had applied the indicator to.

        Please let me know if I may be of additional assistance.

        Comment


          #5
          Hi Jesse,

          There is an error I had not looked I'm still learning these things,

          Indicator ": Error on calling 'OnBarUpdate method on bar 1: You are accessing an index with a value that is invalid since it is out-of-range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.

          I don't understand this
          "value of 5 when there are only 4 bars on the chart"

          My onbarupdate code

          {
          if (BarsInProgress != 0)
          return;

          if (CurrentBars[0] < 1)
          return;

          // Set 1 Long
          if ((Close[0] > Open[0]) // Green Candle
          && (Volume[0] > (Volume[1] + Volume[2]))) // Volume of current has more volume than [1] & [2] combined
          {
          BarBrush = Brushes.ForestGreen;
          }

          // Set 2 Short
          if ((Open[0] > Close[0]) // Red Candle
          && (Volume[0] > (Volume[1] + Volume[2]))) // Volume of current has more volume than [1] & [2] combined
          {
          BarBrush = Brushes.DarkOrange;
          }
          }


          Jesse I'm also editing a moving average Indicator, what I want to do is raise them on the chart by 10 ticks

          these are the plots
          AddPlot(new Stroke(Brushes.ForestGreen), PlotStyle.Line, "WmaHigh");
          AddPlot(new Stroke(Brushes.MediumBlue), PlotStyle.Line, "WmaClose");
          AddPlot(new Stroke(Brushes.Red), PlotStyle.Line, "WmaLow");

          I have tried adding to the plots

          High[0] + (10 * TickSize);
          Last edited by Christopher Leggit; 11-03-2021, 12:46 AM.

          Comment


            #6
            Hello Christopher Leggit,

            The index out of range is because you are referencing 2 bars ago before the script has processed 2 bars.

            Please see below:



            As for raising the plot 10 ticks, you are correct that the plot could be assigned a value + (10 * TickSize)

            I suggest reviewing our indicator tutorials and AddPlot documentation to better see how indicator are assigned their plot values, so you can see how you can make your own indicators and plots with their own values.

            Indicator Tutorials - https://ninjatrader.com/support/help...indicators.htm

            AddPlot documentation - https://ninjatrader.com/support/help...t8/addplot.htm

            Comment


              #7
              Also over here thank you Jim

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              566 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              330 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
              547 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              548 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X