How to back test an OCO order bracket


Category:
0
0

Hi Pete,

Hope you’re doing well. I have my entry order figured out, but im having a hard time figuring out how to create an auto trade script exit order with bracket order on TOS that will tell the system to exit/ close my position either to exit for $2  or 20 tick above my entry or $1 or 10 ticks stop order below my entry.

AddOrder:(ordertype. buy_to_open, bullish, open[-1], tradeSize, Color. blue, Color. blue);

Thanks.

 

Marked as spam
Posted by (Questions: 2, Answers: 3)
Asked on July 1, 2021 12:03 am
329 views
0
Private answer

Your original question title has been updated. You entered a title of "Automatic Trading oco/ bracket" which did not correctly describe what you are trying to accomplish. Automated trading pertains to the automation of order execution in a live market. Whereas you are working with the AddOrder() statement which can only be applied to a Chart Strategy used to back-test trading setups. It can NOT be used to automate any trades on Thinkorswim.

If you are interested in learning to use Chart Strategies for back-testing trading setups on Thinkorswim you will want to review the following videos:

https://www.hahn-tech.com/thinkorswim-strategy-guide/

https://www.hahn-tech.com/thinkorswim-strategy-analysis/

Now let's get to the solution to your request. If you want to simulate the use of an OCO bracket order on Thinkorswim you can add the following built-in strategies to your chart:

ProfitTargetLX: https://tlc.thinkorswim.com/center/reference/Tech-Indicators/strategies/L-P/ProfitTargetLX

StopLossLX: https://tlc.thinkorswim.com/center/reference/Tech-Indicators/strategies/R-S/StopLossLX

Each of these also have an "SX" version for matching with a short entry strategy. Just add those to your charts, select the "offset type" and adjust the "target" parameters as needed. Done. If you want to incorporate these directly into your existing custom Chart Strategy you can examine the code for those built-in profit target and stop loss strategies.

Its very important the rest of our viewers are not mistaken as to how this solution can be applied so that we don't mislead them into believing this solution might be used to automate live trades on Thinkorswim in any way. The only tool used to automate trade execution on Thinkorswim is through the Conditional Order tool. This tool is in no way associated with the AdddOrder() statement used in Chart Strategies. For a complete explanation and demonstration of what is possible for automated trading on Thinkorswim please review the following video:

https://www.hahn-tech.com/thinkorswim-autotrade-almost/

 

Marked as spam
Posted by (Questions: 37, Answers: 4084)
Answered on July 1, 2021 8:09 am