Archive for April, 2009

Swing High / Swing Low Indicator for Think or Swim

April 29, 2009

Update 2-18-10: v3–Added optional lines for plotting after the swing points:

As part of some work I have been doing, I needed a way to identify swing highs and swing lows. What is a swing high / low? It depends on your definition, but basically a swing high is the highest high looking a few bars back and a few bars forward. A swing low is the lowest low looking a few back and a few forward. The more bars you include in the series, the more significant the swing, but the confirmation comes further from the actual swing point. Say you wanted to define a swing high as this:

A bar high that is higher than the highs of the two bars just before it AND higher than the highs of the two bars just after it.

The thinkscript code might look like this:

Def swinghigh = if high > high[1] and high > high[2] and high > high[-1] and high > high[-2] then 1 else 0;

The code for a swing low is similar. This method is a pain because it requires you to hard code the swing period. If you want to change to a different number of bars, you have to modify the source code. Note that the confirmation of a swing point does not come until 2 bars after the swing high in this case. If you wanted to extend the swing check to 3 bars before and after, you would add the checks for a high > high[3] and high > high [-3]. The resulting swing will be more significant, but the signal comes 3 bars after the fact.

To plot the swing high you could do something like this:

Plot sh = if swinghigh then high else double.nan;
sh.setstyle(curve.points);

This would paint a dot on all the swing highs, and nothing everywhere else. The code for swing lows is similar. So now you know how to create your own swing high / swing low indicator. Free education; you provide the sweat equity. If you have any questions on making your own, leave a comment and I’ll be glad to help out!

I spent a couple of hours last night figuring out how to make the indicator generalized, meaning that you can input any number of bars to define your swing period, and the code finds the highs and lows for you without modding the indicator source code. This makes it easier to change on the fly for backtesting or responding to market volatility. Here’s what it looks like:

2009-04-29-tos_charts_pro_swingpoints1

My pain + my brain = your gain! Become a donor and you can download my complete generalized swing point script file, ready to be imported into Think Desktop. This is part of my new “Teach for free, Work for fee” philosophy. If you donate, be sure to email me and let me know what you donated for so I can send it to you! All my files (many for free and some for donors only, including the Swing Points) are at my Google site: http://sites.google.com/site/prospectus/welcome

Teach For Free, Work For Fee

April 28, 2009

I’ve spent a lot of time thinking about how best to deal with offering free vs. paid content. I have been deeply conflicted right down the middle. What, Prospectus conflicted and unable to decide? Shocker. ๐Ÿ˜‰ I think I’ve come to a decision on how I am going to structure my future work and this blog: I will teach for free, and work for fee.

The Case for Free Content: “Pay It Forward”, or “You Filthy Hypocrite”

I am the ultimate bootstrap trader. My accounts have always been small, and I have tried to learn part-time and mostly through self-study. Though I have bought a few books (from gift cards, natch), most of my learning has been done through the internet–through the blogs of traders, trader chat rooms, twitter, and email exchanges with successful traders. All of this teaching been freely shared by the teachers and traders. I don’t believe I have ever paid for a tool, information service, or anything trading related (other than the books). In my beginning, I didn’t want to blow my account equity paying for an expensive service or tool if I couldn’t even be net profitable with my meager account. There’s something to that, but I think there is a place for paying for education and tools. The hard part is in finding one that is worth it before you cough up the money.

Anyway, now that I have some skills and knowledge that could be of value to newer traders, I want to give back. I would be nowhere without so many traders that have helped me, offered advice, kicked my ass when I needed it, and put work into writing and teaching without any compensation from me for it. I want to pay that forward, and continue to offer teaching, tutorials, articles, advice, and help to any trader who wants to learn something. I’m no guru, but 5 years experience with the markets has given me some insight.

The other angle is that if I learned for free from others (free from cost, but not free from my own effort and time, of course) and then turned around and locked down my stuff and demanded a subscription fee, I would be quite the hypocrite. I am too idealistic for my own good, and it shows up in many ways; this is one way. All of these things support my wish to teach others and give back for what I have received. I have released my scripts and tools thus far with the source code included and unlocked, precisely so that others can learn from it and make something of their own if they desire. I debated that, but I didn’t feel right about locking it up. I am a natural teacher, and I don’t think that will ever change.

The Case for Paid Content: “Galt’s Gulch”, or “Get Out of the Rat Race”

The flipside is that I DO have skills that are of value to some. I am able to create tools that can help people make money, refine their trading systems, and the like. My time is valuable to me, and I want to be compensated for it. Further, when someone sends you some money for your work, whether it’s $1 or $1000, it is gratifying. It means they really find it useful and valuable to them, which is success to me.

In the novel “Atlas Shrugged”, when the protagonists went to “Galt’s Gulch”, a secret society of capitalist producers and achievers, they paid each other for their services (in gold, of course). No man (or woman) tried to get more than they deserved for their labors or products, and no person asked for less than they were worth. It was the ultimate meritocracy, where money equaled value, quite unlike our society today. Here comes the idealist again: I admire this sentiment and try to reproduce it today. You may notice some links in my blog roll and references to others who have similar blogs and service offerings as myself. I may be crazy, but I believe that the best product and producer should serve the marketplace! I admire talent and ability, even if it is in direct competition with myself. I believe that people will find value in my own skills if it is there. Maybe that is naive, but that’s where I stand.

Finally, I wish to move to trading full-time. Having other forms of income (like paid content) can help to make this a reality. Further, I have come to the point where I feel the need to pay for better tools and education. I want to use Tradestation (fee) or Ninja Trader (free unless you trade). I love what Richard is doing with EOTPro, and want to subscribe to their indicators. My 9 year old PIII Dell laptop is not able to run either of these systems with only 256MB of ram. It gags on Think Desktop as it is! So all of these reasons support my desire for pay for my work.

The Verdict: “Teach For Free, Work For Fee”, or “Idealism Meets Reality”

After much deliberation and thought, I have come to the following decision:

Anything I do that promotes education, that teaches concepts or experiences, that helps newer traders learn to do something for themselves, I will continue to offer freely.

Anything I do that involves my labor purely for the use of one person, that allows them to directly make money in trading, that is a use of my skills in place of their own efforts, will be reserved for donors only or have a fee attached.

This fits within the framework I have laid out, and I believe is a fair solution both for me and for readers of my blog and users of my work. Anything I have previously released will remain open and free. I won’t have a members-only section of my blog. I also hate “free-then-paid” bait-and-switch marketing, so I want no part of it and will not work that way. The work I do will either be in the free camp or the paid camp; never the twain shall meet.

Thanks for reading, I hope you learn something from my blog, and if something is valuable to you or you would like me to do some work for you, please donate or contact me. ๐Ÿ™‚

What Would Jesus Trade? (WWJT)

April 21, 2009

Disclaimer: This article applies to myself probably more than any trader that ever lived. I write in the hopes that it sinks in for me, and that helps out some readers.

Back in my Move the Markets days, “Mister White Folks” posted a quote from Elite Trader that is very wise, even though short on grammar and punctuation:

Yep donโ€™t fix what aint broke, chop will still kill this system as it will any other so if you are going to spend time on anything, spend it recognizing when to trade and when not to trade

In general, traders (including myself) make trading too hard by focusing first on things that are not important, and neglect the things that are most important. It seems we put way too much emphasis on the particulars of a system–the setups, stop management, profit targets, false positive signals, missed trades that didn’t set up according to the “rules” but went on to win anyway. This is all psychologically satisfying, but it doesn’t help your trading performance in any material way if you don’t have other more important things in place! Further, this effort would do more for your profitability if applied in a slightly different area than is typically done. Unfortunately, it is easier to fiddle with indicator parameters than it is to tackle the bigger problems.

There is a passage in the New Testament (non-Christians, atheists, agnostics, hedonists and satanists bear with me here…) that illustrates this principle very well. Jesus said to the corrupt spiritual leaders of the Jews:

Woe unto you, scribes and Pharisees, hypocrites! for ye pay tithe of mint and anise and cummin, and have omitted the weightier matters of the law, judgment, mercy, and faith: these ought ye to have done, and not to leave the other undone. Ye blind guides, which strain at a gnat, and swallow a camel.

The Pharisees were unjust to the people, ignored the spiritual laws of God and took advantage of their clerical status in society. However, they made many outward appearances of being righteous. While they left the things that were important to God undone, they justified themselves and pointed to their superficial outward acts as evidence of piousness. Jesus didn’t buy it.

As a trader, do you strain at a gnat? Do you spend all your research and energy to find the perfect indicator, the one right system that gives you 100% wins and no losses? The one that catches every possible winning trade no matter what the situation? Do you constantly try to find THE system, the one that makes the most money, the best one?

Do you swallow a camel? Do you ignore position sizing? Do you take no thought for market volatility or the current environment? Do you leave money and risk management for later thought and action–or worse–no thought or action? Do you ignore the “black swan” that could come and take you out of business forever? Do you break your rules and blow your stops? Do you force trades on days where the market is totally stacked against your strategy, or the volume or volatility isn’t there?

Here’s the cold hard facts of life: Almost ANY trend-following system (channel breakouts, MA crossovers and so on) will do well in a trending market. Almost ANY trend-following system will get whipsawed to death in a non-trending market, whether active and choppy or dead and listless. Conversely, almost ANY range-bound system (mean reversion, oscillators, overbought/oversold indicators, etc.) will do well in a non-trending market. Almost ANY range-bound system will get killed in a trending market as you keep fading the strong move and dying a death by 1000 cuts. The systems work well when the environment is right. If they fail, it’s because YOU failed to implement the correct strategy. It’s not because your stochastic was too fast or slow, or because your pivot point used 24 hour data instead of market hours only data. After personal discipline and psychology, the largest part of the battle is as the Elite Trader quote said: Recognizing when to trade and when not to trade.

So, to speak to my carefully crafted, eye-catching, straw-grasping post theme–What Would Jesus Trade? Going by the scripture passage above, he’d ignore the gnats and quit chewing on a camel. He’d fulfill the weightier matters, and leave the less important ones undone. He’d trade a system that explicitly took into consideration what I consider the weightier matters of trading:

1. Personal Discipline
2. Risk Management
3. Position Sizing
4. Market Environment

If you are not disciplined, the market will pistol whip you and take your money. If you put 100% of your equity in an overnight hold of FAZ, you are about to meet Mr. Risk. If your trade size is too big for your account, your days are numbered. And if you don’t have a way to identify what the market environment is, and when to trade and when to sit out, then no amount of clever backtesting, indicators, statistics, or even the Holy Grail is going to make you win. So quit looking for all that other junk, quit wringing your hands over the perfect system, and concentrate on what the market environment is! It’s the way to the REAL Holy Grail ๐Ÿ™‚

I am going to define some VERY simple systems to use as baseline strategies for examining this kind of idea–one for trending markets and one for range-bound markets. I will do some research into how to identify the market environments that we may be in, and then I will use these baseline systems to see how they do against how I define the market environment. This should be 90% of the battle. Only after these things are in place will I personally do any more messing around with indicator parameters or new fancy ways of looking at price data. Stay tuned!

Sponsored Indicator: DaVinci Trade Rate

April 16, 2009

I was commissioned to create an indicator for a donor. After this indicator was developed, the donor generously allowed me to share it with the blog at large.

The sponsor is DaVinci Trading. When they have a website, I will post a link, but for now, they just have a name. ๐Ÿ™‚ As this is a sponsored indicator, please include the full name and source code (including the credits) if you share this script with anyone. Thanks!

The DaVinci Trade Rate is designed to track trade speed on tick charts. Here’s a picture of it in action:

2009-04-16-tos_charts_thumb1

This is a 133 tick chart, so each candle is made up of 133 ticks on the tape. The DaVinci Trade Rate is showing a 3 bar exponential average of the speed of each bar, in bars per minute. As an example:

