Category Archives: EDS

System Development Using Artificial Intelligence

The AIQ code based on Domenico D’Errico and Giovanni Trombetta’s article in August 2017 Stock & Commodities issue, “System Development Using Artificial Intelligence,” is shown here. You can also download the EDS file from here

Are humans or computers better at trading? This question has been around on many fronts since the era of punch cards, and as technology advances, you question whether machines have limits. It’s the same with trading, and here’s an algorithm that may shed some light on which performs better…

!ARTIFICAL INTELLIGENCE FOR SYSTEM DEVELOPMENT
!Authors: Domenico D'Errico & Giovanni Trombetta, TASC August 2017
!Coded by: Richard Denning, 6/08/2017
!www.TradersEdgeSystems.com

!INPUTS:
O is [open].
C is [close].
H is [high].
L is [low].
exitBars is 8.
exitBarsP is 6.
enterGap is -0.08.

!CODE:
AvgP is (O+C+H+L)/4.
MedP is (H+L)/2.
MedB is (O+C)/2.

AvgP1 is valresult(AvgP,1).
AvgP2 is valresult(AvgP,2).
AvgP3 is valresult(AvgP,3).

MedP1 is valresult(MedP,1).
MedP2 is valresult(MedP,2).
MedP3 is valresult(MedP,3).
MedP4 is valresult(MedP,4).

MedB1 is valresult(MedB,1).
MedB2 is valresult(MedB,2).
MedB3 is valresult(MedB,3).
MedB4 is valresult(MedB,4).

!ENTRY & EXIT RULESl
Gandalf if 
  (AvgP1exitBars-1)
 or ({position days}>=exitBars-1)
 or ({position days}>=exitBarsP-1 and (C-{position entry price}>0)).

EntryPr is min(val([low],1) + enterGap,[open]).

Buy if Gandalf and [low] <= EntryPr.

See Figure 10 for how to set up the pricing in a backtest.
Sample Chart

FIGURE 10: AIQ. This shows the EDS backtest settings for entry pricing.
—Richard Denning
info@TradersEdgeSystems.com
for AIQ Systems

A Simple Indicator for Traders

First the Bad News: There are no “magic bullets” when it comes to trading.  There are people in this industry who have literally tested somewhere in the range of six bazillion “indicators” – give or take (“Hi. My name is Jay”).  Every trend following indicator looks like a gold mine when it latches onto a huge trend and rides it (but not so much when it starts getting whipsawed).  And every overbought/oversold indicator looks like a gift from heaven from time to time when it somehow manages to peak (or valley) and then reverses right at a high (or low).  And then the next time the thing gets oversold the security in question just keeps plunging and the previously “amazingly accurate” indicator just gets more and more oversold.

Bottom line: what I am about to discuss is likely no better or worse than a lot of other indicators.  And it is no holy grail.  Still, I kinda like it – or whatever that is worth.

EDITORS NOTE an AIQ EDS file for this indicator with the 3 step rules outlined can be downloaded from here you will need to copy or save this file into your wintes32/eds strategies folder. Alternatively the code is available at the end of this article for copying and pasting into a new EDS file.

UpDays20

I call this indicator UpDays20 and I stole, er, learned it originally from Tom McClellan of McLellan Financial Publications.  My calculation may be slightly different because I wanted an indicator that can go both positive and negative.  For a given security look at its trading gains and losses over the latest 20 trading days.

UPDays20 = (Total # of Up days over the last 20 trading days) – 10

So if 10 of the last 20 trading days showed a gain then UpDays20 would read exactly 0.

If only 6 of the last 20 trading days showed a gain then UpDays20 would read -4

You get the idea (and proving once again that it “doesn’t have to be rocket science”).  As a “trading method” it is always advised that this indicator – like most all other indicators – NOT be used as a standalone approach to trading.  That being said, the way I follow this indicator is as follows.

Step 1) UpDays20 drops to at least -2

Step 2) UpDays20 rises 2 points from a low

Step 3) The security in question then rises above its high for the previous 2 trading days

It is preferable to follow this setup hen the security in question is above its 200-day moving average, but that is up to the trader to decide (the danger to using this with a security below its 200-day moving average is that it might just be in the middle of a freefall.  The upside is that counter trend rallies can be fast and furious – even if sometimes short-lived).

Again, there is nothing magic about these particular steps.  They are simply designed to do the following:

1) Identify an oversold condition

