Category Archives: Stocks & Commodities traders tips

Detecting High-Volume Breakouts

The importable AIQ 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).
VPN is (expavg(((VP - VN) / MAV / period),smoLen))*100.
MAVPN is simpleavg(VPN,maLen).

Code for the VPN indicator is set up in the AIQ 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

The RS4r: Tracking Relative Strength In Four Dimensions

Relative strength has more information embedded within it than meets the eye. Here is a way to identify and compress several dimensions of relative strength into one single scalable value, the RS4r, which allows you to compare and then rank securities for robustness across timeframes and shifting market conditions…

The importable AIQ EDS file based on James Garofallou’s article in
Stocks & Commodities magazine September 2020 issue, “The RS4r: Tracking Relative Strength In Four Dimensions,” can be obtained on request via email to info@TradersEdgeSystems.com. The code is also available here:

! The RS4r: Tracking Relative Strength in Four Dimensions
! Author: James Garofallou, PhD, TASC Sept 2020
! Coded by: Richard Denning, 7/18/2020

!INPUTS
C is [close].
len1 is 10.
len2 is 15.
NumIndx is 4.
BuyLvl is 80.

!FORMULAS
SPYc is TickerUDF("SPY",C).      !SP500
QQQc is TickerUDF("QQQ",C).     !NASDAQ100
MDYc is TickerUDF("MDY",C).     !SP400
IWMc is TickerUDF("IWM",C).      !Russel2000

RS1spy is C/SPYc.
RS1qqq is C/QQQc.
RS1mdy is C/MDYc.
RS1iwm is C/IWMc.

FastSPY is Expavg(RS1spy,len1).
MedSPY is Simpleavg(FastSPY,7).
SlowSPY is Simpleavg(FastSPY,15).
VSlowSPY is Simpleavg(SlowSPY,30).

FastQQQ is Expavg(RS1qqq,Len1).
MedQQQ is Simpleavg(FastQQQ,7).
SlowQQQ is Simpleavg(FastQQQ,15).
VSlowQQQ is Simpleavg(SlowQQQ,30).

FastMDY is Expavg(RS1mdy,Len1).
MedMDY is Simpleavg(FastMDY,7).
SlowMDY is Simpleavg(FastMDY,15).
VSlowMDY is Simpleavg(SlowMDY,30).

FastIWM is Expavg(RS1iwm,Len1).
MedIWM is Simpleavg(FastIWM,7).
SlowIWM is Simpleavg(FastIWM,15).
VSlowIWM is Simpleavg(SlowIWM,30).

Tier1spy is iff(FastSPY>=MedSPY and MedSPY>=SlowSPY and SlowSPY>=VslowSPY,10,0).
Tier1qqq is iff(FastQQQ>=MedQQQ and MedQQQ>=SlowQQQ and SlowQQQ>=VslowQQQ,10,0).
Tier1mdy is iff(FastMDY>=MedMDY and MedMDY>=SlowMDY and SlowMDY>=VslowMDY,10,0).
Tier1iwm is iff(FastIWM>=MedIWM and MedIWM>=SlowIWM and SlowIWM>=VslowIWM,10,0).

Tier2spy is iff(FastSPY>=MedSPY and MedSPY>=SlowSPY and SlowSPY<VslowSPY,9,0).
Tier2qqq is iff(FastQQQ>=MedQQQ and MedQQQ>=SlowQQQ and SlowQQQ<VslowQQQ,9,0).
Tier2mdy is iff(FastMDY>=MedMDY and MedMDY>=SlowMDY and SlowMDY<VslowMDY,9,0).
Tier2iwm is iff(FastIWM>=MedIWM and MedIWM>=SlowIWM and SlowIWM<VslowIWM,9,0).

Tier3spy is iff(FastSPY<MedSPY and MedSPY>=SlowSPY and SlowSPY>=VslowSPY,9,0).
Tier3qqq is iff(FastQQQ<MedQQQ and MedQQQ>=SlowQQQ and SlowQQQ>=VslowQQQ,9,0).
Tier3mdy is iff(FastMDY<MedMDY and MedMDY>=SlowMDY and SlowMDY>=VslowMDY,9,0).
Tier3iwm is iff(FastIWM<MedIWM and MedIWM>=SlowIWM and SlowIWM>=VslowIWM,9,0).

