John Ehlers’ Every Little Bit Helps

Averaging The Open And Close To Reduce Noise

The importable  EDS file based on John Ehlers’ article in the March 2023 issue of Stocks & Commodities, “Every Little Bit Helps,” can be obtained on request via rdencpa@gmail.com. John notes ‘It’s simple but makes a noticeable improvement: You can reduce noise in the data by using an average of the open and close instead of using only the closing price.’ The code is also available below.

!Every Little Bit Helps
!Author: John F. Ehlers, TASC Mar 2023
!Coded by: Richard Denning, 1/12/2023

!Data Sampling Test
!(c) John Ehlers 2022

!INPUTS:
W1 is 14. !Wilder RSI length
W2 is 14. !Ehlers RSI length

!RSI Wilder code:
U is [close]-val([close],1).
D is val([close],1)-[close].
L1 is 2 * W1 – 1.
AvgU is ExpAvg(iff(U>0,U,0),L1).
AvgD is ExpAvg(iff(D>=0,D,0),L1).
RSIwilder is 100-(100/(1+(AvgU/AvgD))).

!Ehlers RSI code:
OCavg is ([open] + [close])/2.
Uoc is OCavg-valresult(OCavg,1).
Doc is valresult(OCavg,1)-OCavg.
L2 is 2 * W2 – 1.
AvgU2 is ExpAvg(iff(Uoc>0,Uoc,0),L2).
AvgD2 is ExpAvg(iff(Doc>=0,Doc,0),L2).
RSIoc is 100-(100/(1+(AvgU2/AvgD2))).

!CTest is RSIwilder.
!OCTest is RSIoc.

BuyRSIwilder if RSIwilder < 20 and valrule(RSIwilder >= 20,1).
ExitRSIwilder if RSIwilder > 80 or {Position days}>=20.

BuyRSIoc if RSIoc < 20 and valrule(RSIoc >= 20,1).
ExitRSIoc if RSIoc > 80 or {Position days}>=20.

Code for the author’s indicators are set up in the EDS code file. Figure 7 shows the EDS module backtest results using the RSI original indicator. Figure 8 shows the EDS module backtest results using the modified version of the RSI indicator over a 10-year period using NASDAQ 100 stocks. The comparison suggests that some of the metrics improve using the modified version and a few are worse.

The system rules are:

  • Buy when the RSI crosses down below 20
  • Sell when the RSI crosses above 80 or after 20 trading days
FIGURE 7: AIQ. This shows example backtest results for classic RSI trading system rules, based on closing data, over a 10-year period using NASDAQ 100 stocks.
FIGURE 8: AIQ. This shows example backtest results for the RSI trading system rules, this time based on data that averages the open and close instead of using just the closing price data, over a 10-year period using NASDAQ 100 stocks.

An Adaptive Moving Average For Swing Trading

The importable  EDS file based on Scott Cong’s article in the May 2023 issue of Stocks & Commodities magazine, “An Adaptive Moving Average For Swing Trading,” can be obtained on request via rdencpa@gmail.com.

In this article, Scott proposes a new adaptive moving average (AMA). It adjusts its parameters automatically according to the volatility of market, tracking price closely in trending movement, and staying flat in congestion areas. The new AMA is well-suited for swing trading.

The code is also available below.

Code for the author’s indicator as shown below is set up in the downloadable EDS code file.

!ADAPTIVE MOVING AVERAGE FOR SWING TRADING
!Author: Scott Cong, TASC May 2023
!Coded by: Richard Denning, 03/14/2023

!INPUTS:
Len is 20.

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

TR is Max(H-L,max(abs(C1-L),abs(C1-H))).
Effort is sum(TR,Len).
Result is highresult(H,Len) – lowresult(L,Len).
alpha is Result / Effort.
beta is 1 – alpha.

DaysInto is ReportDate() – RuleDate().
Stop if DaysInto > Len*2.
stopAMA is iff(stop,C, AMA).
AMA is alpha * [close] + beta * valresult( stopAMA, 1).
ESA is expavg(C,Len).

