Add high / low period parameters to Turtle Trading strategy
This commit is contained in:
parent
d796bace40
commit
9ec7cc29ff
@ -1,5 +1,6 @@
|
|||||||
#region Using declarations
|
#region Using declarations
|
||||||
using NinjaTrader.Cbi;
|
using NinjaTrader.Cbi;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace NinjaTrader.NinjaScript.Strategies
|
namespace NinjaTrader.NinjaScript.Strategies
|
||||||
@ -14,6 +15,9 @@ namespace NinjaTrader.NinjaScript.Strategies
|
|||||||
Description = @"Based on the Turtle Trading method by Richard Dennis and William Eckhardt";
|
Description = @"Based on the Turtle Trading method by Richard Dennis and William Eckhardt";
|
||||||
Calculate = Calculate.OnBarClose;
|
Calculate = Calculate.OnBarClose;
|
||||||
EntriesPerDirection = 1;
|
EntriesPerDirection = 1;
|
||||||
|
|
||||||
|
HighPeriod = 20;
|
||||||
|
LowPeriod = 10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -22,12 +26,12 @@ namespace NinjaTrader.NinjaScript.Strategies
|
|||||||
if (CurrentBar < BarsRequiredToTrade)
|
if (CurrentBar < BarsRequiredToTrade)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (Close[0] > MAX(High, 20)[1])
|
if (Close[0] > MAX(High, HighPeriod)[1])
|
||||||
EnterLong();
|
EnterLong();
|
||||||
|
|
||||||
if (Position.MarketPosition == MarketPosition.Long)
|
if (Position.MarketPosition == MarketPosition.Long)
|
||||||
{
|
{
|
||||||
if (Close[0] < MIN(Low, 10)[1])
|
if (Close[0] < MIN(Low, LowPeriod)[1])
|
||||||
ExitLong();
|
ExitLong();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -36,5 +40,13 @@ namespace NinjaTrader.NinjaScript.Strategies
|
|||||||
{
|
{
|
||||||
get { return Name; }
|
get { return Name; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[NinjaScriptProperty]
|
||||||
|
[Display(Name = "High Period", GroupName = "Turtle Trading Bot", Order = 1)]
|
||||||
|
public int HighPeriod { get; set; }
|
||||||
|
|
||||||
|
[NinjaScriptProperty]
|
||||||
|
[Display(Name = "Low Period", GroupName = "Turtle Trading Bot", Order = 2)]
|
||||||
|
public int LowPeriod { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user