I'm trying to figure out why my short orders stopped executing when I added Targets and Stops. I get both long and short executions with the following code I started out with:
entry4_x = 1;
}
else if (State == State.Configure)
{
}
}
[NinjaScriptProperty]
[Description("entry4_x")]
[Category("Parameters")]
public int entry4_x
{ get; set; }
protected override void OnBarUpdate()
{
if (CurrentBar < BarsRequiredToTrade)
return;
EnterLongStopMarket(High[HighestBar(High, entry4_x)]);
EnterShortStopMarket(Low[LowestBar(Low, entry4_x)]);
entry4_x = 1;
Target = 1000;
Stop = 1000;
}
else if (State == State.Configure)
{
SetProfitTarget(@"Entry04Long", CalculationMode.Currency, Target);
SetStopLoss(@"Entry04Long", CalculationMode.Currency, Stop, false);
SetProfitTarget(@"Entry04Short", CalculationMode.Currency, Target);
SetStopLoss(@"Entry04Short", CalculationMode.Currency, Stop, false);
}
}
[NinjaScriptProperty]
[Description("entry4_x")]
[Category("Parameters")]
public int entry4_x
{ get; set; }
[NinjaScriptProperty]
[Range(1, int.MaxValue)]
[Display(Name="Target", Description="Target Price", Order=1, GroupName="Parameters")]
public int Target
{ get; set; }
[NinjaScriptProperty]
[Range(1, int.MaxValue)]
[Display(Name="Stop", Description="Stop Price", Order=2, GroupName="Parameters")]
public int Stop
{ get; set; }
protected override void OnBarUpdate()
{
if (CurrentBar < BarsRequiredToTrade)
return;
EnterLongStopMarket(High[HighestBar(High, entry4_x)],@"Entry04Long");
EnterShortStopMarket(Low[LowestBar(Low, entry4_x)],@"Entry04Short");

Comment