ninjatrader/strategies/bearish-engulfing/BearishEngulfingBot.cs

56 lines
1.8 KiB
C#
Raw Normal View History

#region Using declarations
using NinjaTrader.Cbi;
using System;
#endregion
namespace NinjaTrader.NinjaScript.Strategies
{
public class BearishEngulfingBot : Strategy
{
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"";
Name = "Bearish Engulfing Bot";
Calculate = Calculate.OnBarClose;
EntriesPerDirection = 1;
EntryHandling = EntryHandling.AllEntries;
IsExitOnSessionCloseStrategy = true;
ExitOnSessionCloseSeconds = 30;
IsFillLimitOnTouch = false;
MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
OrderFillResolution = OrderFillResolution.Standard;
Slippage = 0;
StartBehavior = StartBehavior.WaitUntilFlat;
TimeInForce = TimeInForce.Gtc;
TraceOrders = false;
RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
StopTargetHandling = StopTargetHandling.PerEntryExecution;
BarsRequiredToTrade = 20;
IsInstantiatedOnEachOptimizationIteration = true;
}
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; }
}
}
}