65 lines
2.1 KiB
C#
65 lines
2.1 KiB
C#
#region Using declarations
|
|
using NinjaTrader.Cbi;
|
|
using NinjaTrader.Data;
|
|
using NinjaTrader.NinjaScript.Indicators;
|
|
#endregion
|
|
|
|
namespace NinjaTrader.NinjaScript.Strategies
|
|
{
|
|
public class NYSENewHighsNewLowsBot : Strategy
|
|
{
|
|
private NYSECumulativeNewHighsNewLows newHighsNewLows;
|
|
|
|
protected override void OnStateChange()
|
|
{
|
|
if (State == State.SetDefaults)
|
|
{
|
|
Description = @"Strategy based on NYSE Cumulative New Highs New Lows";
|
|
Name = "NYSE New Highs New Lows Bot";
|
|
Calculate = Calculate.OnBarClose;
|
|
EntriesPerDirection = 1;
|
|
EntryHandling = EntryHandling.AllEntries;
|
|
IsExitOnSessionCloseStrategy = false;
|
|
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)
|
|
{
|
|
AddDataSeries("FINH", BarsPeriodType.Day, 1);
|
|
AddDataSeries("FINL", BarsPeriodType.Day, 1);
|
|
}
|
|
else if (State == State.DataLoaded)
|
|
{
|
|
newHighsNewLows = NYSECumulativeNewHighsNewLows();
|
|
}
|
|
}
|
|
|
|
protected override void OnBarUpdate()
|
|
{
|
|
if (BarsInProgress != 0)
|
|
return;
|
|
|
|
if (newHighsNewLows[0] > 0)
|
|
EnterLong();
|
|
|
|
if (Position.MarketPosition == MarketPosition.Long && newHighsNewLows[0] < 0)
|
|
ExitLong();
|
|
}
|
|
|
|
public override string DisplayName
|
|
{
|
|
get { return Name; }
|
|
}
|
|
}
|
|
}
|