ninjatrader/strategies/bearish-engulfing/BearishEngulfingBot.cs

41 lines
1.1 KiB
C#
Raw Normal View History

#region Using declarations
using NinjaTrader.Cbi;
#endregion
namespace NinjaTrader.NinjaScript.Strategies
{
public class BearishEngulfingBot : Strategy
{
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Name = "Bearish Engulfing Bot";
Description = @"Simple strategy based on the bearish engulfing candle pattern";
Calculate = Calculate.OnBarClose;
EntriesPerDirection = 1;
}
else if (State == State.Configure)
{
}
}
protected override void OnBarUpdate()
{
if (CurrentBar < BarsRequiredToTrade)
return;
if (Close[1] > Open[1] && Open[0] > Close[1] && Close[0] < Open[1])
EnterLong();
if (Position.MarketPosition == MarketPosition.Long && Close[0] > High[1])
ExitLong();
}
public override string DisplayName
{
get { return Name; }
}
}
}