I want to program a simple ATR Stop:
In my System I have Two Positions A & B:
I want it so, When the current price is > Entryprice of B - ATR (14).
Action: Exit Both Longs A&B
How can I do this in the Wizards? Did I need to code it instead?
What Variables are used for the Entryprice of Positions and Current Price of Positions?
Thank you for the help
Here is my code:
// 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 ATRSTOPSSS : 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()
{
CalculateOnBarClose = true;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Condition set 1
if (DonchianChannel(14).Upper[1] < High[0])
{
EnterLong(DefaultQuantity, "A");
}
// Condition set 2
if (High[0] > Position.AvgPrice + ATR(14)[0])
{
EnterLong(DefaultQuantity, "B");
}
}
#region Properties
[Description("")]
[Category("Parameters")]
public int MyInput0
{
get { return myInput0; }
set { myInput0 = Math.Max(1, value); }
}
#endregion
}
}

Comment