Category Archives: Uncategorized

Detecting Flags In Intraday Charts

The AIQ code based on Markos Katsanos’ article in Stocks & Commodities magazine, “Detecting Flags In Intraday Charts,” is provided at www.TradersEdgeSystems.com/traderstips.htm, and is also shown here:

!DETECTING FLAGS IN INTRADAY CHARTS

!Author: Markos Katsanos, TASC December 2014

!Coded by: Richard Denning 10/18/14



!USER DEFINED FUNCTIONS:

C is [close].

Name is description().



!COMPLETED FLAG PATTERN:

FLAG is [Flag].

FLAG_breakoutup if FLAG > 0.

FLAG_breakoutdn if FLAG < 0.



!EMERGING FLAG PATTERN:

e_FLAG is [eFLAG].

e_FLAGup if e_FLAG > 0.

e_FLAGdn if e_FLAG < 0.



!REPORTS TO LIST ALL FLAG PATTERS:

ShowAllCompleted if C>0 and FLAG <> 0.

ShowAllEmerging if C>0 and e_FLAG <>0.

The AIQ program has a chart-pattern recognition module that operates only in daily mode. I am providing code to find both completed flag patterns and also emerging flag patterns.
In Figure 10, I show a chart of G-III Apparel Group Ltd., which shows a flag pattern completed on June 25, 2014 (green up arrow), when the price broke above the down-sloping flag top. Although the volume was above average on the breakout, the follow through was lacking.
Sample Chart

FIGURE 10: AIQ. This sample chart shows G-III Apparel Group Ltd. (GIII) with a completed flag pattern (indicated by the green up arrow).
Note that I did not code exits for the pattern, as the built-in exits can be used to experiment with the flag pattern entry. Note also that the AIQ version of flags does not match exactly the intraday flags that are defined by Katsanos in his article.
—Richard Denning
info@TradersEdgeSystems.com
for AIQ Systems

It “Bean” a Good Time of Year

In case you were not aware of it, I have a “thing” for seasonal trends.  Certain commodities are especially well known for exhibiting “seasonal” – or “cyclical”, if you prefer – trends.  I’ve talked a bit recently about crude oil and energies.
Another market that fits the bill is Soybeans.  Specifically beans have a tendency to show strength between early February and mid-June.
The Test
Even more specifically we will look at soybean performance as follows:
*From the close on the 8th trading day of February through the close on the 15th trading day of June since 1978.
Technical Note: The data that I am using or this test is based on a “continuous” contract which strings together the “front month” (i.e., most heavily traded) over time.  Essentially this data base simply captures the dollar value of the daily price change for the “front month” soybean futures contract and strings them together.
Also, commodity pricing and contract values can cause one to have a headache. To wit: Soybean futures contract are priced in dollar and sense for 50,000 bushels of soybeans.  So each $0.01 (one cent) move in the price of a bean contract is worth $50.  If soybeans advance from $8.00 a bushel to $9.00 a bushel, then the value of the contract increases by $5,000 ($50 a cent x 100 cents). Is this commodity trading stuff exciting, or what?
Figure 1 displays the July 2014 Soybean contract.
beans 
Figure 1 – July 2014 Soybeans
The good news is that if a trader had bought soybeans in February 2014 and sold them in June 2014 he would have made a nice profit.  The bad news – as you can see on the far right hand side of the chart starting in around late May – is that he made a lot more money before giving a good chunk back in early July.
And this raises an important point: No one is suggesting that this be used as a mechanical approach to trading.  Well, OK, not unless you can answer “Yes” to the following three questions:
  1. Are you already ridiculously wealthy?
  2. Do you understand the meaning of the phrase “small lot size”?
  3. Do you know how to place a stop-loss order?