2) Wait for some of the selling pressure to abate

3) Wait for the security to show some sign of reversing to the upside

Like just about every other indicator/method, sometimes it is uncannily accurate and sometimes it is embarrassingly wrong (hence the reason experienced traders understand that capital allocation and risk management are far more important than the actually method you use to enter trades).

In this previous article (in Figures 3 and 4) I wrote about using this indicator with ticker TLT.  Figure 1 and 2 display the “buy” signals generated using the rules above for tickers IYT and GLD.

1Figure 1 – UpDays20 “Buy” Alerts for ticker IYT (Courtesy AIQ TradingExpert)

2Figure 2 – UpDays20 “Buy” Alerts for ticker GLD (Courtesy AIQ TradingExpert)

Are these signals good or bad?  That is in the eye of the beholder and not for me to say.  One big unanswered question is “when do you exit”?  That is beyond the scope of this “idea” article – however, “sell some at the first good profit and then use a trailing stop” looks like a decent approach to consider) but would have a profound effect on any actual trading results.

Some of the signals displayed in Figures 1 and 2 are obviously great, others are maybe not so hot.  Interestingly, some of the signals in Figure 1 and 2 that don’t look to timely at first blush actually offered a profitable opportunity to a trader who was inclined to take a quick profit. Again, how you allocate capital and when you exit with a profit and when you exit with a loss would likely have as much impact on results as the raw “buy” signals themselves.

Summary

No one should go out and start trying to trade tomorrow based on UpDays20.  No claim is being made that the steps detailed herein will result in profits nor even that this is a good way to trade.

But, hey, it’s one way.

Jay Kaeppel Chief Market Analyst at JayOnTheMarkets.com and AIQ TradingExpert Pro client.

Disclaimer:  The data presented herein were obtained from various third-party sources.  While I believe the data to be reliable, no representation is made as to, and no responsibility, warranty or liability is accepted for the accuracy or completeness of such information.  The information, opinions and ideas expressed herein are for informational and educational purposes only and do not constitute and should not be construed as investment advice, an advertisement or offering of investment advisory services, or an offer to sell or a solicitation to buy any security.

EDITORS NOTE an AIQ EDS file for this indicator with the 3 step rules outlined can be downloaded from here you will need to copy or save this file into your wintes32/eds strategies folder. Alternatively the code is available at the end of this article for copying and pasting into a new EDS file.

! UpDays20 – I call this indicator UpDays20. For a given security look at its trading gains and losses over the latest 20 trading days.

! UPDays20 = (Total # of Up days over the last 20 trading days) – 10

! So if 10 of the last 20 trading days showed a gain then UpDays20 would read exactly 0.

! If only 6 of the last 20 trading days showed a gain then UpDays20 would read -4

Upday if [close]&gt;val([close],1).

totalupdayslast20days is CountOf(upday,20).

updayindicator is totalupdayslast20days – 10.

! How to follow this indicator

! Step 1) UpDays20 drops to at least -2

! Step 2) UpDays20 rises 2 points from a low

! Step 3) The security in question then rises above its high for the previous 2 trading days

UpDays20rises2points if updayindicator&gt;valresult(updayindicator,1) and valresult(updayindicator,1)&gt;valresult(updayindicator,2).

updays20atminus2orlower if valresult(updayindicator,2)&lt;=-2.

closesabovehighof2priordays if [close]&gt;val([high],1) and [close]&gt;val([high],2).

Upsignal if UpDays20rises2points and updays20atminus2orlower and closesabovehighof2priordays.

Detecting Swings

The AIQ code based on Domenico D’Errico’s article in the May 2017 issue of Stocks & Commodities issue, “Detecting Swings,” is provided here.

I tested the author’s four systems using the NASDAQ 100 list of stocks on weekly bars, as did the author, from 3/16/2005 through 3/14/2017. Figure 7 shows the comparative metrics of the four systems using the four-week exit. The results were quite different than the author’s, probably due to a different test portfolio and also a 10-year test period rather than the author’s 20-year period. In addition, my test results show longs only, whereas the author’s results are the average of both the longs and shorts.

Sample Chart

FIGURE 7: AIQ. As coded in EDS, this shows the metrics for the author’s four systems run on NASDAQ 100 stocks (weekly bar data) over the period 3/16/2005 to 3/14/2007.

