How to adjust script to allow a strategy to buy more before close signal occurs?


Category:
0
0

Hi! I’m new to your videos and want to thank you for your great videos which explain how to optimize TOS features! But I would like the Strategies to be able to buy whenever there is a buy signal, even if there has not been a sell signal to close out a position yet.  Sort of like allowing dollar cost averaging to be performed on successive buy signals.  How can I adjust the script to allow this?  Ex. Assuming each buy order is the same number of shares, if the strategy executes three successive buy orders, there is now 3 times the original number of shares. A subsequent sell order needs to sell ALL of the accumulated shares, and then calculate the profit (or loss) from the total cost basis.

I looked at the script of the strategy RSIStrat but there is no way to adjust for the above wish. Each long position must be closed out before another buy signal will be executed.  Please correct me if I am mistaken.
Thanks again,

Hugh

Marked as spam
Posted by (Questions: 1, Answers: 0)
Asked on February 18, 2017 1:17 pm
687 views
1
Private answer

Hi!  I found in the Studies menu a button at the bottom left corner called “Global Strategy Settings”.  That button opens a menu which allows you to set the number of entry orders in the same direction.  This allows a buy strategy to buy more positions if there are more buy signal trigger that occur before a sell signal trigger.   This often results in dollar-cost-averaging on repeated buy signals.  However, once a sell signal is triggered, the entire position is sold.  So you can “scale in”, but you cannot “scale out”.  If anyone discovers how to scale out, then please post!

Hugh

Marked as spam
Posted by (Questions: 2, Answers: 2)
Answered on August 24, 2017 4:31 pm
0

I sent an email to support and received a response. They explained how to do this but I haven’t had time to play with it yet. I’ll get around to it eventually. This is a real game changer for us. The technique they gave me may work for both scaling in and scaling out. They didn’t specify.

( at August 24, 2017 7:04 pm)
0
Private answer

Thanks for the feedback, glad you find the resources here useful. I am sorry to say that as of this time there is no way to scale in or scale out of positions in the Strategies on Thinkorswim. I have tested this and confirmed it is not possible. But as it seems very valuable to the community I suggest everyone that would like this feature to submit a feature request to TD Ameritrade support.

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on February 18, 2017 1:42 pm
0
Private answer

Pete, any update on how this could be done?

Marked as spam
Posted by (Questions: 2, Answers: 2)
Answered on February 18, 2018 12:36 pm
0
Private answer

Here is the response I received from Thinkscript support:

If you’re trying to implement this on a back testing strategy using the AddOrder() function you could do something like the below example script. Note the second AddOrder line by itself would never fire a trade as it needs another addorder() statement to create the first trades to generate a value for EntryPrice(). This could create two buys in a row or two sells in a row. I hope this helps!
 
AddOrder(condition = close > open, type = ordertype.buy_auto, tradesize = 100);
AddOrder(condition = close > EntryPrice() + 3 or close < EntryPrice() – 9, type = OrderType.SELL_AUTO, tradeSize = 100);

I have not taken the time to experiment with this yet.

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on February 18, 2018 1:53 pm