Initial commit of IBS + RSI strategy
This commit is contained in:
parent
3290d9ba8e
commit
c62c3b7500
63
strategies/ibs-rsi/IBSRSI.cs
Normal file
63
strategies/ibs-rsi/IBSRSI.cs
Normal file
@ -0,0 +1,63 @@
|
||||
#region Using declarations
|
||||
using NinjaTrader.Cbi;
|
||||
using NinjaTrader.NinjaScript.Indicators;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
#endregion
|
||||
|
||||
namespace NinjaTrader.NinjaScript.Strategies
|
||||
{
|
||||
public class IBSRSI : Strategy
|
||||
{
|
||||
private InternalBarStrength ibs;
|
||||
private RSI rsi;
|
||||
|
||||
protected override void OnStateChange()
|
||||
{
|
||||
if (State == State.SetDefaults)
|
||||
{
|
||||
Name = "IBS + RSI";
|
||||
Description = @"Mean reversion strategy based on the IBS and RSI indicators";
|
||||
Calculate = Calculate.OnBarClose;
|
||||
EntriesPerDirection = 1;
|
||||
|
||||
RSIPeriod = 21;
|
||||
IBSThreshold = 0.25;
|
||||
RSIThreshold = 45.0;
|
||||
}
|
||||
else if (State == State.DataLoaded)
|
||||
{
|
||||
ibs = InternalBarStrength();
|
||||
rsi = RSI(RSIPeriod, 1);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnBarUpdate()
|
||||
{
|
||||
if (CurrentBar < 21)
|
||||
return;
|
||||
|
||||
if (ibs[0] < IBSThreshold && rsi[0] < RSIThreshold)
|
||||
EnterLong();
|
||||
|
||||
if (Position.MarketPosition == MarketPosition.Long && Close[0] > Close[1])
|
||||
ExitLong();
|
||||
}
|
||||
|
||||
public override string DisplayName
|
||||
{
|
||||
get { return Name; }
|
||||
}
|
||||
|
||||
[NinjaScriptProperty]
|
||||
[Display(Name = "RSI Period", GroupName = "IBS + RSI", Order = 1)]
|
||||
public int RSIPeriod { get; set; }
|
||||
|
||||
[NinjaScriptProperty]
|
||||
[Display(Name = "IBS Threshold", GroupName = "IBS + RSI", Order = 2)]
|
||||
public double IBSThreshold { get; set; }
|
||||
|
||||
[NinjaScriptProperty]
|
||||
[Display(Name = "RSI Threshold", GroupName = "IBS + RSI", Order = 3)]
|
||||
public double RSIThreshold { get; set; }
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user