The Bollinger Band (Buy2) system showed the worst results, whereas the author’s results showed the Bollinger Band system as the best. The pivot system (Buy1) showed the best results, whereas the author’s results showed the pivot system as the worst. I am not showing here the comparative test results for the Sell1 thru Sell4 rules, as all showed an average loss over this test period.

!DECTECTING SWINGS
!Author: Domenico D'Errico, TASC May 2017
!Coded by: Richard Denning, 3/15/17
!www.TradersEdgeSystems.com

!Set to WEEKLY in properties

Low is  [low].
Low1  is valresult(Low,1).
Low2  is valresult(Low,2). 
High is [high].
High1  is valresult(High,1).
High2  is valresult(High,2). 
PivotLow if Low1 &lt; Low2  and Low1 &lt; Low.
PivotHigh if High1 &gt; High2  and High1 &gt; High.

Buy1 if  PivotLow.  
Sell1 if  PivotHigh.    

!Set parameter for bollinger bands to 12 with 2 sigma (weekly) in charts:
Buy2 if [close] &gt; [Lower BB] and valrule([close] &lt;= [Lower BB],1).
Sell2 if [close] &lt; [Upper BB] and valrule([close] &gt;= [Upper BB],1).

!Set parameter for Wilder RSI to 5 (weekly) in charts:
Buy3 if [RSI Wilder] &gt; 40 and valrule([RSI Wilder] &lt;= 40,1).
Sell3 if [RSI Wilder] &lt; 60 and valrule([RSI Wilder] &gt;= 60,1).

Buy4 if [RSI Wilder] &lt; 40  And Low &gt; Low1.
Sell4 if [RSI Wilder] &gt; 60  And High &lt; High1.    

Exit if {position days} &gt;= 4.

The code and EDS file can be downloaded from http://aiqsystems.com/detectingswings.EDS

—Richard Denning

info@TradersEdgeSystems.com

for AIQ Systems

Detecting Swings

The AIQ code based on Domenico D’Errico’s article in the May 2017 issue of Stoks Commodities, “Detecting Swings,” is provided below.

I tested the author’s four systems using the NASDAQ 100 list of stocks on weekly bars, as did the author, from 3/16/2005 through 3/14/2017. Figure 7 shows the comparative metrics of the four systems using the four-week exit. The results were quite different than the author’s, probably due to a different test portfolio and also a 10-year test period rather than the author’s 20-year period. In addition, my test results show longs only, whereas the author’s results are the average of both the longs and shorts.

Sample Chart
 
FIGURE 7: AIQ. As coded in EDS, this shows the metrics for the author’s four systems run on NASDAQ 100 stocks (weekly bar data) over the period 3/16/2005 to 3/14/2007.

The Bollinger Band (Buy2) system showed the worst results, whereas the author’s results showed the Bollinger Band system as the best. The pivot system (Buy1) showed the best results, whereas the author’s results showed the pivot system as the worst. I am not showing here the comparative test results for the Sell1 thru Sell4 rules, as all showed an average loss over this test period.

!DECTECTING SWINGS
!Author: Domenico D'Errico, TASC May 2017
!Coded by: Richard Denning, 3/15/17
!www.TradersEdgeSystems.com

!Set to WEEKLY in properties

Low is  [low].
Low1  is valresult(Low,1).
Low2  is valresult(Low,2). 
High is [high].
High1  is valresult(High,1).
High2  is valresult(High,2). 
PivotLow if Low1 < Low2  and Low1 < Low.
PivotHigh if High1 > High2  and High1 > High.

Buy1 if  PivotLow.  
Sell1 if  PivotHigh.    

!Set parameter for bollinger bands to 12 with 2 sigma (weekly) in charts:
Buy2 if [close] > [Lower BB] and valrule([close] <= [Lower BB],1).
Sell2 if [close] < [Upper BB] and valrule([close] >= [Upper BB],1).

!Set parameter for Wilder RSI to 5 (weekly) in charts:
Buy3 if [RSI Wilder] > 40 and valrule([RSI Wilder] <= 40,1).
Sell3 if [RSI Wilder] < 60 and valrule([RSI Wilder] >= 60,1).

Buy4 if [RSI Wilder] < 40  And Low > Low1.
Sell4 if [RSI Wilder] > 60  And High < High1.    

Exit if {position days} >= 4.
—Richard Denning
info@TradersEdgeSystems.com
for AIQ Systems
Editor note: The code and EDS file can be downloaded from http://aiqsystems.com/Detecting_Swings_TASC_May_2017.EDS

