I am doing backtest with CL. I am using 5 min bar as primary bar and I enable intrabar trade feature by adding a smaller granularity time frames, such as 1 min bar. something like this:
protected override void Initialize() { BarsRequired = 20; Add(PeriodType.Minute, 1); SetStopLoss(CalculationMode.Price, 500); SetProfitTarget(CalculationMode.Ticks, 1000); CalculateOnBarClose = false; }
PrintWithTimeStamp ("BarNo: " + CurrentBar + " at: " + BarsInProgress + " " + Positions[0].MarketPosition + " " + Positions[1].MarketPosition); if (BarsInProgress == 0) { bool Condition = Close[1] < ParabolicSAR(BarsArray[0], 0.02, 0.2, 0.02)[0]; if (Condition) { if (Position.MarketPosition == MarketPosition.Flat) { EnterShort(1, DefaultQuantity, "sell"); } } else { if (Position.MarketPosition == MarketPosition.Flat) { EnterLong (1, DefaultQuantity, "buy"); } } } else if (BarsInProgress == 1) { if (Position.MarketPosition != MarketPosition.Flat) { if (FirstTickOfBar) { SetStopLoss (CalculationMode.Price, ParabolicSAR(BarsArray[0], 0.02, 0.2, 0.02)[0]); } } }
but 1). the print statement I added will print "xx:xx:xx at 1 flat flat" even if the time scope has trades and is not flat.
2) there are a lots of strange trades which only last 1 5min bar and triggered by preset stop-loss order, but I am not sure why the stop-loss price is not same with my print. and the strange thing is the stop-loss price is same with entry price in such weird trades, please see my attached pic for sample.
Comment