Initial commit of Bearish Engulfing strategy
This commit is contained in:
parent
1cf196e782
commit
46f36ea46e
55
strategies/bearish-engulfing/BearishEngulfingBot.cs
Normal file
55
strategies/bearish-engulfing/BearishEngulfingBot.cs
Normal 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; }
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user