Add down day streak parameter to Knife Catcher strategy

This commit is contained in:
moshferatu 2024-08-30 08:36:51 -07:00
parent 91650d6cca
commit 4a711e1969

View File

@ -30,6 +30,7 @@ namespace NinjaTrader.NinjaScript.Strategies
BarsRequiredToTrade = 20;
IsInstantiatedOnEachOptimizationIteration = true;
DownDayStreak = 3;
BarsToExit = 5;
}
}
@ -38,8 +39,18 @@ namespace NinjaTrader.NinjaScript.Strategies
{
if (CurrentBar < 3)
return;
if (Close[0] < Close[1] && Close[1] < Close[2] && Close[2] < Close[3])
bool isFallingKnife = true;
for (int i = 0; i < DownDayStreak; i++)
{
if (Close[i] >= Close[i + 1])
{
isFallingKnife = false;
break;
}
}
if (isFallingKnife)
EnterLong();
if (BarsSinceEntryExecution() >= BarsToExit)
@ -52,7 +63,13 @@ namespace NinjaTrader.NinjaScript.Strategies
}
[NinjaScriptProperty]
[Display(Name = "Bars to Exit", GroupName = "Knife Catcher Bot", Order = 1)]
[Range(1, int.MaxValue)]
[Display(Name = "Down Day Streak", GroupName = "Knife Catcher Bot", Order = 1)]
public int DownDayStreak { get; set; }
[NinjaScriptProperty]
[Range(1, int.MaxValue)]
[Display(Name = "Bars to Exit", GroupName = "Knife Catcher Bot", Order = 2)]
public int BarsToExit { get; set; }
}
}