Question #1: Should the SetTrailStop(), SetStopLoss(), SetParabolicStop(), and SetProfitTarget() methods be called in the "OnStateChange()" when "State == State.Configure" or "State == State.DataLoaded"?
Question #2: Are one of these two places a bad, dangerous place to insert these methods, is one a little better than the other, or are they both just as good as locations for these 4 methods to be inserted?
I ask this question because I noticed a difference between where the NinjaTrader Strategy Builder inserts the "Stops and targets" methods (SetTrailStop(), SetStopLoss(), SetParabolicStop(), and SetProfitTarget()) and where the examples in the official NinjaTrader help docs for these 4 methods insert these methods.
When I use the Strategy Builder in the newest NinjaTrader Desktop version (8.1.2.1) and add any of these 4 methods (including both of the variants for the 3 methods that have them, for a total of 7 possible choices) from the "Stops and Targets" tab, it inserts these methods in "OnStateChange()" when "State == State.DataLoaded", like this:
else if (State == State.DataLoaded)
{
SetProfitTarget(CalculationMode.Currency, 0);
SetTrailStop("", CalculationMode.Percent, 0, false);
}
However, on the 4 official NinjaTrader help docs for these 4 methods, the examples show these methods being inserted in "OnStateChange()" when "State == State.Configure", like this:
SetStopLoss() official help doc: https://ninjatrader.com/support/help...etstoploss.htm
protected override void OnStateChange()
{
if (State == State.Configure)
{
// Submits a stop loss of $500
SetStopLoss(CalculationMode.Currency, 500);
}
}
SetTrailStop() official help doc: https://ninjatrader.com/support/help...ttrailstop.htm
protected override void OnStateChange()
{
if (State == State.Configure)
{
// Sets a trail stop of 12 ticks
SetTrailStop(CalculationMode.Ticks, 12);
}
}
protected override void OnStateChange()
{
if (State == State.Configure)
{
// Sets a parabolic stop using default acceleration (0.02), accelerationMax (0.2), accelerationStep (0.02) settings and a floor value of 12 ticks
SetParabolicStop(CalculationMode.Ticks, 12);
// Sets a parabolic stop of with a currency floor of 500
SetParabolicStop("MyLongEntry", CalculationMode.Currency, 500, false, 0.03, 0.3, 0.01);
}
}
SetProfitTarget() official help doc: https://ninjatrader.com/support/help...ofittarget.htm
protected override void OnStateChange()
{
if (State == State.Configure)
{
// Submits a profit target order 10 ticks away from the avg entry price
SetProfitTarget(CalculationMode.Ticks, 10);
}
}
EquityTrader

Comment