If you can answer “Yes” to the three questions above you are free to trade this method mechanically (although for the record I am not making a recommendation here, just highlighting an “interesting” trend).
Everybody else – well at least anyone else who is inclined to and willing to trade soybean futures – might consider the idea of looking for buying opportunities within this favorable time frame, rather than simply buying and holding.
Still, to get the idea of how useful this information might be let’s go back to our mechanical approach and consider…..
The Results
Figure 2 displays the (hypothetical) equity curve generated by holding a long position of 1 contract of soybeans during the seasonally favorable February into June period since 1978.
beans1
Figure 2 – Equity curve of long 1 soybean contract during seasonally favorable period
Figure 3 displays the year-by-year results.  I need to repeat here that these numbers were generated by buying March soybeans, then selling that contract in late February and buying the May contract and then selling the May contract in late April and buying the July contract (no seriously, is this commodity trading stuff exciting, or what?).
So I make no claim that these numbers are exactly what a trader would have experienced in real-time trading.  Also, there is no slippage or commissions deducted.  The purpose of this exercise is not so much to highlight the “raw dollars” but rather the fairly consistent persistence of the favorable trend within the annual time frame.
End of Period (YYMMDD) $+(-) Cumulative
0
780621 $5,813 $5,813
790621 $4,438 $10,250
800620 ($1,375) $8,875
810619 ($1,288) $7,588
820621 $119 $7,706
830621 $769 $8,475
840621 $5,150 $13,625
850621 ($63) $13,563
860620 $656 $14,219
870619 $3,600 $17,819
880621 $21,744 $39,563
890621 $306 $39,869
900621 $1,994 $41,863
910621 ($244) $41,619
920619 $1,713 $43,331
930621 $2,650 $45,981
940621 ($75) $45,906
950621 $2,469 $48,375
960621 $3,781 $52,156
970620 $3,106 $55,263
980619 ($1,350) $53,913
990621 ($1,281) $52,631
621 ($238) $52,394
10621 $463 $52,856
20621 $3,006 $55,863
30620 $3,294 $59,156
40622 $2,544 $61,700
50621 $10,919 $72,619
60621 $363 $72,981
70621 $3,856 $76,838
80620 $11,200 $88,038
90619 $10,050 $98,088
100621 $1,288 $99,375
110621 ($4,163) $95,213
120621 $10,475 $105,688
130621 ($125) $105,563
140620 $4,638 $110,200
Figure 3 – Soybeans (approximate) Year-by-Year during Feb-June seasonally favorable period (1978-2015); Includes roll overs from one contract month to another along the way
For the record, during the seasonally favorable period for soybeans:
*Up 27 times (73% of the time)
*Down 10 times (27% of the time)
*Average gain during Up years = +$4,459
*Average loss during Down years = -$1,020
*Two biggest Up years = +$21,744 (1988) and +11,200 (2008)
*Two biggest Down years = -$4,162 (2011) and -$1,375 (1980)
In a nutshell, this period has seen beans rise 2.7 times more often than they decline and the average win/loss ratio is almost 4.4-to-1.  These are values that we highly trained quantitative analyst types often refer to – using our highly technical quantitative jargon – as “pretty darn good.”
For the record the favorable period for beans in 2015 already started at the close of trading on 2/11/15.  During the first two days of this time frame March beans were up 12.75 cents (+$637.50). May beans were up 14 cents ($700) and July beans were up 14.25 cents ($712.50).
So far so good?  OK, I have to admit its a little early for that.
Summary
So should everyone be rushing to buy soybeans before the “train leaves the station.”  Surely not.  First off, let’s be honest – most people will never trade soybeans futures, nor should they. Still, as those who like to drop clichés every once in awhile to try to make themselves look smarter than they actually are (“Hi, my name is Jay”) just remember that “Knowledge is Power.”  For the record, at this point you now know more about how to make money trading soybeans than a lot of the people who currently do trade them.
One last note, although it is very thinly traded there is an ETF that tracks the price of Soybeans (ticker SOYB).  Those not inclined to trade futures contracts might take a look at buying shares of this ETF (did I mention that it is very thinly traded?)

Is It Time to Buy Energies?