Tier4spy is iff(FastSPY<MedSPY and MedSPY>=SlowSPY and SlowSPY<VslowSPY,5,0).
Tier4qqq is iff(FastQQQ<MedQQQ and MedQQQ>=SlowQQQ and SlowQQQ<VslowQQQ,5,0).
Tier4mdy is iff(FastMDY<MedMDY and MedMDY>=SlowMDY and SlowMDY<VslowMDY,5,0).
Tier4iwm is iff(FastIWM<MedIWM and MedIWM>=SlowIWM and SlowIWM<VslowIWM,5,0).

RS2spy is Tier1spy + Tier2spy + Tier3spy + Tier4spy.
RS2qqq is Tier1qqq + Tier2qqq + Tier3qqq + Tier4qqq.
RS2mdy is Tier1mdy + Tier2mdy + Tier3mdy + Tier4mdy.
RS2iwm is Tier1iwm + Tier2iwm + Tier3iwm + Tier4iwm.


RS3x is  (RS2spy+RS2qqq+RS2mdy+RS2iwm).

RS4 is (RS3x/NumIndx)*10.
RS4osc is simpleavg(RS4,3).
mvSig is simpleavg(RS4osc,5).
RS4r is round(RS4).

mvRS4 is expavg(RS4r,4).
RS4up is iff(RS4r >= 80 or RS4r > mvRS4,1,0).

X is iff(RS4 >= 80,1,0).
R5 is iff(RS4up =1,round(simpleavg(X,len2)*100),0).

Buy if R5 >= BuyLvl.
ExitBuy if R5 < BuyLvl.

ShowValues if 1.

Code for the RS4r is included in the EDS file. I also coded a system that uses the RS4r (R5). I used four independent ETFs as indexes rather than the 11 mutual funds that the author used. I used SPY, QQQQ, MDY, and IWM. The trading system buys (long only) when the R5 >= 80 and exits the long position when RS4r < 80. The summary EDS backtest report for trading this system on the Nasdaq 100 stocks (commission & slippage not subtracted) is shown in Figure 13 and a sample trade on DISH with the R5 indicator is shown in Figure 12.

Sample Chart

FIGURE 12: AIQ. Chart of DISH with R5 indicator and sample trade using R5 indicator >= 80 to buy.

Sample Chart

FIGURE 13: AIQ. Summary EDS backtest report for the R5 system that trades the Nasdaq 100 stocks over the last 4 years.

—Richard Denning
info@TradersEdgeSystems.com
for AIQ Systems

Vitali Apirine’s – The Compare Price Momentum Oscillator (CPMO)

The importable AIQ EDS file based on Vitali Apirine’s article in the August, 2020 issue of Stocks & Commodities magazine, “The Compare Price Momentum Oscillator (CPMO),” can be obtained on request via email to info@TradersEdgeSystems.com.

… Here is a way you can compare at a glance the momentum of two different market indexes or securities in the same chart. It could also be used to help generate trading signals. In this first part of a three-part series, we’ll look at comparing index momentums…

The code is also available here:

!Author: Vitali Aprine, TASC August 2020
!Coded by: Richard Denning, 6/20/20
!www.TradersEdgeSystems.com

!Custom smoothing multiplier: 2 / time period
!PMO line: 20-period custom EMA of (10 × 35-period
!custom EMA of ((Today’s price – Yesterday’s price) / !Yesterday’s price × 100))
!PMO signal line: 10-period EMA of the PMO line

Len1 is 20.
Len2 is 35.
Len3 is 10.
Ticker1 is “QQQ”.
Ticker2 is “SPY”.

C is [close].
C1 is valresult(C,1).
RC1 is (C/C1*100)-100.

custSmoLen1 is Len1 – 1.
custSmoLen2 is Len2 – 1.

CustEma is 10*expavg(RC1,custSmoLen2).
PMO is expavg(CustEma,custSmoLen1).
PMOsig is expavg(PMO,Len3).

Ticker1C is tickerUDF(Ticker1,C).
RC1ticker1 is (Ticker1C/valresult(Ticker1C,1)*100)-100.
CustEmaTicker1 is 10*expavg(RC1ticker1,custSmoLen2).
PMOticker1 is expavg(CustEmaTicker1,custSmoLen1).

Ticker2C is tickerUDF(Ticker2,C).
RC1ticker2 is (Ticker2C/valresult(Ticker2C,1)*100)-100.
CustEmaTicker2 is 10*expavg(RC1ticker2,custSmoLen2).
PMOticker2 is expavg(CustEmaTicker2,custSmoLen1).

CPMO is PMOTicker1 – PMOTicker2.
List if hasdatafor(1000) >= 900.

