Add a configuration property to the RSI divergence strategy for setting the divergence period
This commit is contained in:
parent
9e0590bad7
commit
8fc49bf60d
@ -35,6 +35,7 @@ namespace NinjaTrader.NinjaScript.Strategies
|
|||||||
|
|
||||||
RSIPeriod = 14;
|
RSIPeriod = 14;
|
||||||
RSISmoothing = 3;
|
RSISmoothing = 3;
|
||||||
|
DivergencePeriod = 5;
|
||||||
}
|
}
|
||||||
else if (State == State.DataLoaded)
|
else if (State == State.DataLoaded)
|
||||||
{
|
{
|
||||||
@ -47,7 +48,7 @@ namespace NinjaTrader.NinjaScript.Strategies
|
|||||||
if (CurrentBar < BarsRequiredToTrade)
|
if (CurrentBar < BarsRequiredToTrade)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (rsi[0] > rsi[5] && Close[0] < Close[5])
|
if (rsi[0] > rsi[DivergencePeriod] && Close[0] < Close[DivergencePeriod])
|
||||||
EnterLong();
|
EnterLong();
|
||||||
|
|
||||||
if (Position.MarketPosition == MarketPosition.Long && rsi[0] > 70.0)
|
if (Position.MarketPosition == MarketPosition.Long && rsi[0] > 70.0)
|
||||||
@ -68,5 +69,10 @@ namespace NinjaTrader.NinjaScript.Strategies
|
|||||||
[Range(1, int.MaxValue)]
|
[Range(1, int.MaxValue)]
|
||||||
[Display(Name = "RSI Smoothing", GroupName = "RSI Divergence Bot", Order = 2)]
|
[Display(Name = "RSI Smoothing", GroupName = "RSI Divergence Bot", Order = 2)]
|
||||||
public int RSISmoothing { get; set; }
|
public int RSISmoothing { get; set; }
|
||||||
|
|
||||||
|
[NinjaScriptProperty]
|
||||||
|
[Range(1, int.MaxValue)]
|
||||||
|
[Display(Name = "Divergence Period", GroupName = "RSI Divergence Bot", Order = 3)]
|
||||||
|
public int DivergencePeriod { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user