I coded my strategy ,but in the Strategy Analyser didn't make any trade,something is wrong.
My strategy open a entry position if the sma(40)>sma(200),when the prices breakout the upper Donchian Channel(55).And exit long position when the prices breakout the slower Donchian Channel(20) or the prices = Entry Price - ATR of the Entry Price*2,whichever comes first.
Please,see all my strategy below and tell me what's wrong.
#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.Indicator;
using NinjaTrader.Gui.Chart;
using NinjaTrader.Strategy;
#endregion
// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
/// <summary>
/// The system 2 of The Original Turtle Trading Rules with the filter of Curtis Faith.
/// </summary>
[Description("The system 2 of The Original Turtle Trading Rules with the filter of Curtis Faith.")]
public class TurtleTradingSystembyCurtisFaith : Strategy
{
#region Variables
// Wizard generated variables
private int myInput0 = 1; // Default setting for MyInput0
// User defined variables (add any user defined variables below)
#endregion
/// <summary>
/// This method is used to configure the strategy and is called once before any strategy method is called.
/// </summary>
protected override void Initialize()
{
Add(DonchianChannel(55));
Add(DonchianChannel(20));
Add(SMA(40));
Add(SMA(200));
Add(ATR(20));
CalculateOnBarClose = true;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Condition set 1
double myATR = ATR(20)[0];
if (Close[0] >= DonchianChannel(55).Upper[0]
&& SMA(40)[0] > SMA(200)[0])
{
EnterLong(DefaultQuantity, "EnterLong");
}
// Exit Condition 1 - Breakout
if (Close[0] <= DonchianChannel(20).Lower[0])
{
ExitLong("ExitLongDC", "");
}
if (Position.MarketPosition == MarketPosition.Long)
{
//Print ATRStopLoss
SetStopLoss(CalculationMode.Price, Position.AvgPrice-(myATR*2));
}
}
#region Properties
[Description("")]
[GridCategory("Parameters")]
public int MyInput0
{
get { return myInput0; }
set { myInput0 = Math.Max(1, value); }
}
#endregion
}
}

Comment