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>
- /// Enter the description of your new custom indicator here
- /// </summary>
- [Description("This is the Smoothed RSI Inverse Fisher Transform indicator as described in the October 2010 issue of Stocks & Commodities.")]
- public class SmoothedRsiInverseFisherTransform : Indicator
- {
- #region Variables
- private int rSI_Period = 4;
- private int eMA_Period = 4;
- private double rainbow_value, difference, zero_lag_ema, inv_fish_value = 0;
- private DataSeries rainbow, ema1, ema2, x;
- #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()
- {
- rainbow = new DataSeries(this);
- ema1 = new DataSeries(this);
- ema2 = new DataSeries(this);
- x = new DataSeries(this);
- Add(new Plot(Color.RoyalBlue, PlotStyle.Line, "InvFish"));
- Add(new Line(Color.DarkGray, 80, "Eighty"));
- Add(new Line(Color.DarkGray, 20, "Twenty"));
- Overlay = false;
- }
- /// <summary>
- /// Called on each bar update event (incoming tick)
- /// </summary>
- protected override void OnBarUpdate()
- {
- rainbow_value =
- (5 * WMA(2)[0] +
- 4 * WMA(WMA(2), 2)[0] +
- 3 * WMA(WMA(WMA(2), 2), 2)[0] +
- 2 * WMA(WMA(WMA(WMA(2), 2), 2), 2)[0] +
- WMA(WMA(WMA(WMA(WMA(2), 2), 2), 2), 2)[0] +
- WMA(WMA(WMA(WMA(WMA(WMA(2), 2), 2), 2), 2), 2)[0] +
- WMA(WMA(WMA(WMA(WMA(WMA(WMA(2), 2), 2), 2), 2), 2), 2)[0] +
- WMA(WMA(WMA(WMA(WMA(WMA(WMA(WMA(2), 2), 2), 2), 2), 2), 2), 2)[0] +
- WMA(WMA(WMA(WMA(WMA(WMA(WMA(WMA(WMA(2), 2), 2), 2), 2), 2), 2), 2), 2)[0] +
- WMA(WMA(WMA(WMA(WMA(WMA(WMA(WMA(WMA(WMA(2), 2), 2), 2), 2), 2), 2), 2), 2), 2)[0]) / 20;
- rainbow.Set(rainbow_value);
- x.Set(0.1 * (RSI(rainbow, rSI_Period, 1)[0] - 50));
- ema1.Set(EMA(x, eMA_Period)[0]);
- ema2.Set(EMA(ema1, eMA_Period)[0]);
- difference = ema1[0] - ema2[0];
- zero_lag_ema = ema1[0] + difference;
- inv_fish_value = ((Math.Exp(2 * zero_lag_ema) - 1) / (Math.Exp(2 * zero_lag_ema) + 1) + 1) * 50;
- InvFish.Set(inv_fish_value);
- }
- #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 InvFish
- {
- get { return Values[0]; }
- }
- [Description("")]
- [Category("Parameters")]
- public int RSI_Period
- {
- get { return rSI_Period; }
- set { rSI_Period = Math.Max(1, value); }
- }
- [Description("")]
- [Category("Parameters")]
- public int EMA_Period
- {
- get { return eMA_Period; }
- set { eMA_Period = 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 SmoothedRsiInverseFisherTransform[] cacheSmoothedRsiInverseFisherTransform = null;
- private static SmoothedRsiInverseFisherTransform checkSmoothedRsiInverseFisherTransform = new SmoothedRsiInverseFisherTransform();
- /// <summary>
- /// This is the Smoothed RSI Inverse Fisher Transform indicator as described in the October 2010 issue of Stocks & Commodities.
- /// </summary>
- /// <returns></returns>
- public SmoothedRsiInverseFisherTransform SmoothedRsiInverseFisherTransform(int eMA_Period, int rSI_Period)
- {
- return SmoothedRsiInverseFisherTransform(Input, eMA_Period, rSI_Period);
- }
- /// <summary>
- /// This is the Smoothed RSI Inverse Fisher Transform indicator as described in the October 2010 issue of Stocks & Commodities.
- /// </summary>
- /// <returns></returns>
- public SmoothedRsiInverseFisherTransform SmoothedRsiInverseFisherTransform(Data.IDataSeries input, int eMA_Period, int rSI_Period)
- {
- checkSmoothedRsiInverseFisherTransform.EMA_Period = eMA_Period;
- eMA_Period = checkSmoothedRsiInverseFisherTransform.EMA_Period;
- checkSmoothedRsiInverseFisherTransform.RSI_Period = rSI_Period;
- rSI_Period = checkSmoothedRsiInverseFisherTransform.RSI_Period;
- if (cacheSmoothedRsiInverseFisherTransform != null)
- for (int idx = 0; idx < cacheSmoothedRsiInverseFisherTransform.Length; idx++)
- if (cacheSmoothedRsiInverseFisherTransform[idx].EMA_Period == eMA_Period && cacheSmoothedRsiInverseFisherTransform[idx].RSI_Period == rSI_Period && cacheSmoothedRsiInverseFisherTransform[idx].EqualsInput(input))
- return cacheSmoothedRsiInverseFisherTransform[idx];
- SmoothedRsiInverseFisherTransform indicator = new SmoothedRsiInverseFisherTransform();
- indicator.BarsRequired = BarsRequired;
- indicator.CalculateOnBarClose = CalculateOnBarClose;
- indicator.Input = input;
- indicator.EMA_Period = eMA_Period;
- indicator.RSI_Period = rSI_Period;
- indicator.SetUp();
- SmoothedRsiInverseFisherTransform[] tmp = new SmoothedRsiInverseFisherTransform[cacheSmoothedRsiInverseFisherTransform == null ? 1 : cacheSmoothedRsiInverseFisherTransform.Length + 1];
- if (cacheSmoothedRsiInverseFisherTransform != null)
- cacheSmoothedRsiInverseFisherTransform.CopyTo(tmp, 0);
- tmp[tmp.Length - 1] = indicator;
- cacheSmoothedRsiInverseFisherTransform = 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>
- /// This is the Smoothed RSI Inverse Fisher Transform indicator as described in the October 2010 issue of Stocks & Commodities.
- /// </summary>
- /// <returns></returns>
- [Gui.Design.WizardCondition("Indicator")]
- public Indicator.SmoothedRsiInverseFisherTransform SmoothedRsiInverseFisherTransform(int eMA_Period, int rSI_Period)
- {
- return _indicator.SmoothedRsiInverseFisherTransform(Input, eMA_Period, rSI_Period);
- }
- /// <summary>
- /// This is the Smoothed RSI Inverse Fisher Transform indicator as described in the October 2010 issue of Stocks & Commodities.
- /// </summary>
- /// <returns></returns>
- public Indicator.SmoothedRsiInverseFisherTransform SmoothedRsiInverseFisherTransform(Data.IDataSeries input, int eMA_Period, int rSI_Period)
- {
- return _indicator.SmoothedRsiInverseFisherTransform(input, eMA_Period, rSI_Period);
- }
- }
- }
- // This namespace holds all strategies and is required. Do not change it.
- namespace NinjaTrader.Strategy
- {
- public partial class Strategy : StrategyBase
- {
- /// <summary>
- /// This is the Smoothed RSI Inverse Fisher Transform indicator as described in the October 2010 issue of Stocks & Commodities.
- /// </summary>
- /// <returns></returns>
- [Gui.Design.WizardCondition("Indicator")]
- public Indicator.SmoothedRsiInverseFisherTransform SmoothedRsiInverseFisherTransform(int eMA_Period, int rSI_Period)
- {
- return _indicator.SmoothedRsiInverseFisherTransform(Input, eMA_Period, rSI_Period);
- }
- /// <summary>
- /// This is the Smoothed RSI Inverse Fisher Transform indicator as described in the October 2010 issue of Stocks & Commodities.
- /// </summary>
- /// <returns></returns>
- public Indicator.SmoothedRsiInverseFisherTransform SmoothedRsiInverseFisherTransform(Data.IDataSeries input, int eMA_Period, int rSI_Period)
- {
- 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.SmoothedRsiInverseFisherTransform(input, eMA_Period, rSI_Period);
- }
- }
- }
- #endregion
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement