Archive for October, 2009

EOT Automation: It Shall Be Worth The Wait

October 28, 2009

EOT folks: The delays will be worth it. I’m making progress on being able to start and stop the Bill’s Arrows strategy without having to erase the day’s stored real-time values. You will have a separate form that comes up in Ninja when you initialize the strategy that will let you change parameters and arm and disarm the strategy on the fly. I can make the Ninja strategy create a form, like this:


But I’m still trying to figure out how to get the Ninja strategy to talk to the form it creates. I’m doing something wrong with the classes (any C# gurus out there?)

UPDATE: It’s working! I can arm and disarm the strategy from the form. The problem was that I didn’t link up the event handler to my button. Details, details. With this capability, I’ve solved the biggest automation problem. Now in the premarket, you initialize the strategy, F5 the chart to refresh the indicators so they are visually in sync with what the strategy is calculating against, and just leave it alone for the rest of the day.

Even though it “works” now, it still needs some more development. I want to try to integrate it into the chart toolbar if I can. Otherwise, the form only comes up when you initialize the strategy, so if you close it, you’re screwed. Plus, it doesn’t go away on it’s own, so I need to make it smart enough to not make a new one if an old one already exists. Also, I need to place all the operational parameters of the strategy on the form instead of just the “armed” switch. That way they can be adjusted without screwing up the saved real-time indicator values.

Thanks for your patience, it will be worth it in the end!

Another Lame Non-Update

October 23, 2009

So I’m still working on the EOT strategy. I’m trying to find a way to be able to stop and start it without erasing the saved data in the chart. EOT members know that you can’t mess with the chart or you’ll lose your volume info since it only works with real time data. If you have to reload the chart data (which you do whenever you change any chart parameters or say switch a strategy on or off) all data from earlier in the day is wiped out. I have a couple of solutions I’m investigating. My work had also been Hell last week with deadlines and computer crashes, and a root canal gone haywire. It’s not been my week.

Anyway, there’s the crappy status. Sorry I don’t have better news 😦

EOT Auto Trade Status

October 20, 2009

A quick status: I’ve received some guidance from Richard and made some changes. I’ve tested the strategy on lots of simulated data and it looks good. The strategy matches the displayed indicators as long as you refresh your chart (F5) as soon as you apply the strategy. I’ve sent out another update to my beta testers. If all goes well, I can release the first version tomorrow.

EOT Release Delayed

October 18, 2009

My apologies to EOT members. I’ve had some health issues at the end of last week that delayed my release of the Bill’s Arrows automation. I had a root canal and then lived through “The Tooth That Wouldn’t Die”, some sort of dental zombie horror B-movie. It’s finally subsiding, so I’m just getting back to normal.

Anyway, I want to assure that I don’t release something that’s not ready. I’ve got more testing to do. If you are an EOT member, and you are willing to be a beta tester (just run the thing on your chart in sim mode, no real money) and report back to me any bugs or other feedback, send me an email and I’ll get you a beta copy.

And Thinkscript crowd, I’ve got the three-line break project lined up next. I still love you guys too. 🙂

Tutorial: Creating Study Alerts and Auto-Trades in Think or Swim

October 14, 2009

In Think Desktop, it is possible to set up an alert triggered by certain indicators. It is also possible to automatically send trade orders when your alert fires. Here’s a tutorial on how to do both!

First, the bad news: As of the current time, you can only create alerts and send trades from selected built-in Think or Swim indicators. If you want to take your complicated custom study and fire alerts from it, you’re out of luck at the moment. Hopefully this will come in future releases from ToS.

To start, go to the MarketWatch –> Alerts tab in Think Desktop. Enter your ticker symbol in the field at top left, and click the “Study Alert” button (all screenshots that follow are linked to a larger, clearer version if you click them):


The screen that comes up is your Study Alert editor:


You’ll see several fields and options. Here’s what they do:

Trigger Type: Either “Study Value”, which uses one built-in indicator output, or “Complex Formula”, where you can calculate combinations of the built-in indicators. We’ll start with “Study Value”.

Study: Pull down list of available studies you can use.

Plot: Which output of the study to use (if there are more than one, like in the MACD indicator, that has MACD, the histogram value and the signal line)

Trigger If: Four choices here. At or Above, At or Below, Above, or Below.

Threshhold: This is the value that you are checking if your study is At or Above, Below, or whatever you chose for “Trigger If”. If the padlock is open, it will freely float until you create the alert, and if you click it closed, the value stays frozen.

Aggregation: This is the timeframe of plot that your study will be calculated against.

Parameters: Here you can change the input values of your study to whatever you want them to be.

There is also a Condition Preview plot in a lower pane, so you can see what you are specifying.

Here’s an example: Say I want to create an alert that tells me if the value of the Hull Moving Average (20) on a 5 minute chart is above a certain market price. I would choose that study from the pulldown:


Then choose the 5min aggregation:


The “Threshhold” value is unlocked, so it’s choosing the current floating price of the ES futures. If that’s the level you want, you’re good. If not, change it to what you want to check against, and then click “Create Alert” in the bottom right corner. Your alert is created. Since the value of that Hull MA was above the ES price when I created the alert, my alert triggers immediately, and I see the pop-up and hear a sound:


In this example, the outcome of the study alert was compared to some constant value. This is great if you want to check if RSI(10) is above 80, for example, or if the market price reaches some level you have in mind. What if you want to check something more complex, like adding two indicators together, like $ADVN + $DECN? Then when you create your alert, you select “Complex Formula” from the “Trigger Type” dropdown:


You’ll notice the fields have changed. Now you have a Thinkscript code window instead of the study dropdown. Here you can write code, but you’re basically limited to a single “line” of Thinkscript. Imagine that your code window has an implicit “def studyalertvalue = “, and you are just adding the rest of the code. As before, there are only some of the studies available to you (same ones as there were for the “Study Value” option). You can see them in a dropdown if you check the “Show Tools Window” box. But the real shame is that once you set up your complex formula code, you can only compare the outcome to a constant value like before. So if you want to know something like if HullMovingAvg(5) is greater than HullMovingAvg(20), then you’re stuck. But before you jump off a bridge, know that all is not lost!! You can rewrite your equation algebraically to a form that will work.

In this example, we just go from:

If HullMovingAvg(5)>HullMovingAvg(20) then…


If HullMovingAvg(5)-HullMovingAvg(20)>0 then…

Those statements say exactly the same thing, mathematically. With the simple algebra, instead of comparing the two directly, we compare the difference to zero. Since zero is a constant, we can have both of our comparison variables be dynamically calculated and still work within the Think Desktop constraint. And you thought you would never use algebra after high school! 😉

So say we want to check for HMA(5) above HMA(20) on a 15 minute chart. Here’s what the example in this case would look like:


After you set that up, click “Create Alert” as before. Once your alert is set up, you’ll get notified when the conditions trigger. You can see your alert patiently waiting in the alerts window:


Note that each alert is a one-shot deal. Once it fires, you have to go set it up again if you want to be notified next time. Now you can stop there with alerts only, or move on to the auto-trading realm… If you dare!

***SPOOKY CATASTROPHIC LOSSES WARNING*** Before you let any computer take trades for you in a real money account, make SURE that you have tested it using a paper money account first, and that you understand what your alert code is doing!! Then read this warning again, and again.

To choose to send an order when your alert fires, you first have to create the study alert through the process above. After your alert is created, you go to the Trade tab. Then you need to create an order, but DO NOT submit it yet! Example: If I wanted my HMA study alert to send an order to go long ES, I go to the trade tab and click the ask price (step 1). A buy order is created (I could click the bid to create a sell order instead). The next step is to left-click on the “gear” icon in the order entry pane (step 2):


After you do that, you’ll see the “Order Rules” window. Here is where you can place conditions on when your order is sent. In the top frame, you can choose whether it’s a buy or sell, the quantity, and whether it is a day order or GTC. The lower frame is where we set up the study alert trade. There are options to put in a time to submit the order, a time to cancel it, and then the paydirt: “Submit at Specified Market Condition”:


First, click in the symbol column. The trade instrument is automatically added. Then you click in the method column, choose “Study”, and then choose the study alert you created previously (in our example it is the HMA option on top). After you choose the alert to use, then VERIFY that what you have told the computer to do is actually what you wanted the computer to do:


Then click “OK”. The order is still sitting there, waiting to be sent. Click “Confirm and Send”, and go through the steps to enter the trade as any normal trade. Once it’s accepted, it will show in your order book as a working order, with the status “WAIT COND”:


It will wait there until the order expires (if a day order for example), or until the alert fires. Once the alert fires, then the trade goes live and is executed according to the rules you set up. As before, once the alert trade fires, you must go set it all up again if you want to trade the next signal. The alert is held on the ToS servers, so you don’t even have to be logged in–it’s always working. However, be careful–these alerts I entered on ES actually fired in the after market and I was “filled”, so be aware of the time in force of your order or you could get filled outside of market hours, depending on what it is (options, stocks, futures, forex, etc). Make sure you test before doing anything live!

Congratulations! You are now auto-trading in Think or Swim! If this tutorial is useful to you, and you make some sweet moolah off of a trade, please consider throwing me a piece of the action:

Leave a comment if you have any questions, tips or observations!