If a bar opened, and then 10 seconds later a new bar opened, the first bar traded at a rate of 6 bars per minute: 60 seconds per minute / 10 seconds per bar = 6 bars per minute.

Then, an exponential average of these speeds is calculated to smooth out the one-off spikes. (Default is 3; If you put in a period of 1, you get the actual calculations with no averaging.) There is also an option in the indicator to watch the volume rate per minute instead of just bar rate. If you want to see both, put the indicator on a chart twice and set each to a different setting. Green and red colors correspond to the candle color (up or down), while yellow indicates speed below the threshold value.

The theory of how to use this (so far) is two fold:

1. In times where the trade rate / volume rate is very slow, trade is likely to be choppy and erratic. If you set the threshold value to what you consider to be the minimum speed for your timeframe, then when the speed is below that value it helps to filter out times when the markets are likely to be dead and drifting.

2. If you set the threshold higher, when a large spike in trade rate / volume rate is seen, this can indicate either the start of a new trend, or the climax of an old trend depending on the context.

Look again at the summary plot above. See where the speed is yellow and getting slower, then POW! Huge green spike. The yellow shows trading slowing down as we approached the (then) high of the day. The spike happened as we plowed through it, and price fell back down. It seems that buy stops got run, and then new shorts piled on. It turns out that this was a great place to initiate a short position–to fade the spike. It was an extremely high rate-of-liquidity point, both in number of trades and volume. It didn’t turn out to be the high of the day, but it was a swing high.

This can be a bit subjective, but I noted 7 spikes in the DaVinci Trade Rate from today, indicated by grey ovals on this chart of the NQ:

2009-04-16-tos_charts

You can see how most spikes indicated a local top or bottom. The spike near 9:45 CT was a bit early, but it was also sloppy, with a gradual increase first rather than an extreme spike. Another near 13:15 CT was not confirmed by the volume, but I don’t know yet if that is important. The last one during casino hour at the end of the day actually indicated a breakdown, at least for a few minutes. This thing probably goes haywire in the first and the last half hour of trade, so I wouldn’t trade from it then anyway. Note that 15:00 CT is the market close, but the futures trade for another 15 minutes–with wild abandon today.

Please try this out and post any feedback or testing results you may have! I think that we all become better traders by sharing insights.

To get started with the DaVinci Trade Rate, you can download the script file at my Google site!

Thinkscript Strategy Report Tool

April 14, 2009

UPDATE 12-18-2009: I updated the tool to v2 after a TOS update broke it. Get the new version at the link below!

UPDATE 4-24-2009: I updated the Thinkscript Strategy Report file to make it backward compatible with at least Excel 2000. Download again if you have had problems!

In my earlier post, I covered how to create strategies using Thinkscript. I have developed a tool that can calculate some more useful statistics about your trading system results.

After adding a strategy set to a chart, you right-click on one of the signals and choose “show report”, as described in my tutorial. Think Desktop then gives you a report on your strategy results. You can save the summary as a .csv file. The information given in the report is net Profit/Loss and the trade that gave the maximum profit. This info isn’t really adequate to evaluate a trade strategy, at least in my book.

However, since most of the information is there, all it takes is a little Excel macro magic to import the .csv file and calculate important parameters, like win rate, loss rate, average win size, average loss size, largest win streak, largest loss streak, and system expectancy, or expected profit per trade over a very large number of samples.

Once you have this information, you can plug it into my Monte Carlo Trade System Simulator and stress test it. You can see how bad (or good) your results could be in the future if all of these parameters remain constant. Or, you can adjust them and get what-if scenarios. What if I have 10% fewer winners? What if my average profit is less than what I get in this small backtest?

Well, download the Thinkscript Strategy Report tool under Released Tools at my Google site to get started! As always, you have to enable macros for the tool to work.

This release is grovel-ware:
Pleasepleasepleeeeeeeeeaze !!! Oh, please!! I will always honor your memory! I swear!!

Please note: this tool only works if you use single position strategies! If you allow more than one entry per direction in the “Properties for all” preference screen, this tool will not work.