It’s Soon or Never for Bonds

There is great trepidation in the bond market these days. Most investors seem to have the “interest rates are sure to rise” mantra playing on auto loop in their head.  And this is not entirely unwarranted.  Given the historical tendency for bond yields to move in long, slow trends (20 years or more essentially in one direction is not uncommon), I for one am pretty confident in believing that interest rates will be higher 20 years from now than they are now.
But that is not the fear that is playing in people’s heads. The fear in people’s heads is that rates are rising soon (like immediately) and in a big way.  This however, may or may not prove to be the case.
Figure 1 displays a history of 10-year treasury yields through about 2012 (FYI 10-yr. yields are roughly in changed since that time).  Note the long-term nature of interest rate trends and that while there are “spikes” here and there, most major moves play out over time and not in “here today, sharply higher tomorrow” fashion.
1Figure 1 –
10-year treasury bond yields; 1900-2012(Courtesy: ObservationsandNotes.blogspot.com)
Also, you can see in Figure 2 – one can make a compelling argument that bond yields are not “officially rising”, at least not yet.
1
Figure 2 – Yields still “officially” in a downtrend
Bonds are Due to Bounce – But Will They?
One way to identify important turning points in any market is when a market doesn’t do something that it would normally be expected to do.  For example, here is a simple thought process:
1) The bond market is oversold
2) In the past 30 years, pretty much anytime it would get oversold a rally ensued
3) Therefore, bonds should rally soon
But will they – that is the question.  And in my opinion, the answer is important.
*If bonds rally soon (i.e., over the course of say the next several months) then “the status may still be quo”.
*If bonds do not rally soon, then it may be a sign that “things are changing”
Which Way Bonds?
Figures 3 and 4 below display ticker TLT (an ETF that tracks the long-term treasury bond) with an indicator I call UpDays20.  In this case we are looking at weekly bars and not daily bars, but the concept is the same.
UpDays20 is calculated by simply adding up all of the weeks that have showed a weekly gain over the past 20 weeks and then subtracting 10 (the AIQ TradingExpert Expert Design Studio code appears at the end of this article, after the disclaimer).
If 10 of the past 20 weeks have showed a weekly gain then the upDays20 indicator will read 0 (i.e., a total of 10 weeks were up minus 10 = 0).  If only 6 weeks showed a gain in the past 20 weeks then the UpDays20 indicator will read -4, etc.
What to look for: Typically (at least in the declining rate environment of recent decades) when UpDays20 rises by a value of 2 from a low of -2 or less, a decent rally in bonds has ensued.
For example, if UpDays20 falls to -4 then a rise to -2 or higher triggers a buy signal.  If it falls only as low as -3 then a rise to -1 or higher is required.  If it falls only as low as -2 then a rise to 0 or higher is required.
Figures 3 and 4 highlight signals since roughly 2004.
3
Figure 3 – Ticker TLT with UpDays20 weekly buy signals (2004-2010); (Courtesy AIQ TradingExpert)
4a
Figure 4 – Ticker TLT with UpDays20 weekly buy signals (2010-2017); (Courtesy AIQ TradingExpert)
As you can see in Figures 3 and 4, most of the signals highlighted were followed by at least a decent short-term rally.
In 2017, buy signals from the UpDays20 indicator occurred on 1/13 and 4/14.  TLT is up +0.3% since the 1/13 signal and down -1.4% since the 4/14 signal.
Summary
Either:
1) This is an excellent time to buy the long-term bond (looking for at least a short to intermediate term rally) as a rally is overdue
OR
2) The “times they may be a changing” for bonds
So keep an eye on TLT over the next several months.
Jay Kaeppel
Disclaimer:  The data presented herein were obtained from various third-party sources.  While I believe the data to be reliable, no representation is made as to, and no responsibility, warranty or liability is accepted for the accuracy or completeness of such information.  The information, opinions and ideas expressed herein are for informational and educational purposes only and do not constitute and should not be construed as investment advice, an advertisement or offering of investment advisory services, or an offer to sell or a solicitation to buy any security.
AIQ Expert Design Studio Code for UpDays20
Up1 if [close] > val([close],1).
Up2 if val([close],1) > val([close],2).
Up3 if val([close],2) > val([close],3).
Up4 if val([close],3) > val([close],4).
Up5 if val([close],4) > val([close],5).
Up6 if val([close],5) > val([close],6).
Up7 if val([close],6) > val([close],7).
Up8 if val([close],7) > val([close],8).
Up9 if val([close],8) > val([close],9).
Up10 if val([close],9) > val([close],10).
Up11 if val([close],10) > val([close],11).
Up12 if val([close],11) > val([close],12).
Up13 if val([close],12) > val([close],13).
Up14 if val([close],13) > val([close],14).
Up15 if val([close],14) > val([close],15).
Up16 if val([close],15) > val([close],16).
Up17 if val([close],16) > val([close],17).
Up18 if val([close],17) > val([close],18).
Up19 if val([close],18) > val([close],19).
Up20 if val([close],19) > val([close],20).
UpCount is (Up1+ Up2+Up3+Up4+Up5+Up6+Up7+Up8+Up9+Up10+Up11+Up12+Up13+Up14+Up15+Up16+Up17+Up18+Up19+Up20)-10.
You can also download the EDS file for this at this link http://aiqsystems.com/Its_Soon_or_Never_for_Bonds.EDS

