Re-organize conditions in 3-Day High / Low strategy in order to properly perform aggressive entries

This commit is contained in:
moshferatu 2024-09-25 10:21:28 -07:00
parent dd40d53d5d
commit 7603e7cf36

View File

@ -43,38 +43,30 @@ namespace NinjaTrader.NinjaScript.Strategies
if (EnableLongTrades)
{
if (Close[0] > longTermTrend[0] && Close[0] < shortTermTrend[0])
{
if (IsConsecutiveLowerHighsAndLows(ConsecutiveDays))
{
if (Position.MarketPosition == MarketPosition.Flat)
EnterLong();
else if (Position.MarketPosition == MarketPosition.Long && Close[0] < Position.AveragePrice
&& EnableAggressiveEntries)
EnterLong();
}
}
if (Position.MarketPosition == MarketPosition.Long && Close[0] > shortTermTrend[0])
ExitLong();
else if (Close[0] > longTermTrend[0])
{
if (IsConsecutiveLowerHighsAndLows(ConsecutiveDays) && Close[0] < shortTermTrend[0] && Position.MarketPosition == MarketPosition.Flat)
EnterLong();
if (EnableAggressiveEntries && Position.MarketPosition == MarketPosition.Long && Close[0] < Position.AveragePrice)
EnterLong();
}
}
if (EnableShortTrades)
{
if (Close[0] < longTermTrend[0] && Close[0] > shortTermTrend[0])
{
if (IsConsecutiveHigherHighsAndLows(ConsecutiveDays))
{
if (Position.MarketPosition == MarketPosition.Flat)
EnterShort();
else if (Position.MarketPosition == MarketPosition.Short && Close[0] > Position.AveragePrice
&& EnableAggressiveEntries)
EnterShort();
}
}
if (Position.MarketPosition == MarketPosition.Short && Close[0] < shortTermTrend[0])
ExitShort();
else if (Close[0] < longTermTrend[0])
{
if (IsConsecutiveHigherHighsAndLows(ConsecutiveDays) && Close[0] > shortTermTrend[0] && Position.MarketPosition == MarketPosition.Flat)
EnterShort();
if (EnableAggressiveEntries && Position.MarketPosition == MarketPosition.Short && Close[0] > Position.AveragePrice)
EnterShort();
}
}
}