Add parameters to 10-day low strategy
This commit is contained in:
parent
a6c26c7aac
commit
2fbf175ca1
@ -1,6 +1,7 @@
|
||||
#region Using declarations
|
||||
using NinjaTrader.Cbi;
|
||||
using NinjaTrader.NinjaScript.Indicators;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
#endregion
|
||||
|
||||
namespace NinjaTrader.NinjaScript.Strategies
|
||||
@ -8,7 +9,7 @@ namespace NinjaTrader.NinjaScript.Strategies
|
||||
public class TenDayLowBot : Strategy
|
||||
{
|
||||
private MIN lows;
|
||||
private SMA sma;
|
||||
private SMA shortTermTrend;
|
||||
private SMA longTermTrend;
|
||||
|
||||
protected override void OnStateChange()
|
||||
@ -33,24 +34,28 @@ namespace NinjaTrader.NinjaScript.Strategies
|
||||
StopTargetHandling = StopTargetHandling.PerEntryExecution;
|
||||
BarsRequiredToTrade = 20;
|
||||
IsInstantiatedOnEachOptimizationIteration = true;
|
||||
|
||||
LowPeriod = 10;
|
||||
ShortTermTrendPeriod = 10;
|
||||
LongTermTrendPeriod = 200;
|
||||
}
|
||||
else if (State == State.DataLoaded)
|
||||
{
|
||||
lows = MIN(Low, 10);
|
||||
sma = SMA(10);
|
||||
longTermTrend = SMA(200);
|
||||
lows = MIN(Low, LowPeriod);
|
||||
shortTermTrend = SMA(ShortTermTrendPeriod);
|
||||
longTermTrend = SMA(LongTermTrendPeriod);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnBarUpdate()
|
||||
{
|
||||
if (CurrentBar < 10)
|
||||
if (CurrentBar < LowPeriod)
|
||||
return;
|
||||
|
||||
if (Low[0] == lows[0] && Close[0] > longTermTrend[0])
|
||||
EnterLong();
|
||||
|
||||
if (Close[0] > sma[0])
|
||||
if (Close[0] > shortTermTrend[0])
|
||||
ExitLong();
|
||||
}
|
||||
|
||||
@ -58,5 +63,17 @@ namespace NinjaTrader.NinjaScript.Strategies
|
||||
{
|
||||
get { return Name; }
|
||||
}
|
||||
|
||||
[NinjaScriptProperty]
|
||||
[Display(Name = "Low Period", GroupName = "10-Day Low Bot", Order = 1)]
|
||||
public int LowPeriod { get; set; }
|
||||
|
||||
[NinjaScriptProperty]
|
||||
[Display(Name = "Short Term Trend Period", GroupName = "10-Day Low Bot", Order = 2)]
|
||||
public int ShortTermTrendPeriod { get; set; }
|
||||
|
||||
[NinjaScriptProperty]
|
||||
[Display(Name = "Long Term Trend Period", GroupName = "10-Day Low Bot", Order = 3)]
|
||||
public int LongTermTrendPeriod { get; set; }
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user