Passing parameters to conditional orders


Category:
0
0

Hi, thank you for your YouTube video on semi-automated roundtrips using conditional orders referencing studies.
May I ask if it’s possible to not just reference a study, but pass a parameter from a study (or even a strategy) to a conditional order? for example:
MyStudy.EntryCondition = E;
MyStudy.SellPrice = X;

MyStudy.StopPrice = Y;

MyStudy.LimitPrice = Z;
I understand I can trigger a conditional order if MyStudy.EntryCondition == 1, but can I pass SellPrice, StopPrice and LimitPrice parameters to these 3 orders that are triggered if entry condition is ==1?

Thank you.

PS: I’m pretty good with ThinkScript but haven’t found an option to pass parameters to close the loop on semi-automated trading.

Marked as spam
Posted by (Questions: 1, Answers: 1)
Asked on December 25, 2023 9:59 am
94 views
0
Private answer

I will begin by reminding our viewers where to locate the video mentioned in this request:

https://www.hahn-tech.com/thinkorswim-automated-round-trip-trades/

Within that video, I was very clear to explain that users should avoid referencing custom studies when building conditional orders. Instead, the entire script of the custom study should be copy/pasted into the conditional order editor. We have already disclosed in other posts on this forum that trying to create a reference to a custom study within a conditional order often results in performance that does not match expectations.

The conditional order tools on Thinkorswim are exceedingly fragile. So long as you keep things very simple, they are robust in their operation. But as you increase the complexity, the tool becomes more fragile and less reliable.

Now that I have clearly cautioned everyone about these limitations, I will attempt to directly address your question.

When you apply a script to a conditional order, that order is only triggered once the condition is true. So to begin with, you must have a true/false condition, or you have nothing to trigger an order. Passing values from other studies is a trivial matter on Thinkorswim . We do this by referencing the plots from another study (just as you described in your theoretical example). But when you are building script for a conditional order, the end result must be a true/false condition.

So passing values for sell price, stop price or target price is not sufficient to trigger an order to be sent to market for execution. If you check the 21:30 time stamp on the video you will see I have completed the entry side of the conditional order and the very next step shows how to create the exit side. You will notice the exit side is based on a true/false condition. The only way we could use a numeric value to trigger the exit side would be to use something like this:

plot trigger = close crosses below ExpAverage(close, 13);

Or you could use something like this:

plot trigger = close crosses below 100;

Let me try to summarize this.

The video I referenced above shows the absolute limits of what is currently possible. I have not held anything back. If you don't see it demonstrated in that video, it's simply not possible. Which means if  you want to automate an OCO bracket order, you must

  1. Create 3 separate orders.
    1. One for the entry,
    2. And two for the exit
    3. One exit being the profit target and the other being the stop loss.
  2. Each of those three orders must to set to Market order
  3. Each one must include the appropriate script used to trigger each order
  4. Each script must be a true/false condition.

Passing parameters from custom chart studies is a trivial matter for someone with your experience, as evidenced from your examples. Just remember that the best way to use this tool is to AVOID referencing custom studies, and use the actual script in your conditional orders instead. Which means I am advising everyone to entirely avoid "passing parameters" to conditional orders. But for those who want to ignore my recommendations, I have at least laid out the foundation from which those could be utilized and the framework within which they can be applied.

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on December 25, 2023 10:33 am
0
Thank you, I appreciate your detailed answer. I was really hoping that something have changed. That being said, I think it doesn’t make sense for me to continue using TOS, I will port my strategies to NinjaTrader. My scripts are too complex even for TOS back-testing, so I’m not going to trust it to trigger market orders.
( at December 25, 2023 11:35 pm)
0
For those who are wondering why bother with Thinkorswim automation tools if they are so limited. Well that is because they operate entirely on the server's of Thinkorswim. You don't have to be logged into Thinkorswim for those automated trades to operate. With nearly every other trade platform, automations run on the client's computer. Which means they cease to operate the moment you log out or your computer losses it's data connection to the exchange. I checked around for alternatives. And there other platforms which support serve side automation. However I found that many of them require the use of webhooks, which introduce another level of fragility into the process. This means that Thinkorswim's server side automation tools are quite unique, and its very difficult to find a replacement that handles automation in this way.
( at December 26, 2023 8:25 am)