I coded the indicator described by the author. Figure 10 shows the indicator (QQQ,SPY,20,35) on chart of IWM. When the white line is above the red line on the CPMO indicator, this indicates that the QQQ is stronger than the SPY. Generally, it is considered bullish when the QQQ is leading in strength.

Sample Chart

FIGURE 10: AIQ. The CPMO indicator is shown on a chart of IWM with parameters (QQQ,SPY,20,35).

—Richard Denning
info@TradersEdgeSystems.com
for AIQ Systems

A Simple Way To Trade Seasonality


In “A Simple Way To Trade Seasonality” in the September 2019 Stocks & Commodities, author Perry Kaufman describes methods he uses for measuring the seasonality in markets and approaches he uses for trading these patterns

Editors note: The full article can be obtained from Stocks & Commodities magazine at
http://technical.traders.com/sub/sublog2.asp#Sep the system rules are from the article and are based on these rules

1. Average the monthly frequency of the past 4 years.

2. Find the last occurrence of the highest frequency and the last occurrence of the lowest frequency using the average frequency in step 1. That is, if both March and April have a frequency of 70, we use April.

3. Only trade if the high frequency is 75% or greater and the low frequency is 25% or lower.

4. If the high frequency comes first, sell short at the end of the month with the high frequency. Cover the short at the end of the month with the low frequency.

5. If the low frequency comes first, buy at the end of the month with the low frequency. Sell to exit at the end of the month with the high frequency

The importable AIQ EDS file and Excel spreadsheet for Perry Kaufman’s article can be obtained on request via email to info@TradersEdgeSystems.com. The code is also shown below

!A Simple Way to Trade Seasonality
!Author: Perry Kaufman, TASC September 2019
!Coded by: Richard Denning, 07/21/2019
!www.TradersEdgeSystem.com

C is [close].
year is 2019.
len is 4000.
OSD is offsettodate(month(),day(),year()).
FirstDate is firstdatadate().

EOM1 if Month()=2 and valresult(month(),1)=1 and year()=year.
EOMos1 is scanany(EOM1,len) then OSD+1.
EOMc1 is valresult(C,^EOMos1).
EOM2 if Month()=3 and valresult(month(),1)=2 and year()=year.
EOMos2 is scanany(EOM2,len) then OSD+1.
EOMc2 is valresult(C,^EOMos2).
EOM3 if Month()=4 and valresult(month(),1)=3 and year()=year.
EOMos3 is scanany(EOM3,len) then OSD+1.
EOMc3 is valresult(C,^EOMos3).
EOM4 if Month()=5 and valresult(month(),1)=4 and year()=year.
EOMos4 is scanany(EOM4,len) then OSD+1.
EOMc4 is valresult(C,^EOMos4).
EOM5 if Month()=6 and valresult(month(),1)=5 and year()=year.
EOMos5 is scanany(EOM5,len) then OSD+1.
EOMc5 is valresult(C,^EOMos5).
EOM6 if Month()=7 and valresult(month(),1)=6 and year()=year.
EOMos6 is scanany(EOM6,len) then OSD+1.
EOMc6 is valresult(C,^EOMos6).
EOM7 if Month()=8 and valresult(month(),1)=7 and year()=year.
EOMos7 is scanany(EOM7,len) then OSD+1.
EOMc7 is valresult(C,^EOMos7).
EOM8 if Month()=9 and valresult(month(),1)=8 and year()=year.
EOMos8 is scanany(EOM8,len) then OSD+1.
EOMc8 is valresult(C,^EOMos8).
EOM9 if Month()=10 and valresult(month(),1)=9 and year()=year.
EOMos9 is scanany(EOM9,len) then OSD+1.
EOMc9 is valresult(C,^EOMos9).
EOM10 if Month()=11 and valresult(month(),1)=10 and year()=year.
EOMos10 is scanany(EOM10,len) then OSD+1.
EOMc10 is valresult(C,^EOMos10).
EOM11 if Month()=12 and valresult(month(),1)=11 and year()=year.
EOMos11 is scanany(EOM11,len) then OSD+1.
EOMc11 is valresult(C,^EOMos11).
EOM12 if Month()=1 and valresult(month(),1)=12 and valresult(year(),1)=year.
EOMos12 is scanany(EOM12,len) then OSD+1.
EOMc12 is valresult(C,^EOMos12).
YEARavg is (EOMc1+EOMc2+EOMc3+EOMc4+EOMc5+EOMc6+EOMc7+EOMc8+EOMc9+EOMc10+EOMc11+EOMc12)/12.

