#region Using declarations using NinjaTrader.NinjaScript.Indicators; using System.ComponentModel.DataAnnotations; #endregion namespace NinjaTrader.NinjaScript.Strategies { public class ConnorsVIXReversal3 : Strategy { private const int PrimaryBars = 0; private const int VIXBars = 1; private SMA ShortTermTrend; protected override void OnStateChange() { if (State == State.SetDefaults) { Name = "Connors VIX Reversal 3"; Description = @"Take from Chapter 2 of Connors on Advanced Trading Strategies (1998) by Larry Connors"; Calculate = Calculate.OnBarClose; EntriesPerDirection = 1; ShortTermTrendPeriod = 10; PercentAbove = 10; } else if (State == State.Configure) { AddDataSeries("^VIX"); } else if (State == State.DataLoaded) { ShortTermTrend = SMA(Closes[VIXBars], ShortTermTrendPeriod); } } protected override void OnBarUpdate() { if (PrimaryBars != BarsInProgress) return; if (CurrentBar < ShortTermTrendPeriod) return; if (Lows[VIXBars][0] > ShortTermTrend[0] && Closes[VIXBars][0] >= ShortTermTrend[0] * (1 + PercentAbove / 100)) EnterLong(); if (Lows[VIXBars][0] < ShortTermTrend[0]) ExitLong(); } public override string DisplayName { get { return Name; } } [NinjaScriptProperty] [Display(Name = "Short-Term Trend Period", GroupName = "Connors VIX Reversal 3 Bot", Order = 1)] public int ShortTermTrendPeriod { get; set; } [NinjaScriptProperty] [Display(Name = "Percent Above", GroupName = "Connors VIX Reversal 3 Bot", Order = 2)] public double PercentAbove{ get; set; } } }