Initial commit of Turnaround strategy
This commit is contained in:
parent
95c5750718
commit
92a6c244f1
49
strategies/turnaround/TurnaroundBot.cs
Normal file
49
strategies/turnaround/TurnaroundBot.cs
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
#region Using declarations
|
||||||
|
using NinjaTrader.Cbi;
|
||||||
|
using System;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
namespace NinjaTrader.NinjaScript.Strategies
|
||||||
|
{
|
||||||
|
public class TurnaroundBot : Strategy
|
||||||
|
{
|
||||||
|
protected override void OnStateChange()
|
||||||
|
{
|
||||||
|
if (State == State.SetDefaults)
|
||||||
|
{
|
||||||
|
Description = @"Turnaround Tuesday / Wednesday";
|
||||||
|
Name = "Turnaround 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnBarUpdate()
|
||||||
|
{
|
||||||
|
if (CurrentBar < BarsRequiredToTrade) return;
|
||||||
|
|
||||||
|
// Entry
|
||||||
|
if ((Time[0].DayOfWeek == DayOfWeek.Monday || Time[0].DayOfWeek == DayOfWeek.Tuesday) &&
|
||||||
|
Close[0] < Close[1] && Close[1] < Close[2])
|
||||||
|
EnterLong();
|
||||||
|
|
||||||
|
// Exit
|
||||||
|
if (Position.MarketPosition == MarketPosition.Long && Close[0] > High[1])
|
||||||
|
ExitLong();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user