Tracking Trade Position for “Auto” Trading


Category:
0
0

I’ve been trying to find a reliable way to track (and use) my current trade position (long or short, as I do forex trading) as a factor for a conditional trade for “almost” auto-trading ability of ThinkorSwim. What does not work:

  • Recursive reference to set the current position to prior position if no change (i.e. buy or sell exit/reversal) has occurred (this is because recursion is not allowed in conditional orders, so I cannot use something like pos = pos[1] if no change in position has occurred to “carry over” my current position information).
  • Using a combination of FPL() function and close change to determine position, as the FPL() function is only for Strategies and not accessible for Studies which are needed for conditional orders.
  • Using the functions GetQuantity() (ideal) or GetOpenPL() (with comparison to close), as these read from the users actual account, but apparently are not accessible for conditional orders.

So my question is if you are aware of any way to reliably, whether through a Study or otherwise, track what my current trade position is, such that it can be used to help determine if a trade is taken or not?

My main point in wanting this is so that if, for instance, a buy signal is generated, I only want to buy if I am not already long in the market (or vice-versa for short), as well as using the information to set moving stoploss positions, based on whether I’m long or short the market.

I’m hoping I’m just missing something “easy” to do this, but I’m suspecting instead that it is not “easy” (and may be nearly impossible with the platform’s limitations).

Marked as spam
Posted by (Questions: 2, Answers: 1)
Asked on January 8, 2019 5:08 pm
292 views
0
Private answer

No, Thinkorswim does not make any provision for reading current orders or positions from their code. You will need to move this project to a platform that does. For instance TradeStation or NinjaTrader.

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on January 10, 2019 5:04 pm