Help With Conditional Order on Thinkorswim


Category:
0
0

Hi Pete,

I watched your tutorial on how to do semi-auto orders on tos yesterday.

  1. I have a custom studies, which I want to place my conditional order based. But when I followed the step and put below script into New Studies, it just says “expected doubles” error message. Can you help me fix it?

input price = close;
input length = 20;
input deviation = .25;
def sDev = StDev(data = price, length = length);
plot MidLine = Average(data = price, length = length);
plot LBB = MidLine + deviation * -sDev;
plot UBB = MidLine + deviation * sDev;

2. Also, I realized there is tos doesn’t support conditional orders based on ATR trailing stop, but it supports some custom studies. Is there any ways to find a similar study?

Thanks a lot for your help!

Daisy

 

Editor’s note: The title and URL of this post has been adjusted to correct a spelling error.

Attachments:
Marked as spam
Posted by (Questions: 1, Answers: 2)
Asked on October 17, 2017 12:05 am
4291 views
0

Before I answer the question I need to correct the typo in your question’s title “Conditioner Order on TOS”. This will also break the current URL you are using to view this post. In order to access this post after I make that change, you will need to use the link provided in the email notification you receive after I post my answer. If you have not subscribe to this post, and are not receiving email notifications…. you will need to view your profile, and when viewing your profile click “questions”. There you will see a list of questions you have submitted. Your profile can be accessed only while you are logged on, by using the menu in the upper left sidebar “User Settings –> Profile”

( at October 17, 2017 8:06 am)
1
Private answer

New features have been enabled in Thinkorswim which provide fully automated round trip trades. Meaning we can now automate the entry and the exit and we can daisy-chain multiple stages within the order sequence so that multiple round trip trades can be accomplished automatically. In addition to this, we can save these orders as an order templates so they can be reused with very little effort.

Check the following video for the full details:

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

 

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on April 18, 2022 1:38 pm
0
Private answer

Very good idea to include a screenshot with this. That helps to me everything perfectly clear. From your code I can immediately see a problem. Not sure if it’s the only problem. But to a programers eyes it jumps off the screen and smacks you in the face.

You have ‘def LBB = ….’ and ‘def Midline = …..’

Then when you try to build your condition you place the LBB and Midline inside double quotes. Now I would not be the least bit surprised the conditional order wizard actually did that. So don’t panic if you didn’t intend that to happen. You simply need to remove the double quotes from those variable names.

def signal = close is greater than or equal to UBB;
def exit = close is less than or equal to Midline;

That will correct the error: “Expected Double”

The ATR trailing stop uses recursion and is not supported by conditional orders. There is no way to write a trailing stop like that without using recursion. So it is no possible to find a ‘similar study’ that will work with conditional orders.

You had additional questions.

This code is not for a Study, it is for a Strategy. Those are two completely different things. I see from your screenshot you are trying to add this code to a new custom Study. The AddOrder() functions will NOT work for a Study. You must create a new custom Strategy. Go back and review the video until you understand the difference and how to create a Strategy instead of a Study.

Yes, each time you enter a conditional order it will have to be recreated. They do not auto-generate after execution.

The code should create orders based on the criteria you listed.

 

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on October 17, 2017 10:27 am
0
Private answer

Hi Pete,

Inspired by your think or swim strategy tutorial, I wrote a simple ATR strategy to backtest the data. (I understand I can’t do conditional orders based on ATR trailing stop.)

 

But when I checked the buy and sell signals on chart, I found a lot of slippages compared to do orders just based on ATR trailing stop.

As you can see in my screenshot, orders based on ATR should be at white arrow, but it signal won’t pop until red arrow.

Can I know if there is a way to fix it, so I can get correct backtesting report? Also, can I know have you tried to do automated trading on Tradestation based on ATR trailing and how does that works out? (I’m considering switching to tradestation, if tos doesn’t support ATRtrailing conditional order at all.)

Thank you for your help!!

Best regards,

Daisy

Attachments:
Marked as spam
Posted by (Questions: 1, Answers: 2)
Answered on October 24, 2017 11:40 am
0

First, what you are experiencing here is an alignment problem. The following post may help you understand how to align things correctly. It will also provide you the tools needed to experiment on your own: https://www.hahn-tech.com/ans/parablic-sar-signal-not-firing-in-tos-strategy/

About the alignment issue. The AddOrder() statement is checking the current bar for a signal. If the current bar contains a true condition, the AddOrder executes the order on the NEXT bar. So in order to get the PSAR to execute on the correct bar, we need to check if the condition is true in the next bar to the right. So something like condition2[-1].

However there is another alignment issue, price. Because the PSAR is designed to be traded using a trailing stop, you need to set the trade price to one tick beyond the previous bar’s PSAR value. Confusing? YES! Sorry, but you have picked the very worst indicator upon which to practice building strategies.

TradeStation does indeed support the ATR for both strategies as well as auto-trading. However the development of strategies in TradeStation is far more complex than on Thinkorswim. I have built a strategy on TradeStation that utilizes the PSAR. That was a custom project so I am not at liberty to share any details.

( at October 24, 2017 12:26 pm)