Volume-Weighted Moving Average Breakouts

The AIQ code based on Ken Calhoun’s article in the February 2017 issue of Technical Analysis ofSTOCKS & COMMODITIES, “Volume-Weighted Moving Average Breakouts,” can be found at http://aiqsystems.com/Volume-Weighted-Moving-Average-Breakouts.EDS 
 
Please note that I tested the author’s system using the NASDAQ 100 list of stocks on daily bars rather than intraday bars from 12/31/2008 thru 2/10/2017. Figure 7 shows the resulting equity curve trading the author’s system with the cross-down exit. Figure 8 shows the ASA report for this test. The annualized return showed about a 17% return with a maximum drawdown of 19%.
Sample Chart

FIGURE 7: AIQ. Here are sample test results from the AIQ Portfolio Manager taking three signals per day and 10 concurrent positions maximum run on NASDAQ 100 stocks (daily bar data) over the period 12/31/08 to 2/10/07.
Sample Chart

FIGURE 8: AIQ. This shows the ASA report for the system, which shows the test metrics and settings.
The code and EDS file can be downloaded from http://aiqsystems.com/Volume-Weighted-Moving-Average-Breakouts.EDS , and is also shown below.
!Volume-Weighted Moving Average Breakouts
!Author: Ken Calhoun, TASC Apr 2017
!Coded by: Richard Denning 2/11/17
!www.TradersEdgeSystems.com

!INPUTS:
smaLen is 70.
vwmaLen is 50.

SMA is simpleavg([close],smaLen).
VWMA is sum([close]*[volume],vwmaLen)/sum([volume],vwmaLen).
HasData if hasdatafor(max(smaLen,vwmaLen)+10)>max(smaLen,vwmaLen).
Buy if SMA < VWMA and valrule(SMA > VWMA,1) and HasData.
Sell if SMA > VWMA.

rsVWMA is VWMA / valresult(VWMA,vwmaLen)-1.
rsSMA is SMA / valresult(SMA,smaLen)-1.
—Richard Denning
info@TradersEdgeSystems.com
for AIQ Systems

Exponential Standard Deviation Bands

The AIQ code based on Vitali Apirine’s article in the 2017 issue of Stocks & Commodities magazine, “Exponential Standard Deviation Bands”

Editor note: “Author Vitali Apirine presented a method intended to help traders see volatility while a stock is trending. These bands, while similar to Bollinger Bands, are calculated using exponential moving averages rather than simple moving averages. Like Bollinger Bands, they widen when volatility increases and narrow as volatility decreases. He suggests that the indicator can be used as a confirming indication along with other indicators such as the ADX. Here’s an AIQ Chart with the Upper, Lower and Middle Exponential SD added as custom indicators.”

 

 

To compare the exponential bands to Bollinger Bands, I created a trend-following trading system that trades long only according to the following rules:
  1. Buy when there is an uptrend and the close crosses over the upper band. An uptrend is in place when the middle band is higher than it was one bar ago.
  2. Sell when the low is less than the lower band.
Figure 8 shows the summary test results for taking all signals from the Bollinger Band system run on NASDAQ 100 stocks over the period 12/9/2000 to 12/09/2016. Figure 9 shows the summary test results for taking all signals from the exponential band system on NASDAQ 100 stocks over the same period. The exponential band system improved the average profit per trade while reducing the total number of trades.

