I have a strategy who consiste to trade only one instrument with only one order (short or long). In the strategy analyser all it’s perfect and if I put the strategy in the chart all it’s ok to… But when I connect the strategy with my broker, the strategy can increase the orders quantity by taking many trades after time and I don’t know why. (if i’m already long, I don’t want another order long…)
Someone have a idea?
...
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"";
Name = “Stategy”;
Calculate = Calculate.OnBarClose;
EntriesPerDirection = 1;
EntryHandling = EntryHandling.AllEntries;
IsExitOnSessionCloseStrategy = false;
ExitOnSessionCloseSeconds = 30;
IsFillLimitOnTouch = false;
MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
OrderFillResolution = OrderFillResolution.Standard;
Slippage = 0;
StartBehavior = StartBehavior.AdoptAccountPosition;
TimeInForce = TimeInForce.Gtc;
TraceOrders = true;
RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
StopTargetHandling = StopTargetHandling.PerEntryExecution;
BarsRequiredToTrade = 20;
IsInstantiatedOnEachOptimizationIteration = true;
IsAdoptAccountPositionAware = true;
else if (State == State.Configure)
{
AddDataSeries(Data.BarsPeriodType.Minute, 1);
AddDataSeries(Data.BarsPeriodType.Minute, 2);
AddDataSeries(Data.BarsPeriodType.Minute, 3);
AddDataSeries(Data.BarsPeriodType.Minute, 4);
protected override void OnBarUpdate()
{
if (BarsInProgress != 0)
return;
if (CurrentBars[0] < 1
|| CurrentBars[1] < 1
|| CurrentBars[2] < 1
|| CurrentBars[3] < 1
|| CurrentBars[4] < 1)
return;
ExitLong(Convert.ToInt32(DefaultQuantity), "ProfitTarget", "");
ExitShort(Convert.ToInt32(DefaultQuantity), "ProfitTarget", "");
EnterLong(Convert.ToInt32(DefaultQuantity), "EnterLong");
EnterShort(Convert.ToInt32(DefaultQuantity), "EnterShort");
Comment