Of course I assume stops can be tested in back testing. I have had a quick look around the forum but didn't find what I was after.
I have had a quick look around the forum but didn't find what I was after. I generated the code using the wizard and I just want a simple 10 point profit target and 10 point stop loss.
Bet I'm missing something simple lol.
#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>
/// Enter the description of your strategy here
/// </summary>
[Description("Enter the description of your strategy here")]
public class TSRSTrategy : Strategy
{
#region Variables
// Wizard generated variables
private double cheap = -0.5; // Default setting for Cheap
private double expensive = 0.5; // Default setting for Expensive
// 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()
{
SetProfitTarget("10", CalculationMode.Ticks, 0);
SetStopLoss("10", CalculationMode.Ticks, 0, true);
CalculateOnBarClose = true;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Condition set 1
if (CrossAbove(TSR(21), Cheap, 1))
{
EnterLong(1, "");
}
// Condition set 2
if (CrossBelow(TSR(21), Expensive, 1))
{
EnterShort(1, "");
}
}
#region Properties
[Description("")]
[Category("Parameters")]
public double Cheap
{
get { return cheap; }
set { cheap = Math.Max(-1.000, value); }
}
[Description("")]
[Category("Parameters")]
public double Expensive
{
get { return expensive; }
set { expensive = Math.Max(0, value); }
}
#endregion
}
}
Comment