The figure below shows a chart of Broadcom (AVGO) along with the AMA[20] indicator (the red jagged line) and an exponential moving average indicator [20] (the green smooth line).

Detecting High-Volume Breakouts

The importable  EDS file based on Markos Katsanos’ article in the April issue of Stocks & Commodities, “Detecting High-Volume Breakouts,” can be obtained on request via email to info@TradersEdgeSystems.com.

Excerpt “Is there anything more satisfying for a trader than capturing a huge breakout? The usual practice for breakout entries is to simply buy new highs. This method, when used in isolation, will often result in false breakouts. It is, therefore, better to wait for volume confirmation before entering the trade, as high-volume breakouts usually last much longer. In this article, I will show you how to detect breakouts using only volume, sometimes even before price breaks out, by introducing a new volume breakout indicator. “

The code is also available here:

 
!Detecting High-Volume Breakouts !Author: Markos Katsanos, TASC April 2021 
!Coded by: Richard Denning, 02/18/2021 
!INPUTS: 
period is 30. 
smoLen is 3. 
vpnCrit is 10. 
maLen is 30. 
V is [volume]. 

!FORMULAS: 
MAVol is simpleavg(V,period). 
MAV is iff(MAVol>0,MAVol,1). 
Avg is ([High]+[Low]+[Close])/3. 
MF is Avg - valresult(Avg,1). 
ATR is simpleavg(max( [high]-[low],max(val([close],1)-[low],[high]-val([close],1))),period). 
MC is 0.1*ATR. 
VMP is iff(MF > MC, V, 0). 
VP is sum(VMP,period). 
VMN is iff(MF < -MC, V, 0). 
VN is sum(VMN,period). EDSPN is (expavg(((VP - VN) / MAV / period),smoLen))*100. 
MAVPN is simpleavg(VPN,maLen).

Code for the VPN indicator is set up in the EDS code file. Figure 9 shows the indicator on a chart of Tesla Motors Inc (TSLA).

Sample Chart

FIGURE 9: AIQ. The VPN indicator is shown on a chart of Tesla Motors Inc. (TSLA).

—Richard Denning
info@TradersEdgeSystems.com
for AIQ Systems

A Technical Method For Rating Stocks

The WinWayCharts EDScode based on Markos Katsanos’ article in this issue, “A Technical Method For Rating Stocks,” is shown below.
Synopsis from Stocks & Commodities June 2018
I’s it possible to create a stock rating system using multiple indicators or other technical criteria? If so, how does it compare with analyst ratings? Investors around the world move billions of dollars every day on advice from Wall Street research analysts. Most retail investors do not have the time or can’t be bothered to read the full stock report and rely solely on the bottom line: the stock rating. They believe these ratings are reliable and base their investment decisions at least partly on the analyst buy/sell rating. But how reliable are those buy/sell ratings? In this article I will present a technical stock rating system based on five technical criteria and indicators, backtest it, and compare its performance to analyst ratings.
!A TECHNICAL METHOD FOR RATING STOCKS
!Author: Markos Katsanos, TASC June 2018
!Coded by: Richard Denning, 4/18/18
!www.TradersEdgeSystems.com

!INPUTS:
  MAP is 63. 
  STIFFMAX is 7. 
  VFIPeriod is 130. 
  MASPY is 100. 
  MADL is 100.
  SCORECRIT is 5.
  W1 is 1.
  W2 is 1.
  W3 is 1.
  W4 is 1.
  W5 is 2.
 
