38 lines
1009 B
C#
38 lines
1009 B
C#
#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;
|
|
}
|
|
}
|
|
|
|
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; }
|
|
}
|
|
}
|
|
}
|