Initial commit of Bearish Engulfing strategy

This commit is contained in:
moshferatu 2024-12-16 13:01:11 -08:00
parent 1cf196e782
commit 46f36ea46e

View File

@ -0,0 +1,55 @@
#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; }
}
}
}