Set order size based on net liquidity in strategy


Category:
0
0

Hi Pete, in a strategy is there a way to dynamically adjust tradeSize in the AddOrder function to buy as many shares/contracts as possible (or a percentage of the maximum possible) for each new order, based on net liquidity? And then sell the same number of shares/contracts that were bought in the previous order? Rather than just buying the same set number of shares/contracts for each order in the strategy. I’ve searched through the forum but didn’t find anything that already explores this. Thanks in advance.

Marked as spam
Posted by (Questions: 4, Answers: 6)
Asked on November 17, 2022 8:26 pm
66 views
0
Private answer

Is it possible? Perhaps. But there is certainly nothing provided as a built-in method or function which can accomplish this. The entire process would need to be created from scratch.

The chart strategy would need to be self-contained, handling both the entries as well as the exits. It would need to include a custom made framework which tracks the beginning equity (probably based on a user input). At each entry and exit point that framework would need to keep track of those prices and quantities. (at this very point there is a possibility of running into a feedback loop)

Assuming a feedback loop can be avoided, the next level of the framework would then need to use those metrics to update the current equity at each exit.

I would not even consider building something like this for a fee. My sanity is far to valuable for me to risk it on trying to solve something like this in the rudimentary scripting environment of Thinkorswim. You need something like Python or C++.

But that means you need an entirely different trading platform.

And there is your answer. Don't waste any time tying to do stuff like this on Thinkorswim when there are plenty of trading platforms out there which will handle this natively.

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on November 18, 2022 8:51 am