Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Coppock Curve

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Coppock Curve

    Disclaimer: I don't know my ass from my elbow when it comes to programing.

    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

Latest Posts

Collapse

Topics Statistics Last Post
Started by tonynt, Today, 11:50 AM
0 responses
2 views
0 likes
Last Post tonynt
by tonynt
 
Started by Welovethelibrary, Today, 11:44 AM
0 responses
1 view
0 likes
Last Post Welovethelibrary  
Started by goodknight777, Today, 11:39 AM
0 responses
2 views
0 likes
Last Post goodknight777  
Started by MohammedAmine, Today, 10:44 AM
1 response
6 views
0 likes
Last Post NinjaTrader_Kate  
Started by Nolyn, Today, 10:59 AM
1 response
7 views
0 likes
Last Post NinjaTrader_BrandonH  
Working...
X