Sell position when price increases 10% after entry


Category:
0
0

Hello Pete,

Thank you for everything that you do. I have been reading through your site and have learned a lot. Really appreciate it.

A quick question. I am trying to edit a moving average crossover backtesting strategy where the position is sold when the price appreciates by 10% from the entry point. The entry point is initiated when a fast moving average crosses above a slow moving average and I would like to exit when price appreciates by 10%.

I have posted the two AddOrder statements however, I would like to edit the current sell to close order from how it is currently written below (fastMA crosses below slowMA) and replace it with when the price appreciates by 10% from my entry.

Any suggestions would be greatly appreciated.

Thank you.

James

AddOrder (OrderType.BUY_TO_OPEN, fastMA crosses above slowMA, close, quantity);
AddOrder (OrderType.SELL_TO_CLOSE, fastMA crosses below slowMA, close, quantity);

Marked as spam
Posted by (Questions: 1, Answers: 0)
Asked on September 13, 2021 7:55 pm
224 views
0
Private answer

The solution is far easier than you suspect. All you have to do is add one of the built-in chart strategies included with Thinkorswim.

ProfitTargetLX: if you want to exit a long position at a specified profit target

ProfitTargetSX: if you want to exit a short position at a specified profit target

If you want to incorporate either of these into your existing strategy you can view the source code for these built-in strategies.

Marked as spam
Posted by (Questions: 37, Answers: 4086)
Answered on September 13, 2021 10:03 pm