AR1 is (EOMc1 / YEARavg-1)*100.
AR2 is (EOMc2 / YEARavg-1)*100.
AR3 is (EOMc3 / YEARavg-1)*100.
AR4 is (EOMc4 / YEARavg-1)*100.
AR5 is (EOMc5 / YEARavg-1)*100.
AR6 is (EOMc6 / YEARavg-1)*100.
AR7 is (EOMc7 / YEARavg-1)*100.
AR8 is (EOMc8 / YEARavg-1)*100.
AR9 is (EOMc9 / YEARavg-1)*100.
AR10 is (EOMc10 / YEARavg-1)*100.
AR11 is (EOMc11 / YEARavg-1)*100.
AR12 is (EOMc12 / YEARavg-1)*100.

EOMc if firstdate < makedate(1,20,2019-20).
AR if EOMc.

The EDS code is not a trading system but a way to get the data needed into an Excel spreadsheet to enable you to make the seasonal calculations. The EDS file should be run on a date after the end of the year being calculated. Each year for which data is needed must be run separately by setting the “year” variable. Multiple symbols can be run at the same time by using a list of the desired symbols. Each time a year is run, the “AR” report must be saved as a “.csv” file. Once all the years needed have been run and saved to separate “.csv” files, they all should be cut and pasted to a single Excel sheet. They then can be sorted by symbol and each symbol can be copied and pasted to a tab for that symbol.

Figure 6 shows the rolling four-year frequency for the S&P 500 ETF (SPY) and Figure 7 shows the annual trades resulting from applying the seasonal rules to the frequency data.

Sample Chart

FIGURE 6: AIQ. Shown here is the rolling four-year frequency for the SPY.

Sample Chart

FIGURE 7: AIQ. Shown here are the annual trades resulting from applying the seasonal rules to the frequency data for SPY.

—Richard Denning
info@TradersEdgeSystems.com
for AIQ Systems

Exponential Deviation Bands

The importable AIQ EDS file based on Vitali Apirine’s article in July 2019 Stocks & Commodities issue, “Exponential Deviation Bands,”

and a recreated Excel spreadsheet similar to the one shown in the article can be obtained on request via email to info@TradersEdgeSystems.com. The code is also shown here:

Exponential deviation (ED) bands are plotted above and below a moving average (MA) from which the bands are calculated. An exponential deviation from the moving average is used to set the bands. ED bands can be used with either a simple moving average (SMA) or an exponential moving average (EMA). The moving average dictates direction, and the exponential deviation sets band width. Breakouts from the band and changes in the band’s direction can help identify price trends and price reversals. These bands can be used on a variety of securities with its standard settings.

!EXPONENTIAL DEVIATION BANDS
!Author: Vitali Apirine, TASC July 2019
!Coded by: Richard Denning, 5/15/2019
!www.TradersEdgeSystems.com

C is [close].
Periods is 20. 

MA20 is simpleavg(C,Periods).   !expavg(C,Periods).  !or simpleavg(C,Periods). 
MDev20 is (Abs(MA20-C)+Abs(MA20-valresult(C,1))+Abs(MA20-valresult(C,2))+Abs(MA20-valresult(C,3))
      +Abs(MA20-valresult(C,4))+Abs(MA20-valresult(C,5))+Abs(MA20-valresult(C,6))+Abs(MA20-valresult(C,7))
     +Abs(MA20-valresult(C,8))+Abs(MA20- valresult(C,9))+Abs(MA20- valresult(C,10))+Abs(MA20- valresult(C,11))
     +Abs(MA20- valresult(C,12))+Abs(MA20- valresult(C,13))+Abs(MA20- valresult(C,14))+Abs(MA20- valresult(C,15))
      +Abs(MA20- valresult(C,16)) +Abs(MA20- valresult(C,17))+Abs(MA20- valresult(C,18))+Abs(MA20- valresult(C,19)))/20.

Dev is Abs(MA20-C).  
Rate is 2/( Periods +1).  

DaysInto is ReportDate() - RuleDate().
Stop if DaysInto >= 200.
stopEXD is iff(Stop,Mdev20, EXD).
EXD is Dev*Rate + valresult(stopEXD,1)*(1-Rate).

UpperExp is MA20+2*EXD.  
MidExp is MA20.  
LowerExp is MA20-2*EXD. 

ShowValues if 1.

Figure 9 shows the exponential deviation bands centered on a 20-bar simple moving average on a chart of the New York Composite Index (NYA).

Sample Chart

FIGURE 9: AIQ. Here are exponential deviation bands centered on a 20-bar simple moving average on a chart of the New York Composite Index (NYA).

—Richard Denning
info@TradersEdgeSystems.com
for AIQ Systems