!VFI FORMULA: 
  COEF is 0.2.
  VCOEF is 2.5.
  Avg is ([high]+[low]+[close])/3.
  inter is ln( Avg ) - ln( Valresult( Avg, 1 ) ). 
  vinter is sqrt(variance(inter, 30 )).
  cutoff is Coef * Vinter * [Close].
  vave is Valresult(simpleavg([volume], VFIPeriod ), 1 ).
  vmax is Vave * Vcoef.
  vc is Min( [volume], VMax ).
  mf is Avg - Valresult( Avg, 1 ).
  vcp is iff(MF > Cutoff,VC,iff(MF < -Cutoff,-VC,0)).
  vfitemp is Sum(VCP , VFIPeriod ) / Vave.
  vfi is expavg(VFItemp, 3 ).

!STIFFNESS 
  ma100 is Avg. 
  CLMA if [close] < MA100.
  STIFFNESS is countof(CLMA,MAP).

!CONDITIONS:
 ! MONEY FLOW:
   COND1 is iff(VFI>0,1,0). 
 !SIMPLEAVG:
    SMA is simpleavg([close],MADL).                              
    COND2 is iff([close]>SMA,1,0).  
 !SIMPLEAVG DIRECTION:                       
    COND3 is iff(SMA>valresult(SMA,4),1,0).  
!STIFFNESS:                          
    COND4 is iff(STIFFNESS<= STIFFMAX,1,0).  
!MARKET DIRECTION:
    SPY is TickerUDF("SPY",[close]).
    COND5 is iff(EXPAVG(SPY,MASPY)>= 
 valresult(EXPAVG(SPY,MASPY),2),1,0).            

SCORE is  W1*COND1+W2*COND2+W3*COND3+
   W4*COND4+W5*COND5.

 buy if Score>=SCORECRIT and hasdatafor(300)>=268. 
Figure 11 shows the summary results of a backtest using NASDAQ 100 stocks during a generally bullish period from April 2009 to April 2018. Figure 12 shows the backtest using the same list of NASDAQ 100 stocks during a period that had two bear markets (April 1999 to April 2009). The average results are similar except that there are fewer trades during the period that contained the two bear markets. Both backtests use a fixed 21-bar exit.

Sample Chart

FIGURE 11: AIQ, BULL MARKET. Here are the summary results of a backtest using NASDAQ 100 stocks during a generally bullish period from April 2009 to April 2018.

Sample Chart

FIGURE 12: AIQ, BEAR MARKET. Here are the summary results of a backtest using NASDAQ 100 stocks during a period from April 1999 to April 2009 that contained two bear markets.
—Richard Denning info@TradersEdgeSystems.com for AIQ Systems

Weekly and Daily MACD

The WinWay EDS code based on Vitali Apirine’s article in December 2017 issue of Stocks and Commodities magazine, “Weekly & Daily MACD,” is provided below.
The moving average convergence/divergence oscillator (MACD), developed by Gerald Appel, is one of the more popular technical analysis indicators. The MACD is typically used on a single timeframe, but what if we looked at two timeframes on one chart?

Traders can look for relative daily MACD line crossovers, weekly and daily centerline crossovers, and divergences to generate trading signals. 
Figure 5 shows the daily & weekly MACD indicator on a chart of Apple Inc. (AAPL) during 2016 and 2017, when there was a change from a downtrend to an uptrend.
Sample Chart

FIGURE 5: AIQ. Here is an example of the daily & weekly MACD on a chart of AAPL.
The code and EDS file can be downloaded from http://aiqsystems.com/dailyweeklyMACD.EDS, or copied here:
!WEEKLY & DAILY MACD
!Author: Vitali Apirine, TASC Dec 2017
!Coded by: Richard Denning 10/13/17
!www.TradersEdgeSystems.com

!INPUTS:
S is 12.
L is 25.

EMA1 is expavg([Close],S).
EMA2 is expavg([Close],L).
EMA3 is expavg([Close],S*5).
EMA4 is expavg([Close],L*5).
MACD is EMA1 - EMA2.
MACDW is EMA3 - EMA4.
rdMACD is MACD + MACDW.
—Richard Denning
info@TradersEdgeSystems.com

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 a WinWay 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: WinWay EDS. 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: WinWay EDS. 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
!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.

 

 

en_GBEnglish
en_GBEnglish