Close trade after X bars

T

toncuz

New member
Hi...newbie here.

Does anyone know of any script I can add to a thinkscript strategy backtest that closes the trade after x amount of bars?



For ex: "After price breaks above 20 day moving average, close trade after 5 bars". Or 3 bars etc...

So I change number of bars to see the strength of a typical breakout per each moveing average breakout or any other strategy. Obviously, the script would replace the "auto buy to close" or auto sel to closel" at the bottom of a TOS strategy. Thanks in advance.

 
Last edited:
BenTen

BenTen

Administrative
Staff
VIP
@toncuz ToS does have support for the
Code:
within X bars
. For example, MovAvgExponential()."AvgExp" crosses close within 5 bars. Give that a try and see if you can replicate it to your need. But I'm not sure if what you needed is available in ThinkorSwim.

 
Last edited:
T

toncuz

New member
Thank you...

Sorry...I meant after a buy signal.

"After price breaks above 20 day moving average, buy-to-open, THEN...sell-to-close trade after 5 bars"

 
Last edited:
BenTen

BenTen

Administrative
Staff
VIP
@toncuz I don't think thats possible at the moment.

 
Last edited:

Top