I feel like this has been asked before, so forgive me in advance
but in backtesting - how should we handle scenarios where my entry and stop happen on the same bar ?
Am I correct in saying that WL8 cannot execute an intra-bar stop order?
below you can see an up bar in grey:
1= short position initiated
2=yellow dot stop loss (breached on the same bar)
3=actual exit showing at the open of next bar

but in backtesting - how should we handle scenarios where my entry and stop happen on the same bar ?
Am I correct in saying that WL8 cannot execute an intra-bar stop order?
CODE:
if (barsSinceEntry == 0) { // Bar 0 (Entry Bar): Initial stop at Midline + 1.0 ATR stopPrice = midline + currentATR; ClosePosition(pos, OrderType.Stop, stopPrice, "Short Initial Stop"); }
below you can see an up bar in grey:
1= short position initiated
2=yellow dot stop loss (breached on the same bar)
3=actual exit showing at the open of next bar
Rename
Check AssignAutoStopTargetPrices method.
Or you can just create a sample block strategy, for stop exit, select "Same Bar" check box, and check the C# code it generates.
Or you can just create a sample block strategy, for stop exit, select "Same Bar" check box, and check the C# code it generates.
Thank you ! This proved to be quite helpful ! Pasting the ref details here for visibility
You can override this method to assign values to the AutoProfitTargetPrice and AutoStopLossPrice properties of the Transaction instance passed in the t parameter. See the corresponding entries for these properties in the Transaction class for more details on same-bar exits. The advantage of assigning these properties within this method is that it provides you the actual executionPrice, upon which you can base the desired profit target and stop loss prices.
CODE:
public virtual void AssignAutoStopTargetPrices(Transaction t, double basisPrice, double executionPrice)
You can override this method to assign values to the AutoProfitTargetPrice and AutoStopLossPrice properties of the Transaction instance passed in the t parameter. See the corresponding entries for these properties in the Transaction class for more details on same-bar exits. The advantage of assigning these properties within this method is that it provides you the actual executionPrice, upon which you can base the desired profit target and stop loss prices.
Your Response
Post
Edit Post
Login is required