A quick glance at Figure 1 is enough to scare the daylights out of most sane investors.
fsenx 1 
Figure 1 – SPDR Energy (ticker XLE) (Courtesy AIQ TradingExpert)
Thanks primarily to Saudi Arabia’s desire to “boost market share” by putting a lot of oil producers around the globe “out of business”, energy prices – and the prices of most stocks in any field that has anything to do with producing energy – have plummeted since Summer 2014.
Standard investment advice suggests that it is typically a mistake to attempt to “buy the bottom.”  Still there is some evidence that suggests that this may not be the worst time to consider looking at energy related stocks.  In fact to put it more accurately, evidence exists that suggests that now may be the very best time to consider looking at energy related stocks.
The Test
*The test below involves buying Fidelity Select Energy (ticker FSENX) on the last day of January and holding through the first day of May, each year since 1989.
*No stop-loss is involved in this test, simply buy-and-hold for roughly 3 months.
fsenx 2
Figure 2 – Growth of $1,000 invested in FSENX from las trading day of January through 1sttrading day of May (1989-2014)
Results
Figure 3 displays the results from each year using the “strategy” (if this can in fact be legitimately called a “strategy” – Q: Is this any way to trade energies?  A: Well, it’s one way…..).
fsenx 3
Figure 3 – Annual Results of Holding FSENX during “bullish” period
A few relevant notes:
-# times UP = 22
-#times DOWN = 4
-Annual Average %+(-) = +8.24%
-Worst Year (1997) = -13.47%
Other Choices
FSENX is obviously not the only choice these days.  Other possible candidates:
XLE           SPDR Energy
ERX           Direxion Russell 1000 Energy (x3 leveraged)
ENPIX        Profunds Energy
RYEIX        Rydex Energy
Summary
As a firm believer in the “The Trend is Your Friend” mantra, the prospect of buying energy stocks right here and now appears to be a bit “gutsy”. So the bottom line is this:
Does one put more faith in the belief that the current (down) trend will continue?  Or more faith in the seasonal historical tendency for energy stock to perform well over the next three months?
One can make a compelling argument that the worst is over for energy stocks and that a buying opportunity may be at hand.  Aggressive investors and traders should definitely be taking a look at the potential for energy stocks to bounce higher in the months ahead.  Just as importantly, anyone considering “taking the plunge” in energy stocks should be giving very careful consideration to how much capital they are willing to commit.
As always, I am not making any recommendations here, just telling you what I see.  I don’t think there is anything wrong with considering a position in energy stocks.  I do have a problem with making a huge bet in the face of an ongoing decline.  So just remember:
Jay’s Trading (and Life, for that Matter) Maxim #9:  There is an exceptionally fine line between courage and stupidity.  If you are not sure which side of the line you are on….step lightly.
Jay Kaeppel  
Chief Market Analyst at JayOnTheMarkets.com and AIQ TradingExpert Pro (http://www.aiq.com) client
http://jayonthemarkets.com/
Jay has published four books on futures, option and stock trading. He was Head Trader for a CTA from 1995 through 2003. As a computer programmer, he co-developed trading software that was voted “Best Option Trading System” six consecutive years by readers of Technical Analysis of Stocks and Commodities magazine. A featured speaker and instructor at live and on-line trading seminars, he has authored over 30 articles in Technical Analysis of Stocks and Commodities magazine, Active Trader magazine, Futures & Options magazine and on-line at www.Investopedia.com.

26% a Year in 3 Easy Trades?

Some trading strategies make intuitive sense.  Other trading strategies do not.  With some trading strategies it is possible to articulate some logical reason or reasons regarding why they might be expected to work well over time.  With others trading strategies, well, not so much.
Some trading strategies lend some confidence to a trader.  Others offer nothing but a ridiculously good historical track record – and require a trader to make a leap of faith.
For example, consider the following seasonal trading strategy.
The Rules
*On the last trading day of January buy Energies (FSESX)
*On the 1st trading day of May sell Energies
*On the 7th trading day of August buy Biotech (FBIOX)
*On the 9th trading day of September sell Biotech
*On the 19th trading day of October buy Retail (FSRPX)
*On the 20th trading day of November sell Retail
The rest of the time the portfolio is held in cash.  For the purposes of this test we will assume that the portfolio earns interest at a rate of 1% per year while in cash.
The Results
We will start our test on 12/31/1988.  But before we look at the results of our “system” (such as it is), let’s first create something to compare it to.  So for our “comparative result” we will split $1,000 evenly between:
Fidelity Select Energy Services (FSESX)
Fidelity Select Biotechnology (FBIOX)
Fidelity Select Retailing (FSRPX)
At the end of each year we will rebalance so that each year all three funds start with 1/3 of the portfolio.  The daily equity curve for this 3-fund buy-and-hold approach (with an annual rebalancing adjustment) appears in Figure 1.  
jotm20150206-01
Figure 1 – Growth of $1,000 in FSESX/FBIOX/FSRPX from 12/31/88 to 12/31/14 (rebalanced annually)
In a nutshell, $1,000 invested this way grew to $31,165 by the end of 2014.  This works out to about a +16.3% annual return, which in the technical financial jargon that we “highly trained quantitative analyst” types like to use, “ain’t too shabby.”  Of course a close look at Figure 1 reveals some pretty nasty swings along the way.  But hey, you “gotta take the good with the bad”, right?
Well, possibly “not.”
Now let’s look at the results generated following the switching rules listed earlier.  The growth of $1,000 invested using this method since the end of 1988 appears in Figure 2 (the blue line).  For comparison sake, the results we generated using the buy and hold approach is also displayed in Figure 2 (the red line). 
jotm20150206-02 
Figure 2 – Jay’s Seasonal System (blue) versus 3 fund buy-and-hold (red); 1988-2014
Despite the fact that you may not be a “highly trained quantitative analyst” type, chances are good that even your untrained eye can pick up on the fact that there is a “discrepancy” between the blue line and the red line in Figure 2.
For the record:
-$1,000 invested using the buy-and-hold approach detailed earlier grew to $31,165, or +3,016% (+16.3% annually).
-$1,000 invested using the seasonal trading rules listed earlier grew to $347,003, or +34,600% (+26.7% annually).
In still more highly technical financial jargon, these types of 11.5-to-1 discrepancies in return are what we refer to as “statistically significant.”
The annual results for both methods are listed in Figure 3.
jotm20150206-03F
figure 3 – Results: Jay’s Seasonal System versus Buy-and-Hold (thru 2/4/2015)
A few interesting numbers:
jotm20150206-04
Figure 4 – A few relevant comparative numbers
Other Choices
Fidelity sector funds are not the only choices.  Other possible candidates:
XLE           Energy Select Sector SPDR (ETF)
IBB           iShares Nasdaq Biotechnology (ETF)
XRT           SPDR S&P Retail (ETF)
OEPIX        ProFunds Oil Equipment (x1.5 leveraged)
BIPIX         ProFunds Biotechnology UltraSector (x1.5 leveraged)
CYPIX        Profunds Consumer Cyclical (x1.5 leveraged)
Summary
So should every investor simply stop what they’re doing now and just make these three trades every year and sit back and collect their 26%+ per year ad infinitum into the future?
Well it sounds good in theory, but of course the reality – as is the case with any seasonal trend – is that there is no guarantee that these trends will play out as consistently or as strongly in the future as they have in the past.
Which is where the “leap of faith” I mentioned earlier enters into the picture and leads most traders to stand on the “outside looking in.”  And maybe that is the wise thing to do.
Still, 26% is 26%.  Or to quote the immortal words of Glenn Frey: “The lure of easy money – it’s got a very strong appeal.”
Jay Kaeppel  
Chief Market Analyst at JayOnTheMarkets.com and AIQ TradingExpert Pro (http://www.aiq.com) client
http://jayonthemarkets.com/
Jay has published four books on futures, option and stock trading. He was Head Trader for a CTA from 1995 through 2003. As a computer programmer, he co-developed trading software that was voted “Best Option Trading System” six consecutive years by readers of Technical Analysis of Stocks and Commodities magazine. A featured speaker and instructor at live and on-line trading seminars, he has authored over 30 articles in Technical Analysis of Stocks and Commodities magazine, Active Trader magazine, Futures & Options magazine and on-line at www.Investopedia.com.

A Time for Crude and a Time, um, Not for Crude?

I like to think of myself as a creative, independent thinker.  Of course I’d also like to think of myself as handsome, charming and witty and look how that’s worked out.  But I digress.  Anyway, on my Twitter feed last week I posted a link to a piece from Stock Trader’ Almanac regarding a terrific seasonal trend in crude oil. Let’s take a closer look at what the boy’s at the Stock Trader’s Almanac lab uncovered.
The Stock Trader’s Almanac Crude Oil Seasonal Trend
The seasonal trend highlighted in the link to STA points out the fact that crude oil trends to be bullish for 60 trading days starting on February 13th (or the closest trading day to it).  As we will see in a moment, the results are compelling.  What is even more interesting is to compare the results generated by holding a long position in crude oil (or a crude oil ETF) during this time period to the results generated by holding a long position in crude oil all of the rest of the year.
The Test
For the record, the historical data that I use for crude oil futures is based on  a “continuous contract” (which basically strings together the daily price change for the currently most active contract at any given point in time), so they may not exactly reflect what a real trader might have experienced in real-time trading.  But they will be close.  And the point of this exercise is not really the “raw” returns but the “relative” returns of the “bullish” period versus “all other” periods.
So for our test:
*Bullish Period
Starts at the close of trading on the last trading day prior to February 13th each year, and lasts for 60 trading days.
*Bearish Period
Starts at the end of the 60 day period described above and lasts until the close of trading on the last trading day prior to February 13th the next year.
The Results
Figure 1 displays the growth of equity achieved by holding a long position in crude oil futures (a $1 move in the price of crude oil equals $1,000 change in the value of the futures contract) during the bullish period (blue line) versus holding a long position in crude oil futures during the bearish period (red line) since April 5th, 1983 (when crude oil futures starting trading).
cl 1
Figure 1 – $ +(-) for crude during bullish period (blue line) versus bearish period (red line); 4/5/1983 through 1/16/2014
For the record:
-During the “bullish” period crude oil futures gained roughly +$106,000.
-During the “bearish” period crude oil futures lost roughly (-$88,000)
Using ETFs instead of Futures
While the numbers above are compelling, let’s be honest, the vast majority of traders will never trade a crude oil futures contract (and in reality that is probably a good thing given the dollars and risks involved).  So what about using an ETF that tracks the price of crude oil?
The most heavily traded crude oil ETF is ticker USO.  Now I don’t wish to go into details but USO has had some – how shall I say this, um, performance issues – due to the way its portfolio is configured (i.e., it holds several months of futures contracts however, due to “contango” – whereby the farther out contracts trade at a higher price than the closer months – its share price has tended to lag the price of crude oil, particularly in up markets and, oh never mind.  If you want to know more Google “contango and uso”).
Still, the results generated by this seasonal trend via USO are pretty compelling. Figure 2 displays the growth of $1,000 fully invested in USO only during the bullish seasonal period (blue line) versus $1,000 fully invested in USO only during the bearish seasonal period (red line) since USO started trading on 4/10/2006.
cl 2
Figure 2 – Growth of $1,000 invested in ETF ticker USO during bullish period (blue line) versus bearish period (red line); 4/10/2006 through 1/16/2014
For the record:
-During the “bullish” period, $1,000 in USO grew to $1,861 (+86.1%)
-During the “bearish” period, $1,000 in USO declined to $146 (-85.4%)
These types of stark contrasts are what we “quantitative analyst types” refer to as “statistically significant.”
Summary
So does it make sense to simply buy and hold crude oil futures during the bullish period and to sell short during the bearish periods? Probably not.  For the record I am not advocating this as a standalone strategy. A closer look at Figures 1 and 2 reminds us that large unexpected moves can and will happen regardless of what the “seasonals” are suggesting “should” happen.  And as always, there is never any guarantee that the bullish phase will see higher prices nor that the bearish phase will see lower prices.
Probably a better way to use this information is to given the bullish case the benefit of the doubt during the bullish phase and vice versa.  To wit, should crude oil show signs of bottoming out and/or attempting to rally starting around mid-February, aggressive traders might do well to look for ways to play the bullish side.
Jay Kaeppel  
Chief Market Analyst at JayOnTheMarkets.com and AIQ TradingExpert Pro (http://www.aiq.com) client
http://jayonthemarkets.com/
Jay has published four books on futures, option and stock trading. He was Head Trader for a CTA from 1995 through 2003. As a computer programmer, he co-developed trading software that was voted “Best Option Trading System” six consecutive years by readers of Technical Analysis of Stocks and Commodities magazine. A featured speaker and instructor at live and on-line trading seminars, he has authored over 30 articles in Technical Analysis of Stocks and Commodities magazine, Active Trader magazine, Futures & Options magazine and on-line at www.Investopedia.com.