Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicator not showing when attempting to add to a chart

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

    Indicator not showing when attempting to add to a chart

    My successfully compiled custom indicator does not show up in the list when attempting to add it to a chart.
    There are no compiler errors from the editor.
    The file name of the indicator is the same as that inside the code.
    I am new to this so maybe it's obvious - any thoughts?

    ----------------------------------------
    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;
    using NinjaTrader.NinjaScript.Indicators;
    #endregion

    public class CustomVolumeATRIndicator : NinjaTrader.NinjaScript.Indicators.Indicator
    {
    private NinjaTrader.NinjaScript.Indicators.ATR atr;

    [NinjaScriptProperty]
    [Range(1, int.MaxValue)]
    [Display(Name="ATR Period", Description="Number of bars for ATR calculation", Order=1, GroupName="Parameters")]
    public int AtrPeriod { get; set; }

    [NinjaScriptProperty]
    [Range(1, int.MaxValue)]
    [Display(Name="Font Size", Description="Size of the displayed text", Order=2, GroupName="Parameters")]
    public int FontSize { get; set; }

    [NinjaScriptProperty]
    [XmlIgnore]
    [Display(Name="Text Color", Description="Color of the displayed text", Order=3, GroupName="Parameters")]
    public Brush TextColor { get; set; }

    [Browsable(false)]
    public string TextColorSerializable
    {
    get { return Serialize.BrushToString(TextColor); }
    set { TextColor = Serialize.StringToBrush(value); }
    }

    [NinjaScriptProperty]
    [Range(1, int.MaxValue)]
    [Display(Name="Volume Divisor", Description="Value to divide volume by", Order=4, GroupName="Parameters")]
    public int VolumeDivisor { get; set; }

    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = "Displays (Volume / VolumeDivisor) / ATR vertically above each candle";
    Name = "CustomVolumeATRIndicator";
    Calculate = Calculate.OnBarClose;
    IsOverlay = true;
    DisplayInDataBox = true;
    DrawOnPricePanel = true;
    DrawHorizontalGridLines = true;
    DrawVerticalGridLines = true;
    PaintPriceMarkers = true;
    ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;

    // Set default values for the new properties
    AtrPeriod = 1;
    FontSize = 10;
    TextColor = Brushes.White;
    VolumeDivisor = 1000;
    }
    else if (State == State.Configure)
    {
    atr = ATR(AtrPeriod);
    }
    }

    protected override void OnBarUpdate()
    {
    if (CurrentBar < AtrPeriod)
    return;

    double volumeComponent = Volume[0] / (double)VolumeDivisor;
    double atrValue = atr[0];

    if (atrValue > 0)
    {
    double result = volumeComponent / atrValue;

    Draw.Text(this, "VolumeATR" + CurrentBar, true, result.ToString("F2"), 0, High[0] + TickSize, 90, TextColor,
    new SimpleFont("Arial", FontSize), TextAlignment.Center, Brushes.Transparent, Brushes.Transparent, 1);
    }
    }
    }

    #2
    Hello ziponline,

    Thank you for your post.

    If your indicators are not showing up in the list of indicators then that suggests there is an issue with the indicators themselves. Specifically, there is likely an error in OnStateChange().

    Keep in mind that while it may compile successfully, the compiler cannot check "run time" logic errors, which can only occur when you run (or load) the strategy.

    A good first step here is to check the "Log" tab of the Ninjatrader Control center and look for any errors related to the strategies as if there is a run time error is would show in the log tab.

    If there are no log errors, check (in the Ninjascript editor open each strategy) to see if the indicators have the same name (IE you made a copy of the indicator and made your changes but unintentionally left the name the same as an existing one).

    In general, you want the filename of the indicator (this is what Ninjascript editor uses to open the script) to be the same as the public class name and most importantly that inside OnStateChange and within State.SetDefaults, the Name = field (This is what the drop-down or strategy selector uses) shows the same name as the public class name.​

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    57 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    37 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    18 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    20 views
    0 likes
    Last Post TheRealMorford  
    Started by Mindset, 02-28-2026, 06:16 AM
    0 responses
    49 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Working...
    X