Add indicator for displaying a customizable label on the chart
This commit is contained in:
parent
7a8df23acd
commit
e998b34d0d
110
indicators/ChartLabel.cs
Normal file
110
indicators/ChartLabel.cs
Normal file
@ -0,0 +1,110 @@
|
||||
#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
|
||||
{
|
||||
public class ChartLabel : Indicator
|
||||
{
|
||||
protected override void OnStateChange()
|
||||
{
|
||||
if (State == State.SetDefaults)
|
||||
{
|
||||
Description = @"Adds a customizable label to the chart";
|
||||
Name = "Chart Label";
|
||||
Calculate = Calculate.OnBarClose;
|
||||
IsOverlay = true;
|
||||
IsSuspendedWhileInactive = true;
|
||||
Label = "";
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnBarUpdate() { }
|
||||
|
||||
public override string DisplayName
|
||||
{
|
||||
get { return Label; }
|
||||
}
|
||||
|
||||
[NinjaScriptProperty]
|
||||
[Display(Name = "Label", GroupName = "Chart Label", Order = 1)]
|
||||
public string Label { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
#region NinjaScript generated code. Neither change nor remove.
|
||||
|
||||
namespace NinjaTrader.NinjaScript.Indicators
|
||||
{
|
||||
public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
|
||||
{
|
||||
private ChartLabel[] cacheChartLabel;
|
||||
public ChartLabel ChartLabel(string label)
|
||||
{
|
||||
return ChartLabel(Input, label);
|
||||
}
|
||||
|
||||
public ChartLabel ChartLabel(ISeries<double> input, string label)
|
||||
{
|
||||
if (cacheChartLabel != null)
|
||||
for (int idx = 0; idx < cacheChartLabel.Length; idx++)
|
||||
if (cacheChartLabel[idx] != null && cacheChartLabel[idx].Label == label && cacheChartLabel[idx].EqualsInput(input))
|
||||
return cacheChartLabel[idx];
|
||||
return CacheIndicator<ChartLabel>(new ChartLabel(){ Label = label }, input, ref cacheChartLabel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
|
||||
{
|
||||
public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
|
||||
{
|
||||
public Indicators.ChartLabel ChartLabel(string label)
|
||||
{
|
||||
return indicator.ChartLabel(Input, label);
|
||||
}
|
||||
|
||||
public Indicators.ChartLabel ChartLabel(ISeries<double> input , string label)
|
||||
{
|
||||
return indicator.ChartLabel(input, label);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace NinjaTrader.NinjaScript.Strategies
|
||||
{
|
||||
public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
|
||||
{
|
||||
public Indicators.ChartLabel ChartLabel(string label)
|
||||
{
|
||||
return indicator.ChartLabel(Input, label);
|
||||
}
|
||||
|
||||
public Indicators.ChartLabel ChartLabel(ISeries<double> input , string label)
|
||||
{
|
||||
return indicator.ChartLabel(input, label);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
Loading…
Reference in New Issue
Block a user