ninjatrader/strategies/turnaround/TurnaroundBot.cs

39 lines
1.0 KiB
C#

#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";
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; }
}
}
}