Is this the appropriate use of SetProfitTarget?
And related, what is the impact to my backtest by setting an entry price for the EnterLongLimit that is less than current Close[0]? Is this making my results look better than reality, or is that limit actually not filled if the next bar does not have tick that would fill as in the real world?
void Buy() { int size = 0; double entryPrice = 0.0; if (this.TradingStocks) { entryPrice = Close[0] - (_atr[0] * this.ATRMultiple); size = (int) (this.InitialCapital / entryPrice); } else if (this.TradingFutures) { entryPrice = Close[0] - (Math.Truncate(_atr[0] * this.ATRMultiple) / TickSize); size = (int) (this.InitialCapital / 20000.0); } if (size > 0) { base.EnterLongLimit(size, entryPrice, "B"+base.CurrentBar); base.SetProfitTarget("B"+base.CurrentBar, CalculationMode.Ticks, Math.Truncate((_atr[0] * this.ATRMultiple) / TickSize), false); //base.ExitLongLimit(entryPrice + (TickSize * Math.Truncate(_atr[0] * this.ATRMultiple)), "B"+base.CurrentBar); base.SetTrailStop("B"+base.CurrentBar, CalculationMode.Ticks, Math.Truncate((_atr[0] * this.ATRMultiple) / TickSize), false); } }
Comment