ninjatrader/strategies/turnaround/TurnaroundBot.cs

39 lines
1.0 KiB
C#
Raw Permalink Normal View History

2024-11-14 13:53:22 +00:00
#region Using declarations
using NinjaTrader.Cbi;
using System;
#endregion
namespace NinjaTrader.NinjaScript.Strategies
{
public class TurnaroundBot : Strategy
{
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Name = "Turnaround Bot";
Description = @"Turnaround Tuesday / Wednesday";
2024-11-14 13:53:22 +00:00
Calculate = Calculate.OnBarClose;
EntriesPerDirection = 1;
}
}
protected override void OnBarUpdate()
{
if (CurrentBar < BarsRequiredToTrade) return;
if ((Time[0].DayOfWeek == DayOfWeek.Monday || Time[0].DayOfWeek == DayOfWeek.Tuesday) &&
Close[0] < Close[1] && Close[1] < Close[2])
EnterLong();
if (Position.MarketPosition == MarketPosition.Long && Close[0] > High[1])
ExitLong();
}
public override string DisplayName
{
get { return Name; }
}
2024-11-14 13:53:22 +00:00
}
}