Sample Chart

FIGURE 8: AIQ. Here are summary test results for taking all signals from the Bollinger Band system run on NASDAQ 100 stocks over the period 12/9/2000 to 12/09/2016.

Sample Chart

FIGURE 9: AIQ. Here are summary test results for taking all signals from the exponential band system run on NASDAQ 100 stocks over the period 12/9/2000 to 12/09/2016.
The EDS file can be downloaded from http://aiqsystems.com/EDS/Exponential_Standard_Deviation_Bands.EDS 
and is also shown here:
!Exponential Standard Deviation Bands
!Author: Vitali Apirine, TASC February 2017
!Coded by: Richard Denning 12/11/2016
!www.TradersEdgeSystems.com!INPUT:
xlen is 20.
numSD is 2.

!INDICATOR CODE:
ExpAvg is expavg([close],xlen).
Dev is [close] – ExpAvg.
DevSqr is Dev*Dev.
SumSqr is sum(DevSqr,xlen).
AvgSumSqr is SumSqr / xlen.
ExpSD is sqrt(AvgSumSqr).

!UPPER EXPONENTIAL SD BAND:
UpExpSD is ExpAvg + numSD*ExpSD.  !PLOT ON CHART

!LOWER EXPONENTIAL SD BAND:
DnExpSD is ExpAvg – numSD*ExpSD.   !PLOT ON CHART

!MIDDLE EXPONENTIAL SD BAND:
MidExpSD is ExpAvg.

!BOLLINGER BANDS FOR COMPARISON:
DnBB is [Lower BB].  !Lower Bollinger Band
UpBB is [Upper BB].  !Upper Bollinger Band
MidBB is simpleavg([close],xlen). !Middle Bollinger Band
!REPORT RULE TO DISPLAY VALUES:
ShowValures if 1.

!TRADING SYSTEM USING EXPPONENTIAL SD BANDS:
UpTrend if MidExpSD > valresult(MidExpSD,1).
BreakUp if [close] > UpExpSD.
BuyExpSD if UpTrend and BreakUp and valrule(Breakup=0,1).
ExitExpSD if [Low] < DnExpSD.  ! or UpTrend=0.

!TRADING SYSTEM USING BOLLINGER BANDS:
UpTrendBB if MidBB > valresult(MidBB,1).
BreakUpBB if [close] > UpBB.
BuyBB if UpTrendBB and BreakUpBB and valrule(BreakupBB=0,1).
ExitBB if [Low] < DnBB.  ! or UpTrend=0.

—Richard Denning
info@TradersEdgeSystems.com
for AIQ Systems

Chart Pattern Recognition – Lock in 2008 pricing 5 days remaining!

Why add Chart Pattern to your TradingExpert Pro? 

 
  • Over 3000 stocks tracked
  • 16 different patterns tracked
  • 6 gauges of each pattern's quality
  • Automatically generate report every night
  • Built in EDS file so you can backtest and add to your own strategy
  • Completed and emerging patterns
​​​​​​​
OR CALL AIQ SALES on 1-800-332-2999 or 775-832-2798
 
 LOCK in 2008 pricing
 

hfwacp7-13-16

 
If you order before July 31, 2016
you'll get the 2008 pricing!
 
 
OR CALL AIQ SALES on 1-800-332-2999 or 775-832-2798

Zero In On The MACD

The AIQ code based on Barbara Star’s article in May issue of Stocks and Commodities “Zero In On The MACD,” is provided at www.TradersEdgeSystems.com/traderstips.htm, and is also shown below.
Sample Chart
FIGURE 7: AIQ. Here is a sample chart of VIAB with MACDhist, the color bars, and the 34- and 55-bar EMAs.
Figure 7 shows the MACD histogram on a chart of Viacom (VIAB) with the color bars and the 34- and 55-bar exponential moving averages (EMA). Note that I did not code the weighted moving average (WMA) but substituted the EMA for the WMA. I chose to view the chart of VIAB by running the EDS “Zero MACD.eds” on 3/14/2016 and examining the alert messages on the report “List.” VIAB is the only one on that date that showed a cross up on the MACDhist (see Figure 8 for a look at part of this report for 3/14/2016).
Sample Chart
FIGURE 8: AIQ. This shows part of the EDS custom report “List” that shows the MACDhist values on 3/14/2016, the color status, and any alerts that were generated for that day.
! ZERO IN ON THE MACD

