stuttgart
Experience: Advanced
Platform: NinjaTrader, TradeStation
Posts: 20 since Nov 2009
Thanks Given: 30
Thanks Received: 23
Hi,
I need your help in programming an indicator.
And I wish that I display by a color dot the High and Low Close vin. I have it already but it only shows me one by one color. But I want two colors.
So it should look something ..
https://img705.imageshack.us/img705/7481/bild4zh.png
this is the code of dot plot .
Thank you
Code
#region Using declarations using System ; using System . ComponentModel ; using System . Diagnostics ; using System . Drawing ; using System . Drawing . Drawing2D ; using System . Xml . Serialization ; using NinjaTrader . Cbi ; using NinjaTrader . Data ; using NinjaTrader . Gui . Chart ; #endregion // This namespace holds all indicators and is required. Do not change it. namespace NinjaTrader . Indicator { /// <summary> /// Plots Dots On OHLC /// </summary> [ Description ( "Plots Dots On OHLC" )] public class PlotDot : Indicator { #region Variables // Wizard generated variables private string tag = @ "Dots" ; // Default setting for Tag private bool autoscale = true ; // Default setting for Autoscale private int barsago = 0 ; // Default setting for Barsago private double y = 0 ; // Default setting for Y // User defined variables (add any user defined variables below) #endregion /// <summary> /// This method is used to configure the indicator and is called once before any bar data is loaded. /// </summary> protected override void Initialize () { Add (new Plot ( Color . FromKnownColor ( KnownColor . White ), PlotStyle . Dot , "Plot0" )); CalculateOnBarClose = true ; Overlay = true ; PriceTypeSupported = false ; } /// <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. Plot0 . Set ( Close [ 0 ]); } #region Properties [ Browsable ( false )] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove [ XmlIgnore ()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove public DataSeries Plot0 { get { return Values [ 0 ]; } } [ Description ( "Marked Dots" )] [ Category ( "Parameters" )] public string Tag { get { return tag ; } set { tag = value ; } } [ Description ( "" )] [ Category ( "Parameters" )] public bool Autoscale { get { return autoscale ; } set { autoscale = value ; } } [ Description ( "" )] [ Category ( "Parameters" )] public int Barsago { get { return barsago ; } set { barsago = Math . Max ( 0 , value ); } } [ Description ( "" )] [ Category ( "Parameters" )] public double Y { get { return y ; } set { y = Math . Max ( 0 , value ); } } #endregion } } #region NinjaScript generated code. Neither change nor remove. // This namespace holds all indicators and is required. Do not change it. namespace NinjaTrader . Indicator { public partial class Indicator : IndicatorBase { private PlotDot [] cachePlotDot = null ; private static PlotDot checkPlotDot = new PlotDot (); /// <summary> /// Plots Dots On OHLC /// </summary> /// <returns></returns> public PlotDot PlotDot ( bool autoscale , int barsago , string tag , double y ) { return PlotDot ( Input , autoscale , barsago , tag , y ); } /// <summary> /// Plots Dots On OHLC /// </summary> /// <returns></returns> public PlotDot PlotDot ( Data . IDataSeries input , bool autoscale , int barsago , string tag , double y ) { checkPlotDot . Autoscale = autoscale ; autoscale = checkPlotDot . Autoscale ; checkPlotDot . Barsago = barsago ; barsago = checkPlotDot . Barsago ; checkPlotDot . Tag = tag ; tag = checkPlotDot . Tag ; checkPlotDot . Y = y ; y = checkPlotDot . Y ; if ( cachePlotDot != null ) for ( int idx = 0 ; idx < cachePlotDot . Length ; idx ++) if ( cachePlotDot [ idx ]. Autoscale == autoscale && cachePlotDot [ idx ]. Barsago == barsago && cachePlotDot [ idx ]. Tag == tag && Math . Abs ( cachePlotDot [ idx ]. Y - y ) <= double . Epsilon && cachePlotDot [ idx ]. EqualsInput ( input )) return cachePlotDot [ idx ]; PlotDot indicator = new PlotDot (); indicator . BarsRequired = BarsRequired ; indicator . CalculateOnBarClose = CalculateOnBarClose ; indicator . Input = input ; indicator . Autoscale = autoscale ; indicator . Barsago = barsago ; indicator . Tag = tag ; indicator . Y = y ; indicator . SetUp (); PlotDot [] tmp = new PlotDot [ cachePlotDot == null ? 1 : cachePlotDot . Length + 1 ]; if ( cachePlotDot != null ) cachePlotDot . CopyTo ( tmp , 0 ); tmp [ tmp . Length - 1 ] = indicator ; cachePlotDot = tmp ; Indicators . Add ( indicator ); return indicator ; } } } // This namespace holds all market analyzer column definitions and is required. Do not change it. namespace NinjaTrader . MarketAnalyzer { public partial class Column : ColumnBase { /// <summary> /// Plots Dots On OHLC /// </summary> /// <returns></returns> [ Gui . Design . WizardCondition ( "Indicator" )] public Indicator . PlotDot PlotDot ( bool autoscale , int barsago , string tag , double y ) { return _indicator . PlotDot ( Input , autoscale , barsago , tag , y ); } /// <summary> /// Plots Dots On OHLC /// </summary> /// <returns></returns> public Indicator . PlotDot PlotDot ( Data . IDataSeries input , bool autoscale , int barsago , string tag , double y ) { return _indicator . PlotDot ( input , autoscale , barsago , tag , y ); } } } // This namespace holds all strategies and is required. Do not change it. namespace NinjaTrader . Strategy { public partial class Strategy : StrategyBase { /// <summary> /// Plots Dots On OHLC /// </summary> /// <returns></returns> [ Gui . Design . WizardCondition ( "Indicator" )] public Indicator . PlotDot PlotDot ( bool autoscale , int barsago , string tag , double y ) { return _indicator . PlotDot ( Input , autoscale , barsago , tag , y ); } /// <summary> /// Plots Dots On OHLC /// </summary> /// <returns></returns> public Indicator . PlotDot PlotDot ( Data . IDataSeries input , bool autoscale , int barsago , string tag , double y ) { if ( InInitialize && input == null ) throw new ArgumentException ( "You only can access an indicator with the default input/bar series from within the 'Initialize()' method" ); return _indicator . PlotDot ( input , autoscale , barsago , tag , y ); } } } #endregion