Add a configuration setting for position size to daily reversal strategy
This commit is contained in:
parent
f16f801dd1
commit
b821a6da24
@ -2,6 +2,7 @@
|
||||
using NinjaTrader.Cbi;
|
||||
using NinjaTrader.Data;
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
#endregion
|
||||
|
||||
namespace NinjaTrader.NinjaScript.Strategies
|
||||
@ -35,6 +36,8 @@ namespace NinjaTrader.NinjaScript.Strategies
|
||||
StopTargetHandling = StopTargetHandling.PerEntryExecution;
|
||||
BarsRequiredToTrade = 2;
|
||||
IsInstantiatedOnEachOptimizationIteration = true;
|
||||
|
||||
PositionSize = 10000;
|
||||
}
|
||||
else if (State == State.Configure)
|
||||
{
|
||||
@ -53,7 +56,7 @@ namespace NinjaTrader.NinjaScript.Strategies
|
||||
return;
|
||||
|
||||
// Using fixed position sizing to account for lower index values in the past.
|
||||
int quantity = (int)Math.Floor(10000 / Close[0]);
|
||||
int quantity = (int)Math.Floor(PositionSize / Close[0]);
|
||||
|
||||
if (Lows[PrimaryBars][0] < Lows[PrimaryBars][1] && Highs[PrimaryBars][0] < Highs[PrimaryBars][1])
|
||||
{
|
||||
@ -66,5 +69,11 @@ namespace NinjaTrader.NinjaScript.Strategies
|
||||
if (ToTime(Time[0]) == ToTime(sessionClose.AddMinutes(-1)))
|
||||
ExitLong();
|
||||
}
|
||||
|
||||
[NinjaScriptProperty]
|
||||
[Range(1, int.MaxValue)]
|
||||
[Display(Name = "Position Size", GroupName = "Daily Reversal Bot", Order = 1)]
|
||||
public int PositionSize
|
||||
{ get; set; }
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user