! Author: Barbara Star, TASC May 2016

! Coded by: Richard Denning 3/14/16

! www.TradersEdgeSystems.com



! INPUTS:

macd1  is  12.

macd2  is  26.

macdSig is  1.



! INDICATORS:

emaST  is expavg([Close],macd1).

emaLT  is expavg([Close],macd2).

MACD  is emaST - emaLT.  ! MACD line

SigMACD is expavg(MACD,macdSig). ! MACD Signal line

MACDosc is MACD - SigMACD. ! MACD Oscillator



HD if hasdatafor(macd2) = macd2.

MACDhist is MACD.                                 ! plot as historigram

MACDblue if MACDhist > 0.  ! use these rules to color MACDhist

MACDred  if MACDhist < 0.  ! use these rules to color MACDhist

MACDcolor is iff(MACDblue and HD,"Blue",iff(MACDred and HD,"Red","White")). !for report list

List if 1.



!ALERTS:

EMA1 is expavg([close],34).

EMA2 is expavg([close],55).

xupEMA1 if [close] > EMA1 and valrule([close] < EMA1,1).

xdnEMA1 if [close] < EMA1 and valrule([close] > EMA1,1).

xupEMA2 if [close] > EMA2 and valrule([close] < EMA2,1).

xdnEMA2 if [close] < EMA2 and valrule([close] > EMA2,1).

xupMACD if MACDhist > 0 and valrule(MACDhist < 0,1).

xdnMACD if MACDhist < 0 and valrule(MACDhist > 0,1).

UpAlerts is iff(xupEMA1,"xupEMA1",iff(xupEMA2,"xupEMA2",iff(xupMACD,"xupMACD"," "))).

DnAlerts is iff(xdnEMA1,"xdnEMA1",iff(xdnEMA2,"xdnEMA2",iff(xdnMACD,"xdnMACD"," "))).

The code and EDS file can be downloaded from www.TradersEdgeSystems.com/traderstips.htm.

Trading Gap Reversals

The AIQ code based on Ken Calhoun’s article in April 2016 issue of Stock & Commodities Trading Gap Reversals”, is provided below. 
AIQ has also posted the EDS file at “ is provided for downloading at 
Save this file to your/wintes32/EDS Strategies folder.
Since I mainly work with daily bar strategies, I wanted to test the gap-down concept on a daily bar trading system rather than on one-minute bars. I set up a system that buys after a stock has gapped down at least 10% in the last two days and then trades above the high of the gap-down bar. The entry is then at the close of that bar. For exits, I used the built-in exit, the profit-protect exit set at 80% once profit reaches 3% or more combined with a stop-loss using the low of the gap-down bar and also a time exit set to five bars. 
I then ran this system on the NASDAQ 100 list of stocks in the EDS backtester over the period 12/31/1999 to 1/11/2016 (Figure 7). The system generated 303 trades with an average profit of 1.09% per trade with a reward-to-risk ratio of 1.35. Slippage and commissions have not been deducted from these results.
Sample Chart
FIGURE 7: AIQ. This shows the EDS test results for the example system.
Again, the code and EDS file can be downloaded from www.TradersEdgeSystems.com/traderstips.htm, and is also shown below.
!TRADING GAP REVERSALS
!Author: Ken Calhoun, TASC April 2016
!Coded by: Richard Denning 2/1/2016
!www.TradersEdgeSystems.com

!INPUTS:
GapSize is 10.
GapLookBack is 5.
MaxBars is 5.

!CODING ABBREVIATIONS:
H is [high].
C is [close].
C1 is val([close],1).
L is [low].
O is [open].

GapD is (O / C1 - 1) * 100.
GapOS is scanany(GapD < -GapSize,GapLookBack) <> nodate()
  then offsettodate(month(),day(),year()).
Hgap  is valresult(H,^GapOS).
Lgap  is valresult(L,^GapOS).
SU if  scanany(GapD < -GapSize,GapLookBack).
SU1 if  scanany(GapD < -GapSize,GapLookBack,1).
SU2 if  scanany(GapD < -GapSize,GapLookBack,2).
LE if ((SU1 then resetdate()) or (SU2 then resetdate())) 
 and H > Hgap.
ExitLong if {position days} > maxBars
 or C < Lgap.
EntryPr is max(O,Hgap).
List  if C > 0.
—Richard Denning