I discovered an intraday strategy using a bastardised Coppock Curve to trigger entries, running it on TOS it generates crazy results. In attempting to use the strategy wizard I created some sort of monster that works going short, but gives sub par results going long.
The part I am stuck on is how to go about getting the WMA of (ROC1 + ROC2). Then creating the if statement that enters a trade.
If anyone can help me out it would be much appreciated!
########################################
#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.Indicators;
using NinjaTrader.NinjaScript.DrawingTools;
#endregion
//This namespace holds Strategies in this folder and is required. Do not change it.
namespace NinjaTrader.NinjaScript.Strategies
{
public class CoppockBullV3 : Strategy
{
private ROC ROC1;
private ROC ROC2;
private WMA WMA1;
private CurrentDayOHL CurrentDayOHL1;
private PriorDayOHLC PriorDayOHLC1;
private EMA EMA1;
private SMA SMA1;
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Enter the description for your new custom Strategy here.";
Name = "CoppockBullV3";
Calculate = Calculate.OnBarClose;
EntriesPerDirection = 1;
EntryHandling = EntryHandling.AllEntries;
IsExitOnSessionCloseStrategy = true;
ExitOnSessionCloseSeconds = 30;
IsFillLimitOnTouch = true;
MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
OrderFillResolution = OrderFillResolution.High;
OrderFillResolutionType = BarsPeriodType.Tick;
OrderFillResolutionValue = 1;
Slippage = 0;
StartBehavior = StartBehavior.WaitUntilFlat;
TimeInForce = TimeInForce.Gtc;
TraceOrders = false;
RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
StopTargetHandling = StopTargetHandling.PerEntryExecution;
BarsRequiredToTrade = 20;
// Disable this property for performance gains in Strategy Analyzer optimizations
// See the Help Guide for additional information
IsInstantiatedOnEachOptimizationIteration = true;
Fast = 8;
Slow = 12;
WeightedMA = 8;
FastCloseEMA = 4;
SlowCloseSMA = 9;
StopLoss = 12;
ProfitTarget = 6;
TrailLength = 16;
}
else if (State == State.Configure)
{
}
else if (State == State.DataLoaded)
{
ROC1 = ROC( Convert.ToInt32(Fast));
ROC2 = ROC( Convert.ToInt32(Slow));
CurrentDayOHL1 = CurrentDayOHL(Close);
PriorDayOHLC1 = PriorDayOHLC(Close);
EMA1 = EMA(Close, Convert.ToInt32(FastCloseEMA));
SMA1 = SMA(Close, Convert.ToInt32(SlowCloseSMA));
WMA1 = WMA((ROC1 + ROC2),Convert.ToInt32(WeightedMA));
CurrentDayOHL1.Plots[0].Brush = Brushes.FloralWhite;
CurrentDayOHL1.Plots[1].Brush = Brushes.SeaGreen;
CurrentDayOHL1.Plots[2].Brush = Brushes.Red;
AddChartIndicator(CurrentDayOHL1);
SetProfitTarget(@"Long", CalculationMode.Ticks, ProfitTarget);
SetStopLoss(@"Long", CalculationMode.Ticks, StopLoss, false);
SetTrailStop(@"Long", CalculationMode.Ticks, TrailLength, false);
}
}
protected override void OnBarUpdate()
{
if (BarsInProgress != 0)
return;
if (CurrentBars[0] < 2)
return;
// Set 1
if (WMA1[1] < 0)
&& (WMA1 > WMA1[1])
&& (WMA1[1] < WMA1[2])
&& (CurrentDayOHL1.CurrentOpen[0] < GetCurrentBid(0))
&& (Close[0] > PriorDayOHLC1.PriorClose[0]))
{
EnterLong(Convert.ToInt32(DefaultQuantity), @"Long");
}
// Set 2
if (CrossBelow(EMA1, SMA1, 1))
{
ExitLong(Convert.ToInt32(DefaultQuantity), @"Cover", @"Long");
}
}
#region Properties
[NinjaScriptProperty]
[Range(1, int.MaxValue)]
[Display(Name="Fast", Order=1, GroupName="Parameters")]
public int Fast
{ get; set; }
[NinjaScriptProperty]
[Range(1, int.MaxValue)]
[Display(Name="Slow", Order=2, GroupName="Parameters")]
public int Slow
{ get; set; }
[NinjaScriptProperty]
[Range(1, int.MaxValue)]
[Display(Name="WeightedMA", Order=3, GroupName="Parameters")]
public int WeightedMA
{ get; set; }
[NinjaScriptProperty]
[Range(1, int.MaxValue)]
[Display(Name="FastCloseEMA", Order=4, GroupName="Parameters")]
public int FastCloseEMA
{ get; set; }
[NinjaScriptProperty]
[Range(1, int.MaxValue)]
[Display(Name="SlowCloseSMA", Order=5, GroupName="Parameters")]
public int SlowCloseSMA
{ get; set; }
[NinjaScriptProperty]
[Range(1, int.MaxValue)]
[Display(Name="StopLoss", Order=6, GroupName="Parameters")]
public int StopLoss
{ get; set; }
[NinjaScriptProperty]
[Range(1, int.MaxValue)]
[Display(Name="ProfitTarget", Order=7, GroupName="Parameters")]
public int ProfitTarget
{ get; set; }
[NinjaScriptProperty]
[Range(1, int.MaxValue)]
[Display(Name="TrailLength", Order=8, GroupName="Parameters")]
public int TrailLength
{ get; set; }
#endregion
}
}
#region Wizard settings, neither change nor remove
#endregion