Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #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>
- /// ATR on chart
- /// </summary>
- [Description("ATR on chart")]
- public class ATRonchart : Indicator
- {
- #region Variables
- // Wizard generated variables
- private int aTREMA = 10; // Default setting for ATREMA
- // 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.Orange), PlotStyle.Dot, "ATRonchart"));
- CalculateOnBarClose = true;
- PriceTypeSupported = true;
- }
- /// <summary>
- /// Called on each bar update event (incoming tick)
- /// </summary>
- protected override void OnBarUpdate()
- {
- Plot0.Set(Close[0]+ATR(10)[0]); //This is causing me some trouble for some fucking reason.
- }
- #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 ATRDot
- {
- get { return Values[0]; }
- }
- [Description("ATR Exponential MA")]
- [GridCategory("Parameters")]
- public int ATREMA
- {
- get { return aTREMA; }
- set { aTREMA = Math.Max(1, 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 ATRonchart[] cacheATRonchart = null;
- private static ATRonchart checkATRonchart = new ATRonchart();
- /// <summary>
- /// ATR on chart
- /// </summary>
- /// <returns></returns>
- public ATRonchart ATRonchart(int aTREMA)
- {
- return ATRonchart(Input, aTREMA);
- }
- /// <summary>
- /// ATR on chart
- /// </summary>
- /// <returns></returns>
- public ATRonchart ATRonchart(Data.IDataSeries input, int aTREMA)
- {
- if (cacheATRonchart != null)
- for (int idx = 0; idx < cacheATRonchart.Length; idx++)
- if (cacheATRonchart[idx].ATREMA == aTREMA && cacheATRonchart[idx].EqualsInput(input))
- return cacheATRonchart[idx];
- lock (checkATRonchart)
- {
- checkATRonchart.ATREMA = aTREMA;
- aTREMA = checkATRonchart.ATREMA;
- if (cacheATRonchart != null)
- for (int idx = 0; idx < cacheATRonchart.Length; idx++)
- if (cacheATRonchart[idx].ATREMA == aTREMA && cacheATRonchart[idx].EqualsInput(input))
- return cacheATRonchart[idx];
- ATRonchart indicator = new ATRonchart();
- indicator.BarsRequired = BarsRequired;
- indicator.CalculateOnBarClose = CalculateOnBarClose;
- #if NT7
- indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
- indicator.MaximumBarsLookBack = MaximumBarsLookBack;
- #endif
- indicator.Input = input;
- indicator.ATREMA = aTREMA;
- Indicators.Add(indicator);
- indicator.SetUp();
- ATRonchart[] tmp = new ATRonchart[cacheATRonchart == null ? 1 : cacheATRonchart.Length + 1];
- if (cacheATRonchart != null)
- cacheATRonchart.CopyTo(tmp, 0);
- tmp[tmp.Length - 1] = indicator;
- cacheATRonchart = tmp;
- 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>
- /// ATR on chart
- /// </summary>
- /// <returns></returns>
- [Gui.Design.WizardCondition("Indicator")]
- public Indicator.ATRonchart ATRonchart(int aTREMA)
- {
- return _indicator.ATRonchart(Input, aTREMA);
- }
- /// <summary>
- /// ATR on chart
- /// </summary>
- /// <returns></returns>
- public Indicator.ATRonchart ATRonchart(Data.IDataSeries input, int aTREMA)
- {
- return _indicator.ATRonchart(input, aTREMA);
- }
- }
- }
- // This namespace holds all strategies and is required. Do not change it.
- namespace NinjaTrader.Strategy
- {
- public partial class Strategy : StrategyBase
- {
- /// <summary>
- /// ATR on chart
- /// </summary>
- /// <returns></returns>
- [Gui.Design.WizardCondition("Indicator")]
- public Indicator.ATRonchart ATRonchart(int aTREMA)
- {
- return _indicator.ATRonchart(Input, aTREMA);
- }
- /// <summary>
- /// ATR on chart
- /// </summary>
- /// <returns></returns>
- public Indicator.ATRonchart ATRonchart(Data.IDataSeries input, int aTREMA)
- {
- 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.ATRonchart(input, aTREMA);
- }
- }
- }
- #endregion
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement