Code Snippets
&
How To’s
David Jennings
The Performance Factory
AIQ CODE...9
CANDLESTICKS...9
CANDLESTICK COLOUR STUDY...9
RATE OF CHANGE...9
MONEY MANAGEMENT EXITS...10
MACDI EXIT RULES...10
CONDITIONAL RULES-SELLING PRESSURE...11
MOMENTUM...12
VIDYA - TUSHAR CHANDE...13
SECTOR MOVEMENT...13
PRICE/VOLUME CRITERIA?...17
HIGH JUMP CANDIDATE SELECTION...17
VOLUME SPIKE...18
VARIABLE PROFIT PROTECT STOP, LOSS STOP AND TIME STOP...19
BUY FOR STOCKS IN A SECTOR...20
BOLLINGER BANDS...20
LINEAR REGRESSION CALCULATION USING THE LEAST MEANS SQUARED METHOD...21
LINEAR REGRESSION METHOD BASED INDICATORS...21
SECTOR DIVERGENCE...22
COUNTOF...23
ATR AND WILDER’S RSI ...23
RELATIVE STRENGTH...24
RECURSION...25
METASTOCK CODE...28
PRIMARY BUY SIGNAL...28
PRIMARY SELL SIGNAL...28
MARKETSPACE STOCK SYSTEM...28
Primary Buy Signal...28
Primary Sell Signal ...29
SMOOTH STOCKS...29
Bressert Cycle Indicators...30
EXPLANATION OF THE MCCLELLAN OSCILLATOR...31
THRUST OSCILATOR: ...31
MIDAS VOLUME WEIGHTED AVE PRICE-SUPPORT/RESIST...32
STOCHASTIC CROSS TRADING SYSTEM ...33
TSI AND ERGODICS INDICATORS...33
Trading Ergodics with the Trend – Rules ...34
RELATIVE STRENGTH OF STOCK TO INDEX ...34
FIND RSI ABOVE 80 ...36
KASE DEV STOP...36
WOLF WAVE PATTERNS...36
THE MARKET FACILITATION INDEX...37
TRUE STRENGTH INDEX...38
GANN SWING HILOW ACTIVATOR...41
RUGGERIO'S TREND...42
AUTOMATIC METASTOCK TRENDLINE FORMULA...42
THE RECURSIVE MOVING TREND AVERAGE...44
THREE INSIDE DAYS ...49
NR4 FORMULA...50
MOVAVG ASYMMETRIC VOLATILITY PRICE BANDS...58
REGRESSION ASYMMETRIC VOLATILE PRICE BAND...58
WRO AND WSO INDICATORS... 152
BODY MOMENTUM... 158
ST OSCILLATOR... 159
LOOKBACK... 160
CHANDE & KROLL'S R2 INDICATOR... 165
PRICE ACTION INDICATOR (PAIN) ... 165
WEEKLY PIVOT POINT... 167
HIGHEST HIGH SINCE BUY SIGNAL... 168
FORECAST OSCILLATOR SYSTEM ALTERNATIVE... 168
FORECAST OSCILLATOR SYSTEM ... 168
Chaos Blue BL ... 171
Chaos Red BL ... 171
Chaos Green BL... 171
Chaos Gator... 171
CHAOS AO ... 172
Chaos AO Signal Line... 172
Chaos AC ... 172
Chaos Fractal ... 172
TRADING THE TREND 2 ... 184
TRADING THE TREND 1 ... 186
BOLLINGER BAND WIDTH ... 187
BOLLINGER BAND HISTOGRAM KARNISH ... 187
BB HISTOGRAM... 191
CHANDELIER EXIT, VERSION 2 METASTOCK CODE ... 196
MOVING AVERAGE CROSSOVERS ... 197
VIDYA WITH P VARIABLE VERSION 2 ... 200
VIDYA EXPLANATION ... 201
IMPROVED CHANDELIER EXIT ... 217
BOOMERS TRADING SIGNALS... 224
Boomers buysig... 224
ADX AND TRENDLINES ... 227
ADX RISING EXPOLORATION... 243
SWING TRADING EXPERT ... 243
DMI EXPLORATION VERSION 3... 245
VOLATILITY BREAKOUT... 249
VOLATILITY EXPLORATION... 253
RELATIVE VOLATILITY INDEX... 254
SMOOTHED ADAPATIVE STOCHASTIC OSCILLATOR... 254
SIDEWAYS CHANNELS EXPLORATION... 260
STOCHASTIC AND RSI SYSTEM ... 261
DAHL OSCILLATOR... 263
2 DAY HAMMER EXPLORATION... 264
WRO AND WSO INDICATORS... 265
WRO INDICATOR: ... 267
GAP1 SYSTEM... 268
GAP2 SYSTEM... 268
RSI DIVERGENCE EXPLORATION... 269
STIX INDICATOR ... 270
DENVELOPE (RSI) ... 270
CYLICAL SYSTEM ... 271
JKCYCL... 272
ST OSCILLATOR... 273
CCI SPIKE TRADING SYSTEM... 273
LOOKBACK... 274
MCCLELLAN OSCILLATOR... 276
MCCLELLAN SUMMATION INDEX... 276
BARNES' ACCELERATION... 278
BARNES' ADAPTIVE FORECAST... 278
BARNES' MOVING AVERAGE... 278
NATENBERG'S VOLATILITY... 279
TEMA STOCHRSI FORMULA... 280
DEVSTOP ... 280
WEEKLY PIVOT POINT... 281
ATR MODIFIED... 283
HIGHEST HIGH SINCE BUY SIGNAL... 283
MINER’S STORSI... 284
FORECAST OSCILLATOR SYSTEM ALTERNATIVE... 287
MURREY MATH... 287
ZIGZAG CODE... 289
TRADE EQUITY AND TRADE STOP FORMULA UPDATE... 292
SO MUCH FOR QUICK FIXES. MY THANKS TO DAVID HOBBS FOR LETTING ME KNOW THAT MY 'ND' VARIABLE FIX WAS ALSO FLAWED. I'LL TRY AGAIN. IF YOU HAVE VERSION 3.X TRADE EQUITY OR TRADE STOP FORMULAS WITH AN 'ND' THAT LOOKS LIKE EITHER OF THE LINES BELOW, ND:=LASTVALUE(INT(FRAC(CP/100)*10)); OR ND:=LASTVALUE(INT(FRAC(CP/99)*10)); THEN IT SHOULD BE CHANGED TO ND:=LASTVALUE(INT(0.1+FRAC(CP/100)*10)); HOPEFULLY THIS WILL FIX THE PROBLEM ONCE-AND-FOR-ALL.... 297
LATCHES... 297
TRADESTATION CODE... 302
SLOWKCLASSIC... 302
MACD HISTOGRAM... 302
HIGH OF TODAY... 303
MACD CROSSOVER CHART... 304
COLES’S RANGE... 304
INDICATOR COLE'S RANGE DAILY... 305
8 PERIOD DONCHIAN CHANNEL MID-POINT LINE... 305
INDICATOR SUPP-RESIS DAILY... 305
ANDREW’S PITCHFORK... 307
E-MINI WITH MONTE CARLO... 311
HURST EXPONENT... 313
ERGOTIC CSI... 314
ERGOTIC MACD ... 315
ENTRY & EXIT... 316
STOPS IN EDS ... 317
TRIGGERS BASED ON ENTRY PRICES... 318
COUNT OF... 318
COMPARE TWO INDICES... 318
COLOUR STUDIES... 319
RECURSION... 320
DIFFERENT RESULTS IN TRADESTATION... 325
SIGNAL REVIEW – UPSIDE... 326
3 BAND RESEARCH SYSTEM... 326
MARKET PROFILE... 327
T BOND SYSTEM... 334
HIGHER HIGHS... 334
INDICATOR MARKS... 335
YESTERDAY’S HIGH LOW ON AN INTRADAY CHART... 336
TO COUNT THE NUMBER OF NEW HIGHS IN THE LAST N BARS... 336
COMMENTARY FUNCTION... 337
NO PLOT() STATEMENT... 338
NUMERICAL ACCURACY... 340
TRADESTATION: RELATIVE VIGOR INDEX ... 340
STOPS... 341
ADAPTIVE STOP... 341
LINE THICKNESS WON’T RESPOND... 342
TEXT STUDIES... 342
@TextCurrentCText... 344
@TextCurrentIndic ... 345
TRADESTATION INSTABILITY... 346
OTHER HOW TO’S ... 347
TS4 INSTALLATION ON WIN 2K... 349
ATR DISCUSSION... 355
CODING VELOCITY AND ACCELERATION... 356
WEALTHSCRIPT CODE ... 357
DEAD CAT CATCHER... 357
INTRADAY... 358
WEALTHSCRIPT CODE... 358
WEALTHSCRIPT CODE ... 360
TURTLE SOUP WITH FILTER... 360
WEALTHSCRIPT CODE... 361
MULTI COLOUR MA ETC... 363
DIVERGENCE BETWEEN PRICE AND RSI OR MACD HISTO...? ... 364
CHECK PEAK & CHECK VALLEY... 368
MOVING AVERAGES... 371
FIBONACCI FORMULAS... 373
JOE DINAPOLI - DINAPOLI TREND FORMULA... 376
FORECAST OSCILLATOR... 390
CHANDE'S DYNAMIC MOMENTUM INDEX... 392
ADAPTIVE SYSTEMS... 394
ON BALANCE VOLUME... 399
BOOK LIST... 401
GANN... 401
LIST OF BOOKS AND COURSES:... 401
RWI ... 405
KNEWPEAKINDICATOR ... 406
KPEAK OSCILLATOR ... 406
OKS & PEAKOSCILLATOR... 407
KCD INDICATOR... 407 KPERM FN... 408 1ST CLASS SHORTS ... 408 1ST CLASS LONGS ... 409 KCDL PIERCING ... 410 {BULLISH PIERCING} ... 410 {BEARISH PIERCING} ... 411
KSDANGERLONG & SHORT ... 411
KS2 LONGS & WARNING ... 411
KS2 SHORTS & WARNING ... 412
PERMISSION STOCHASTIC... 414
XPERM K ... 414 XPERM LONG... 414 XPERM SHORT ... 415 XD ... 415 XKCD ... 416 KPERMISSIONFN ... 416 KDEVSTOPS... 416 XDEV... 417 XREV... 417
LARRY WILLIAMS EXPERT ... 418
DEMARK EXPERT... 420
ZIG ZAG TREND INDICATOR... 423
Expressing Exponential averages in days... 428
FIBONACCI FORMULAS... 442
JOE DINAPOLI - DINAPOLI TREND FORMULA... 444
FORECAST OSCILLATOR... 457
CHANDE'S DYNAMIC MOMENTUM INDEX... 460
ADAPTIVE SYSTEMS... 461
ON BALANCE VOLUME... 466
MARKET COMMENTARY... 467
ACTIVE TRADER MAGAZINE CODE... 468
ROSS CONGESTION PAINTBAR. ... 489
NARROW RANGE 4 (NR4) DAYS... 490
NARROW RANGE 7 (NR7) DAYS... 491
HISTORICAL VOLATILITY... 492
BOLLINGER BANDS... 493
OUTSIDE DAY, NR4 AND MOVING AVERAGE... 494
NR7, INSIDE DAY AND BOLLINGER BAND... 495
STOWELL’S THREE-BAR NET LINE... 499
NONLINEAR EHLERS FILTER... 505
NEW MARKET PARADIGM SYSTEM... 508
BETTER BOLLINGER BANDS BY DENNIS MCNICHOLL... 510
KLINGER VOLUME OSCILLATOR... 512
TPF_REVERSAL2002 ... 514
{MARKET DIRECTION}... 517
REAL TIME PIVOT 2000... 518
VOLATILITY STOP INDICATOR... 519
CLUSTER 20000... 521 REVERSAL INDICATOR... 522 HI LO PIVOTS... 523 INTRADAY HI LO... 524 PB LONG... 525 PB SHORT... 527 RUBBER BAND2... 529 SFD... 530 SFK... 531 SSD... 531
CLUSTER VOLATILITY STOP – USES CLUSTER 2000 AS A FUNCTION... 532
REVERSAL INDICATOR... 535
CLUSTER INDICATOR CODE... 535
CANDLESTICK PATTERN RECOGNITION... 536
TFS TREND FOLLOWING SYSTEM... 544
TETHERLINE... 545
VOLUME OSCILLATOR... 546
DOUBLE STOCHASTIC... 546
RINA DATA COLLECTION PORTFOLIO OUTPUT... 547
WILL SPREAD... 551
MAMA FAMA... 551
AIQ Code
CANDLESTICKS See Separate file
CANDLESTICK COLOUR STUDY !Colour Study GreenCandle if ([Open]<=[Close]). RedCandle if ([Open]>[Close]). GreenBar if ([close]>=val([close],1)). RedBar if ([close]<val([close],1)). Island reversal !================================================== lowbody is min([open],[close]). highbody is max([open],[close]).
gapup if valresult(lowbody,1) > valresult(highbody,2). gapdn if valresult(lowbody,1) < highbody.
islandReversal if gapup and gapdn.
!=================================================== I have not tested this. I hope it is correct.
Almost correct... just reverse the UDFs: gapdn if highbody < valresult(lowbody,1).
+++++++++++++++++++++++++++++++++++++++++++++++++++++++
RATE OF CHANGE
! [email protected] august 2000 www.pewd.com ! ROC indicator (rate of change)
! source: TA from A-Z, S. Achelis www.equis.com/free/taaz/
! change value of nbrdays to change number of days in indicator originally coded for 12 period ROC
define nbrdays 12.
roc is (([close]-closexago)/closexago)*100. rocaverage is simpleavg(roc,21).
check my code for accuracy before trading off of them
MONEY MANAGEMENT EXITS
!! Exits Start Here !!
losslimit is 1.25. !! This controls the stop loss limit. stesa is expavg([close],5).
stoploss if val([high],1) >={position entry price} * losslimit. profitarget if val([low],1) <= valresult(stesa,1).
!! Insert the UDF and rule(below) into the backtester. exitprice is iff(stoploss, {position entry price} * losslimit, iff(profitarget,valresult(stesa,1), val([close],1))).
closeposition if [high] >= {position entry price} * losslimit or [low] <=stesa or {position days} =4 or mfi1 < 0.1.
!!! Exit the position when one of the following 4 events occurs first: !!! 1) a -25% max stoploss is reached,
!!! 2) or profit target is triggered when price hits the 5-day ESA, !!! 3) or the 1-day MF RSI turns 0,
!!! 4) or at the close of day 4.
!!! If money management does not allow you to use a -25% stop loss, then use a smaller limit. It will decrease overall
performance, but it will make you FEEL safer.
=============================================================
MACDI EXIT RULES
! Based upon strategies from "Street Smarts", copyright M. Gordon Publishing.
!Linda Bradford Raschke MACDI exit rules MACDXEXIT if
val([macd],2)< val([macd],1) and val([macd],1)> val([macd],0) and val([macd],1)>0
and val([macd],2)>0 and [macd]>0
and HiVal([Macd],20)=val([macd],1).
CONDITIONAL RULES-SELLING PRESSURE
I did more work on this and now it works for all the stocks in my database with look
back of 22 days-all of my stocks showed at least 4 up days in a 22 day look back
period from today:
!=============================
!Selling Pressure 4 day average in 22 day lookback:
ORg is [open]-[low]. UpC if [close]>val([close],1). A1 is Sum(ORgUpC,4)/4. A2 is Sum(ORgUpC,5)/4. A3 is Sum(ORgUpC,6)/4. A4 is Sum(ORgUpC,7)/4. A5 is Sum(ORgUpC,8)/4. A6 is Sum(ORgUpC,9)/4. A7 is Sum(ORgUpC,10)/4. A8 is Sum(ORgUpC,11)/4. A9 is Sum(ORgUpC,12)/4. A10 is Sum(ORgUpC,13)/4. A11 is Sum(ORgUpC,14)/4. A12 is Sum(ORgUpC,15)/4. A13 is Sum(ORgUpC,16)/4. A14 is Sum(ORgUpC,17)/4. A15 is Sum(ORgUpC,18)/4. A16 is Sum(ORgUpC,19)/4. A17 is Sum(ORgUpC,20)/4. A18 is Sum(ORgUpC,21)/4. A19 is Sum(ORgUpC,22)/4. Cup1 if countof(UpC,4)=4. Cup2 if countof(UpC,5)=4. Cup3 if countof(UpC,6)=4. Cup4 if countof(UpC,7)=4. Cup5 if countof(UpC,8)=4. Cup6 if countof(UpC,9)=4. Cup7 if countof(UpC,10)=4. Cup8 if countof(UpC,11)=4. Cup9 if countof(UpC,12)=4. Cup10 if countof(UpC,13)=4. Cup11 if countof(UpC,14)=4. Cup12 if countof(UpC,15)=4. Cup13 if countof(UpC,16)=4. Cup14 if countof(UpC,17)=4. Cup15 if countof(UpC,18)=4. Cup16 if countof(UpC,19)=4. Cup17 if countof(UpC,20)=4. Cup18 if countof(UpC,21)=4.
CountUp is countof(UpC,22). Avg4day is iff(Cup1,A1,iff(Cup2,A2,iff(Cup3,A3,iff(Cup4,A4,iff(Cup5,A5,iff(Cup6, A6, iff(Cup7,A7,iff(Cup8,A8,iff(Cup9,A9,iff(Cup10,A10,iff(Cup11,A11, iff(Cup12,A12,iff(Cup13,A13,iff(Cup14,A14,iff(Cup15,A15,iff(Cup16,A16 , iff(Cup17,A17,iff(Cup18,A18,A19)))))))))))))))))).
!The following is to display data to test calculation of average: ORgUpC is IFF(UpC,ORg,0). ORgUpC1 is valresult(IFF(UpC,ORg,0),1). ORgUpC2 is valresult(IFF(UpC,ORg,0),2). ORgUpC3 is valresult(IFF(UpC,ORg,0),3). ORgUpC4 is valresult(IFF(UpC,ORg,0),4). ORgUpC5 is valresult(IFF(UpC,ORg,0),5).
GoodData if HasDataFor(255)>=252 and expavg([volume],50)>3000 and [close]>=5 and mover and not ScanAny(GapDown,20) and resetdate() and
CountUp>=4.
GapDown if Val([low],1) - [high]>2.
Look if [ADX]>30 and [DirMov]>0 and Avg4day<1.00 and GoodData.
HG if Look and [low]<=expavg([close],20).
!Mover scan created by Bill S. (from Bear Essentials): bigs if [Close] > 10.
diffrat is (([high] - [low]) / [low]) * 100. avgrat is simpleavg(diffrat,30).
mover if avgrat > 4. BigMover if avgrat>8.
List if 1=1.
MOMENTUM
! [email protected] august 2000 www.pewd.com ! momentum indicator
! sources: TA from A-Z, S. Achelis www.equis.com/free/taaz/
! MarketTrack-MX user manual, page 10-16 (Track Data Corp) define nbrdays 12.
momentum is ([close]/val([close],nbrdays))*100. check my code for accuracy before trading off of them
VIDYA - TUSHAR CHANDE
Here's Vidya based on a 9-period CMO, or as close as we can get given > TEP's limitations for recursive calculations. Change VidLen to vary > the > (nominal) length of the moving average. As an indicator it is very > slow > to calculate, but is not bad in a scan.
> > HHP
! (based on 9-period CMO).
!================================== Define CMOLen 9. ! Conventional value is 9. Define VidLen 12. ! Smoothing. Vary to suit. Define Itr 100. ! Iterations allowed (maximum 240). !=============================
MO is [Close] - Val([Close], 1). AbsMO is Abs(MO).
AbsCMO is 0.01 + Abs(Sum(MO, CMOLen)) / (Sum(AbsMO, CMOLen) + 0.01). Alpha is (2 / ((1 + VidLen)) * AbsCMO).
Beta is 1 - Alpha.
DaysInto is ReportDate() - RuleDate(). Stop if DaysInto > Itr.
StopCalc is iff(Stop, [Close], Vidya).
Vidya is Alpha * [Close] + Beta * ValResult(StopCalc, 1). !===================================
SECTOR MOVEMENT
Steve, Quite correct to point out this market has no intrinsic worth of 5000 and the trip back to that level may take years, I meant that because it is a long trip, I'm not in a hurry to jump on the first train that leaves. There will be plenty of opportunity to catch a tech wave or two. The sector rotation formula is very simple, but it has backtested better than TS for the way I am using it. It mostly fires at the beginning of a shift in leadership, and is best with 20 day holds or so. The gifs will show you what it looks like, and it doesn't look very good because it fires for a few days and then drops. It is only used to fire a good sector signal, the stock sell is based on stock action, not a drop in the sector signal.
!GROUP & SECTOR STUFF ! Rich set up form Description is Description(). GroupSymbol is TickerUDF(RSTicker(),Symbol()). GroupName is TickerUDF(RSTicker(),Description). SectorSymbol is TickerUDF(RSTicker(),GroupSymbol). SectorName is TickerUDF(SectorSymbol,Description). SectorTCIDIR is TickerUDF(SectorSymbol,TCIDIR). GroupTCIDIR is TickerUDF(GroupSymbol,TCIDIR).
TCIDIR is (( [TCI]-val([TCI],1))*10 )+ [dirmov]-60. !combines the TCI and the DIRMOV to find quik trend
Tech if SectorSymbol="MGTECHNO". !I set up my sectors based on the 10 Market Guide sectors,but any will work
NOTECHNOSECTOR if not tech.
notech if NOTECHNOSECTOR and SectorTCIDIR>=0. ! used to keep techs out of the game if the NASDAQ is on a decline
! but any other sector that shows life will be active for a few days. !ALL weather for month long 20 stocks
!will switch to non-tech sectors if they are hot when combosig=-1 !..code for stock picking--last few criteria
and [TCI]<65 and not FoundGaps
and ((combosig=-1 and notech) or combosig=1). ! this lets ANY stock get picked when the NASDAQ is on a buy
Weighted Action List Report
attached are the action and weighted action reports, in eds, which is real close to the system supplied reports (report module). change the constants to match what you usually run on reports, and don't forget to change to whatever list you want to run for (file/properties).
2 report tabs, 1 for wa report, another for the action report, both upside versions. i didn't code the downside reports. and i should note, AIQ wrote the original EDS - i just fixed it and modified it slightly, the original work is AIQ's, not mine.
note that there are a few oddities in the wa report, not reflected in the code - this version of the code matches the report as close as i can get it, at least till the next time someone prompts me to look at it ;)
first oddity - wa report looks back x days, action report looks back x+1 days, for looking for an up er.
next item, in the report (and attached eds) the system does not look for a phase reversal upside followed a day or 2 later by a reversal downside, followed by another reversal up. it does make sure phase is currently going up, but doesn't check for whipsaws (up/down/up). if i recall correctly, you will occasionally see stocks on the weighted action report which have had a upside phase reversal a few days ago, followed by a downside reversal a day or 2 later, then another up. personally, i don't trade such stocks. your
mileage may vary, disclaimer, do what you will with it , i'm not liable (too many lawyers in my family i guess :) )
the other thing i'm not checking for in the code is an up er followed a few days later by a down er. an example would be yhoo - up er on 1/3, down er on 1/11, yet its on the report. same comment as above. i disagree with the report specs in this case - i don't want to see it if an up er has been
followed by a down one, regardless of current phase direction. others
however would view the down er as unconfirmed, and thus a non signal, due to lack of down phase action, so they remain on the report. other versions of this EDS that i've passed around in the past do check for an intervening down er, and exclude such stocks - this version doesn't as i tried to match the report. same disclaimer, check your charts before pulling the trigger.
! ---! eds to match weighted action report
! modified by pewd from original version supplied by AIQ
! check what settings you have on wt act rpt if youre trying to match this eds to the report,
! eg., make sure youre running for the same list, price, and volume filters as on the wt. act. report
!
! ER to upside 95 or greater last 10 days confirmed by change in direction of the Price Phase indicator in the last 3 days.
!
! modifications to original (aiq) version: ! pewd 7/99 added price filter, $10 and up
! pewd 7/99 added volume filter, 100,000 shares and up ! pewd 7/99 changed up er lookback from 10 to 6
! pewd 7/99 corrected logic error in PhaseChangeUp test, eliminate stocks that turned phase down on report date
! pewd 7/99 added 4th day to PhaseCHANGEUPup rule to match reports module ! pewd 7/99 added er, price, and a few other columns to report
! pewd 1/01 added action report tab, cleaned up my sloppy code from 99
! --
---! define report constants
define minprice 10. ! minimum price
define minvolume 1000. ! minimum volume, in lots (x 100) define nbrdays 11. ! nbr days to look for an up er define miner 90. ! minimum er value to trigger
define nbrphasedays 4. ! number of days to look back for phase reversal ! check for minimum price
! check for minimum volume
volumefilter if [Volume ESA] > minvolume.
phasereverse if val([phase],1)<[phase] and val([phase],2)>val([phase],1). goodphase if ^[phase]>^val([phase],1).
phasechangeup if scanany(phasereverse,nbrphasedays) and goodphase. ! look for ER buy signal
WA_Report_Up if HiVal([ER UP],nbrdays) >=MinER and PhaseChangeUp and PriceFilter and VolumeFilter.
Action_Report_Up if HiVal([ER UP],nbrdays-1) >=MinER and PhaseChangeUp and PriceFilter and VolumeFilter.
! report columns !pewd july 99
UpER is hival([ER UP],nbrdays). Exch is MarketCode(). Change is [close]-val([close],1). Security_name is Description(). Trend is [TS]. DeltaTrend is [DTS]. GroupSymbol is TickerUDF(RSTicker(),Symbol()). GroupName is TickerUDF(RSTicker(),Security_name). GroupTS is TickerUDF(RSTicker(),Trend). GroupDTS is TickerUDF(RSTicker(),DeltaTrend). SectorSymbol is TickerUDF(RSTicker(),GroupSymbol). SectorName is TickerUDF(SectorSymbol,Security_name). SectorTS is TickerUDF(SectorSymbol,Trend). SectorDTS is TickerUDF(SectorSymbol,DeltaTrend).
PRICE/VOLUME CRITERIA?
Gap is IFF([low]>Val([High],1) and ([low]/Val([High],1))>=1.15 and ([close]/Val([High],1))>=1.15,1,0).
Keep if [volume esa]>500 and Sum(Gap,100)=0 and Countof([volume]>0,100)>=98.
HIGH JUMP CANDIDATE SELECTION
I wrote the HighestHighJump scan and I use it just as you do to develop a list of trading candidates.
The inventor of the HJ indicator is Ian Woodward. He uses it as a gauge of how extended a stock is off its base. When the numbers get over certain cutoffs (on a current basis), he says there is a high danger of a major correction in the stock.
After I programmed the indicator in AIQ, I noticed that some stocks got to much higher HJ numbers than others. I also noticed that most of the High Growth stocks that Ian (and William O'Neil) define by other means (eg EPS rank, RS and Group RS etc) could be defined by a high peak readings in their maximum HJ levels. So I wrote the scan that looks back and picks out the highest reading over a lookback period of five years or less if less trading history. The ones with the highest readings were always the high growth and/or momentum stocks. What this indicator does is measure the ability of a stock to rise rapidly. The higher the reading the faster the stock
has been able to climb.
I am working on additional ways to develop trading lists and I will post more on this when I have time. I asked other traders to propose how they would go about
developing
a short list of stocks. I received several good suggestions and I want to thank those who contributed.
Here is the code for the HJ (but not the Highest High Jump) for those of you who are wondering what it is:
!HIGH JUMP INDICATOR - from Ian Woodward
!For Ian Woodward's standard HighJump set ST MA to 17, IT MA to 50, LT MA to 200. STMA is simpleavg([close],17). ITMA is simpleavg([close],50). LTMA is simpleavg([close],200). STdmaPct is ([close]-STMA)/STMA*100. ITdmaPct is ([close]-ITMA)/ITMA*100. LTdmaPct is ([close]-LTMA)/LTMA*100. Highjump is STdmaPct + ITdmaPct + LTdmaPct.
VOLUME SPIKE
*******************
!ER is 95 or above within last 5 days
!Strength of Group is based on trend score , or high positive value for DTS ! P-Vol is higher than yesterday and todays P-Vol is higher than its ESA. ! Spike if volume is 50% above the ESA of volume
!Buy the stock when all rules are passed. TS is [TS]. DTS is [DTS]. Description is Description(). GroupDTS is TickerUDF(RSTicker(),DTS). GroupTS is TickerUDF(RSTicker(),TS). Group is TickerUDF(RSTicker(),Description).
GroupTSHigh if GroupTS>90. GroupDTSHigh if GroupDTS>20. ERUP if HiVal([er up],5) >= 95.
PVolUP if VAL([P-Vol],1) < [P-Vol] and [P-Vol] > [P-Vol ESA] . VolSpike if [volume] >= [volume esa] * 1.5.
BuyMid2 if HiVal([er up],5) >= 95 and PVolUP and VolSpike and (GroupTSHigh or GroupDTSHigh)
***********************************
VARIABLE PROFIT PROTECT STOP, LOSS STOP AND TIME STOP
!Variable Profit Protect Stop, Loss Stop and Time Stop ! Coded by Rich Denning
! Date: 3/10/2001
! This file was written for the AIQ Yahoo Groups Message Board and is for demonstration
! and educational purposes only. Distribution outside of this message board or use ! in commercial applications is prohibited.
! If any of this file is copied, in part or in whole, this header must be included with it. !The following requires AIQ version 6.0 and can only be used as an exit rule in a bactest of a simulation
P is {Position Days}.
MaxProfitR is {Position High Price}/{Position Entry Price}. Profit is [close]-{Position Entry Price}.
MaxProfit is HighResult(Profit,P).
Stop1 is {Position Entry Price}+MaxProfit*0.70. Stop2 is {Position Entry Price}+MaxProfit*0.80. Stop3 is {Position Entry Price}+MaxProfit*0.90. Stop4 is {Position Entry Price}+MaxProfit*0.95. Stop5 is {Position Entry Price}+MaxProfit*0.98. Stop6 is {Position Entry Price}+MaxProfit. ! Protect 70% of profit above 50%
! Protect 80% of profit above 60% ! Protect 90% of profit above 70% ! Protect 95% of profit above 80% ! Protect 98% of profit above 90% ! Protect 100% of profit above 100%
ProfitProtect if [close]<iff(MaxProfitR>1.5 and MaxProfitR<1.6,Stop1, iff(MaxProfitR>1.6 and MaxProfitR<1.7,Stop2,
iff(MaxProfitR>1.7 and MaxProfitR<1.8,Stop3, iff(MaxProfitR>1.8 and MaxProfitR<1.9,Stop4, iff(MaxProfitR>1.9 and MaxProfitR<2.0,Stop5, iff(MaxProfitR>2.0,Stop6,0)))))).
LossStop if [close]<{Position Entry Price}*0.75. !TimeStop if {Position Days}>=20.
BUY FOR STOCKS IN A SECTOR !Scan for DTUniversity
Price if [close]<51 AND [close]>19. AvgVol is [Volume ESA].
Vol if ExpAvg(AvgVol,14)>1200 AND [Volume]>1200. !To-days range
Range is [high]-[low].
HighRange If ExpAvg(Range,14)>4 AND Range>4 . CCIUp IF Slope([CCI],5)>0 AND [CCI]>0.
Avgvcrossover IF [ST ESA]>[IT ESA] AND ( Val([ST ESA],1)<Val([IT ESA],1)).
Security_nameis Description(). GroupSymbol is TickerUDF(RSTicker(),Symbol()). GroupName is TickerUDF(RSTicker(),Security_name). Semiconductor if GroupSymbol="ETSEMMFG". ComputerSoftware if GroupSymbol="CSSFTETR". Internet if GroupSymbol="INECOMM". ComputerHardware if GroupSymbol="CPMFGS". Biotech if GroupSymbol="MDBIOGEN".
Buy IF Price AND Vol AND HighRange AND CCIup AND (semiconductor OR ComputerSoftware OR Internet OR ComputerHardware OR Biotech).
BOLLINGER BANDS > ===================================== > varudf is [close]. > variance is Variance(varudf,21). > stddev is Sqrt(Variance). > ma is SimpleAvg(varudf,21). >
> UpperBB is 2 * StdDev + ma. > LowerBB is ma - 2 * StdDev.
> =======================================
Slope etc
While I am at it...here is something that is VERY valuable to your bag of EDS tricks. It is the calculation used to calculate the internal function "slope". The math may be way over some peoples heads,but the most important thing about having this is the ability to calculate the INTERCEPT point!
Alan Nathan asked about doing Standard Deviation lines based on the linear
regression line. In order to do this you must have the intercept point. So I coded the internal Slope function in EDS so you can now have this. I put together an EDS file
that does the math, and creates "bands" based on 2 standard deviations above/below the intercept point of the linear regression line. I hope this is close to what Alan has asked for. You can put UpperSD and LowerSD and Intercept as Custom Indicators and plot the bands.
! Author: Dale Paul (AIQ) ! Date: 4/7/2001
! How to calculate a slope and intercept using linear regression ! how many days are we running this for?
define constdays 4.
days is HasDataFor(constdays). ! value (in this case the close) varudf is [close].
LINEAR REGRESSION CALCULATION USING THE LEAST MEANS SQUARED METHOD day is offsettodate(month(),day(),year())+1.
dayX2 is day * day. sx is Sum(day,days). sx2 is Sum(dayX2,days). sy is Sum(varudf,days).
sxy is Sum( day * varudf ,days). d is ( days * sx2) - (sx * sx).
slope is ((days * sxy) - ( sx * sy)) / -d. ! same result as internal Slope function b is ((sx2 * sy) - (sx * sxy)) / d.
Intercept is slope + b.
! get the standard deviation of the close variance is Variance(varudf,days). stddev is Sqrt(Variance).
! Compute our Deviation Bands UpperSD is 2 * StdDev + Intercept. LowerSD is Intercept - 2 * StdDev. all if 1.
LINEAR REGRESSION METHOD BASED INDICATORS
There was an error in my linear regression code--the intercept was claculated incorrectly. Thanks to John R for pointing this out.
define TimeFrame 30.
b is slope([close],TimeFrame).
intercept is sum([close],TimeFrame)/TimeFrame - (b * (TimeFrame+1)/2). expectedLast is intercept + (TimeFrame*b).
SECTOR DIVERGENCE !!! Sector Divergence
!!! EDS Author. Ron Stockstill !!! Date. 4/9/2001.
!!! Define constants
define slopelen 20. ! determine length of lookback for slope function to see if a divergence in price
define divpct 15. ! set divergence percentage Sym is symbol().
Desc is description().
GroupSym is TickerUDF( RSTicker(),symbol()). SectorSym is TickerUDF( RSTicker(),groupsym).
stock if stock(). ! Only want stock symbols. MedSector if SectorSym = "medical". ! Check for medical sector TechSector if SectorSym = "electric".
Biotech if GroupSym = "medic1". ! AIQALL list uses medic1 for biotech
Semi if GroupSym = "Elect10".
Slope is Slope([close], slopelen). ! Calculate slope of linear regression line
GroupSlope is TickerUDF(groupsym,slope). ! Calculate slope of linear regression line for group symbol
groupstock if Semi or Biotech. ! Only want symbols from semiconductors or biotechs
Pctgain is 100*([close] - Val([close],slopelen))/Val([close],slopelen). ! Calculate percent gain using slope length as lookback period.
groupPctGain is TickerUDF(groupsym,Pctgain).
Totalgain is Pctgain + ABS(groupPctGain). ! Use Absolute value as a negative slope will normally but not always have a negative return.
Diverge if stock and groupstock and Slope > 0 and GroupSlope < 0 and Totalgain > divpct. COUNTOF
Rule if [close] > simpleavg([close],20).
CountRule if Countof(Rule,1)=1 and Countof(Rule,2) =1. ! False on day n+2; True on day n+1
================================================ Tom,
Rule is true if close is greater than the 20 day sma.
Now suppose you have two days in a row of closes above 20 day sma. Rule will be true for today and also Rule will be true for yesterday. Thus Countof(Rule,2) will = 2 (1 + 1). Thus, Countof(Rule,2)=1 will be FALSE.
Now CountRule is only true when
yesterday is FALSE and today is TRUE. If today is below the
moving average, the Countof(Rule,1) will be zero and CountRule will be false. This leaves the only combination that CountRule can be true; yesterday below the SMA and today above the SMA.
You could have used Valresult(rule)<> 1 and rule=1 for CountRule.
ATR AND WILDER’S RSI
!========================== !!! Average True Range.
TR is Max([High], Val([Close], 1)) - Min([Low], Val([Close], 1)). ATR27 is ExpAvg(TR, 27). !! Equivalent to ATR14 using Wilder's smoothing.
!======================== PlusDM1 is [High] - Val([High], 1). PlusDM2 is Max(PlusDM1, 0).
PlusDM is PlusDM2 * (PlusDM2 > MinusDM2). AvgPlusDM is ExpAvg(PlusDM, 27).
PlusDMI is AvgPlusDM * 100 / ATR27. !! Plot wuth MinusDMI as 2-line indicator.
MinusDM1 is Val([Low], 1) - [Low]. MinusDM2 is Max(MinusDM1, 0).
MinusDM is MinusDM2 * (MinusDM2 > PlusDM2). AvgMinusDM is ExpAvg(MinusDM, 27).
MinusDMI is AvgMinusDM * 100 / Atr27. !! Plot with PlusDMI as 2-line indicator.
DlDiff is PlusDMI - MinusDMI. !! Plot as histogram. Same as AIQ's DirMov.
DlSum is PlusDMI + MinusDMI. DX is Abs(DlDiff) * 100 / DlSum.
ADX is ExpAvg(Dx, 27). !! PLOT ADX as single line indicator with support at 24, same as AIQ's ADX.
!==========================
RELATIVE STRENGTH
!RELATIVE STRENGTH STUDY by Rich Denning 10/23/99
!Run against your group or sector structure by clicking on file, properties, then put in group list eg AIQALL and check groups only
!Indicatior for ranking RS of stocks, groups or sectors (you can set these up a custom indicators on the charts)
RS4 is SLOPE([RS Indx],4)*100. RS9 is SLOPE([RS Indx],9)*100. RS17 is SLOPE([RS Indx],17)*100. RS50 is SLOPE([RS Indx],50)*100. RS200 is SLOPE([RS Indx],200)*100. RScomposit is RS17 + RS50 + RS200.
!Is trend up or down in various time frames? my settings are st=17, it=50, lt=200 STtrend is SLOPE([st ma],5).
ITtrend is SLOPE([it ma],5). LTtrend is SLOPE([lt ma],5). !List of all tickers
List if 1=1.
Description is description().
Group is TickerUDF(RSTicker(),Description). Sector is TickerUDF(RSTicker(),Group).
!List of positive relative strength tickers (short term) Define Length1 17. ! Or 4,9
RS1 is 100*SLOPE([RS Indx], length1). STposRS if RS1 > 0.
!List of positive relative strength tickers (long term) Length2 is 200. !Or 50, 100
RS2 is SLOPE([RS Indx],length2)*100. LTposRS if RS2 > 0.
!List of negative relative strength tickers (short term) STnegRS if RS1 < 0.
!List of positive relative strength tickers (long term) LTnegRS if RS2 < 0.
!List all positive tickers
AllPos if STposRS and LTposRS and RScomposit > 0 and [DTS]>=0 and [TS]>0 and [VA pct]>0.
!List HGS groups only
HGSgroup1 if 1=1. !Don't know how to do this yet
!HGSgroup if Symbol() is "COMP1" HGS group includes all Computer, Electrical, Telecom, Medical plus selected others
RECURSION
!! Adaptive Moving Average (Perry Kaufman). ! (with allowances for AIQ recursion).
! EDS code by HHP. !******************************************* MA Long Term: Mov(C,30,E); Mov(C,35,E); Mov(C,40,E); Mov(C,45,E); Mov(C,50,E); Mov(C,55,E); MA Short Term: Mov(C,5,E); Mov(C,8,E); Mov(C,11,E); Mov(C,14,E); Mov(C,17,E);
Adaptive Moving Average: period:=Input("Period",1,250,13); DifP:=Abs(C-Ref(C,-1)); SC:=Power((Abs(C-Ref(C,-period)) / Sum(DifP,period)) * 0.60215{2/3-2/31} + 0.06452{2/31},2); AMA:=PREV+(SC*(C-PREV)); AMA !*********************************************** Define ERPds 10. ! Efficiency Ratio Periods.
Define FPds 2. Define SPds 30.
Dir is [Close] - Val([Close], ERPds). dPr is [Close] - Val([Close], 1). Vlty is Sum(Abs(dPr), ERPds). ER is Dir / Vlty.
Fastest is 2 / (FPds + 1). Slowest is 2 / (SPds + 1).
Smooth is ER * (Fastest - Slowest) + Slowest. C is Smooth * Smooth.
!=====================
! EDS Recursion. Original coding by Dale Paul. Define RWin 100. ! Recursion window.
DaysInto is ReportDate() - RuleDate(). Stop if DaysInto > RWin.
StopADPT is IFF(Stop, [Close], ADPTMA).
ADPTMA is C * [Close] + (1 - C) * ValResult(StopADPT, 1). !========================
!! AMA Filter.
Define FltWin 20. ! Filter Window periods). Define FltPct 15.
dAMA is ADPTMA - ValResult(ADPTMA, 1).
MetaStock Code
PRIMARY BUY SIGNAL
((MACD()>Mov(MACD(),9,E) AND C>Mov(C,5,E) AND C>Mov(C,15,E))=TRUE) AND
(Ref(MACD()>Mov(MACD(),9,E) AND C>Mov(C,5,E) AND C>Mov(C,15,E),-1)=FALSE)
AND
BarsSince(Ref( ((MACD()>Mov(MACD(),9,E) AND C>Mov(C,5,E) AND C>Mov(C,15,E))=TRUE) AND (Ref(MACD()>Mov(MACD(),9,E) AND C>Mov(C,5,E)
AND C>Mov(C,15,E),-1)=FALSE),-1)) >=
BarsSince(Ref(Cross(0.955*Ref(C,-2),C),-1))
PRIMARY SELL SIGNAL
Cross(0.955*Ref(C,-2),C) AND
BarsSince(((MACD()>Mov(MACD(),9,E) AND C>Mov(C,5,E) AND C>Mov(C,15,E))=TRUE) AND (Ref(MACD()>Mov(MACD(),9,E) AND C>Mov(C,5,E)
AND C>Mov(C,15,E),-1)=FALSE)) <=
BarsSince(Ref(Cross(0.955*Ref(C,-2),C),-1))
and the MarketSpace Stock System which works with daily data.
MARKETSPACE STOCK SYSTEM
Primary Buy Signal
((MACD()>Mov(MACD(),45,E) AND C>Mov(C,25,E))=TRUE) AND
(Ref(MACD()>Mov(MACD(),45,E) AND C>Mov(C,25,E),-1)=FALSE) AND BarsSince(Ref(((MACD()>Mov(MACD(),45,E) AND C>Mov(C,25,E))=TRUE) AND
(Ref(MACD()>Mov(MACD(),45,E) AND C>Mov(C,25,E),-1)=FALSE),-1)) >= BarsSince(Ref(Cross(0.9*Ref(C,-7),C),-1))
Primary Sell Signal
(Cross(0.9*Ref(C,-7),C) AND BarsSince(((MACD()>Mov(MACD(),45,E) AND C>Mov(C,25,E))=TRUE) AND (Ref(MACD()>Mov(MACD(),45,E) AND C>Mov(C,25,E),-1)=FALSE))<= BarsSince(Ref(Cross(0.9*Ref(C,-7),C),-1)))
SMOOTH STOCKS
David,
Following are two explorations which will find stocks with a high percentage of relatively "smooth" stocks that have been trending up over the last a) three months and b) twelve months.
In the Exploration Editor, put the following in one of the "columns": (C - Ref(C,-252)) / Ref(C,-252) *100
This will give you the percentage gain over the last twelve months.
Some of the other columns could have the current closing price, average volume or whatever has meaning to you.
In the Filter, put one of the following, depending on whether you want a three month trend or a twelve month trend (or modify for some other period)
For three months:
(C / (1 + ((C - Ref(C,-64)) / Ref(C,-64)))) <= (C / (1 + ((C - Ref(C,-21)) / Ref(C,-21)))) AND (C / (1 + ((C - Ref(C,-21)) / Ref(C,-21)))) <= (C / (1 + ((C - Ref(C,-5)) / Ref(C,-5)))) AND (C / (1 + ((C - Ref(C,-5)) / Ref(C,-5)))) <= C AND
colB >= 20 {I use Column B for my twelve month percentage and don't want to see any stocks with less than a 20% trailing twelve month gain.}
For twelve months:
(C / (1 + ((C - Ref(C,-252)) / Ref(C,-252)))) <= (C / (1 + ((C - Ref(C,-126)) / Ref(C,-126)) AND (C / (1 + ((C - Ref(C,-126)) / Ref(C,-126)))) <=
(C / (1 + ((C - Ref(C,-64)) / Ref(C,-64)))) AND (C / (1 + ((C - Ref(C,-64)) / Ref(C,-64)))) <= (C / (1 + ((C - Ref(C,-21)) / Ref(C,-21)))) AND (C / (1 + ((C - Ref(C,-21)) / Ref(C,-21)))) <= (C / (1 + ((C - Ref(C,-5)) / Ref(C,-5))) AND (C / (1 + ((C - Ref(C,-5)) / Ref(C,-5)))) <= C AND colB >= 20
After running the exploration, I sort on the twelve month column (Column B) to get the biggest 12 month gainers on top of the list. Many of the stocks in this list (not all) will be "smooth" gainers and momentum stocks. Then comes the question, how to make money from these stocks?
Jim Dawson
---Original
Message---From: [email protected]
[mailto:[email protected]]On Behalf Of David DeFina
Sent: Friday, June 08, 2001 12:07 PM
To: [email protected]; [email protected] Subject: Finding "smooth" stocks?
I’m interested in identifying stocks that have “smooth” transitions up and down, meaning when a stock is increasing day to day that the lows of the previous day aren’t violated, and vice versa. Also, stocks that have a tendency to increase or decrease multiple days rather than reversing all the time.
I know stocks don’t behave consistently all the time, but I’m looking to rank stocks from a specific universe that have the propensity to trade smoothly. Any input would be appreciated.
Thanks, David DeFina
Bressert Cycle Indicators
I saw that some were interested in the Bressert cycle indicators for use in Metastock. Here is my implementation of the cycle 10 indicator; I have been using it for more than one year as part of explorations. If you want the cycle 5, just substitute 5 for the 10 in the formulas.
Good luck I find these cycle indicators helpful.
The below should be installed as a custom indicator. It can then be used on charts and called for in explorations.
{double smoothed stochastic 10 period}
{demominators defined to eliminate divide by zero errors}
denom1:= If(HHV(H,10)-LLV(L,10)>0, HHV(H,10)-LLV(L,10), 1); P1:= Mov(((C-LLV(L,10))/ denom1)*100,3,E);
denom2 := If(HHV(P1,10)-LLV(P1,10)>0, HHV(P1,10)-LLV(P1,10), 1); Mov(((P1-LLV(P1,10))/denom2)*100,3,E)
EXPLANATION OF THE MCCLELLAN OSCILLATOR
(DAILY ADVANCING ISSUES -(minus) DAILY DECLINING ISSUES)= B McClellan OSC= MOV(B,19,E)- MOV(B,39,E)
WHERE: -100 OR LESS IS OVERSOLD (BULLISH)
WHERE: +100 OR GREATER IS OVERBOUGHT (BEARISH) Note that B is just a constant for illustration purposes only. Advance Decline Line
{To display the Advance Decline Line, create a composite security in The DownLoader of Advancing Issues minus Declining Issues. Open a chart of the composite and plot this formula}
Cum(CLOSE) McClellan Oscillator
{To display the McClellan Oscillator, create a composite security in The DownLoader of Advancing Issues minus Declining Issues. Open a chart of the composite and plot this custom indicator.}
Mov(CLOSE,19,EXPONENTIAL) - Mov(CLOSE,39,EXPONENTIAL) mike arnoldi CMO FILTER CMO Filtered: momu:=If(C>Ref(C,-1),C-Ref(C,-1),0); momd:=If(C<Ref(C,-1),Ref(C,-1)-C,0); A1:=Stdev(momu,100); A2:=Stdev(momd,100); Mup:=If(C-Ref(C,-1)>A1,C-Ref(C,-1),0); Mdn:=If(Ref(C,-1)-C>A2,Ref(C,-1)-C,0); Periods:=Input("Length",5,100,13); CMOF:=100*((Sum(Mup,Periods)-Sum(Mdn,Periods)) /(Sum(Mup,Periods)+Sum(Mdn,Periods))); Sig:=Mov(CMOF,10,S); Hist:=CMOF-Sig; Hist; Sig; CMOF; THRUST OSCILATOR: AI:= Security("D:\Stocks\Market Indicators\X.NASD-A",C); AV:= Security("D:\Stocks\Market
Indicators\X.NASD-A",V); DecI:= Security("D:\Stocks\Market Indicators\X.NASD-D",C); DecV:= Security("D:\Stocks\Market Indicators\X.NASD-D",V); TO:=(((AI*AV)-(DecI*DecV))/((AI*AV)+(DecI*DecV)))*100; Periods1:=Input("length1",3,100,21); Periods2:=Input("length2",3,100,5); IND:=Mov(TO,Periods1,S); sig:=Mov(IND,Periods2,S); sig; IND;
You will have to create securities of advancing issues,declining issues,advancing volume, declining volume first then type in the directory where they are located Henry kaczmarczyk
THRUST OSCILLATOR
the thrust osc, the metastock formula
AI:= Security("D:\Stocks\Market Indicators\X.NASD-A",C); AV:= Security("D:\Stocks\Market Indicators\X.NASD-A",V); DecI:= Security("D:\Stocks\Market Indicators\X.NASD-D",C); DecV:= Security("D:\Stocks\Market Indicators\X.NASD-D",V); TO:=(((AI*AV)-(DecI*DecV))/((AI*AV)+(DecI*DecV)))*100; Periods1:=Input("length1",3,100,21); Periods2:=Input("length2",3,100,5); IND:=Mov(TO,Periods1,S); sig:=Mov(IND,Periods2,S); sig; IND;
You will have to have created securities of advancing issues,declining issues,advancing volume, declining volume
MIDAS VOLUME WEIGHTED AVE PRICE-SUPPORT/RESIST From P.67, TASC, May 2001
MIDAS Volume Weighted Ave Price-Support/resist.} sm:=Input("Starting Month",1,12,1);
sd:=Input("Starting day of month",1,31,1); sy:=Input("Starting year",1980,2100,2000);
start:= sd = DayOfMonth() AND sm = Month() AND sy = Year(); pv:= MP()*V;
denom:=If(Cum(V)-ValueWhen(1,start,Cum(V))=0,1,Cum(V)-ValueWhen(1,start,Cum(V)));
STOCHASTIC CROSS TRADING SYSTEM
QUESTION
How would I write a MetaStock System Tester for:
Buy: stoch(12,3) has fallen below 36 and then crosses above its 6 day WMA.
Sell: stoch(12,3) rises above 52 and then falls below its 3 day WMA OR 3 day WMA of stoch crosses above 55.
ANSWER
stoch(12,3)<36 and cross(stoch(12,3),mov(stoch(12,3),6,w)) stoch(12,3)>52 and cross(mov(stoch(12,3),3,w),stoch(12,3)) or mov(stoch(12,3),3,w)>55
TSI AND ERGODICS INDICATORS
Contributed by Christian Baude [email protected]
True Strength Index (TSI) - "Momentum, Direction and Divergence", William Blau, Pub: John Wiley& Sons (see also TASC Jan '93, "Stochastic Momentum" gives the formula for the true strength index. This article refers to an older article by Blau in the Jan '91 TASC "Double Smoothed Stochastics")
TSI(close,r,s) = 100*EMA(EMA(mtm,r),s / EMA(EMA(ImtmI,r),s) >> Your formula expanded
>>
100*(Mov(Mov(ROC(C,1,$),25,E),13,E)/Mov(Mov(Abs(ROC(C,1,$)),25,E),13,E)) Numerator:
mtm = one-day momentum of close r-day EMA of mtm {25 day}
s-day EMA {13 day double smoothing} Denominator:
ImtmI = absolute value of mtm r-day EMA of ImtmI
s-day EMA {double smoothing} TSI(close,25,13)
Signal Line = EMA(TSI,7) thresholds at +25, 0, -25
5 day EMA of 20 day EMA of 1 day momentum {little lag Vs smoothing of price}
Ergodic Oscillator = Ergodic + Signal line {TSI version of Slow Stochastic} Ergodic(close,r) = TSI(close,r,5) {double smoothing is fixed at 5}
Signal Line(close,r) = EMA(TSI(close,r,5),5) r = 20days
Interesting comparison chart between 20 Slow Stochastic and 20 Erodic {more head room in oversold-bought areas}
another chart showing Ergodic Osc = TSI(close,32,5) with 5-day EMA signal line
Trading Ergodics with the Trend – Rules
1. Enter or hold position only when slope of Ergodic Signal line has the same direction as the trend
2. Stand aside when slope of Ergodic Signal Line is in the opposite direction of trend 3. Enter or exit position when Ergodic and its Signal Line cross
Slow TSI Trend = TSI(close,64,64) {? weekly looking chart - very little lag} Thresholds set at +15 & -15
Trading Ergodics with Slow TSI Trend
1st window - Slow TSI Trend = TSI(close,64,64) 2nd window - Ergodic Osc = TSI(close,64,5)
RELATIVE STRENGTH OF STOCK TO INDEX
Here is what I have been using as Relative strength (RSC)Compared to the XAO Column A: CLOSE
Column B: If( (Ref(Div(CLOSE,P),-4) > Ref(Mov(Div(C,P),30,E),-4)),1,0) Column C: If( (Ref(Div(CLOSE,P),-3) > Ref(Mov(Div(C,P),30,E),-3)),1,0) Column D: If( (Ref(Div(CLOSE,P),-2) > Ref(Mov(Div(C,P),30,E),-2)),1,0) Column E: If( (Ref(Div(CLOSE,P),-1) > Ref(Mov(Div(C,P),30,E),-1)),1,0) Column F: (( C/P - Mov(C/P,30,E)) / Mov(C/P,30,E)) * 100
Filter: Div(C,P)> Mov(Div(C,P),30,E) AND colB=1 AND colC =1 AND colD = 1 AND colE =1
I name columns B - E period 1, 2, 3, etc.
Open The chart of the index you wish to get the relative strength of the securities on make periodicity "Week".
In the options area of the exploration editor change to Week.
This formula will select securities that have outperform the index over the last 5 weeks. The formula in column F provides a way to rank the securities in terms of their recent performance relative to the index.
Frederick W McKenzie
FLEXIBLE PARAMETER BOLLINGER BAND
SYSTEM
N:=Input("Lookback Period", 9, 220, 90); M:=N; {Period used for Momentum Index} SD:=1.5; {Number of Stdev's around FlexPivot} MI:= CMO(C ,M ) / 100; { Momentum Index } MA:= Mov(C, N, S); { Moving Average } FlxP := If( MI > 0,
{ THEN }
MA + (MI * (HHV(C, M) - MA)), { ELSE }
MA + (MI * (MA - LLV(C, M))) ); { ENDIF } LBand := FlxP - SD * Stdev(INDICATOR, N); UBand := FlxP + SD * Stdev(INDICATOR, N); UBand; FlxP; LBand;
{from Andreas Grau}
DIVERGENCE TRADING SYSTEM
RSI(9) DIVERGENCE BUY:
If(RSI(9) >= HHV(RSI(9),19) AND CLOSE <HHV(CLOSE,19), 1,0) OR If(CLOSE <= LLV(CLOSE,19) AND RSI(9) > LLV(RSI(9),19), 1,0) RSI(9) DIVERGENCE SELL:
If(CLOSE >= HHV(CLOSE,19) AND RSI(9)<HHV(RSI(9),19),1,0) OR If(RSI(9) <= LLV(RSI(9),19) AND CLOSE > LLV(CLOSE,19),1,0) Substitute any formula for the "RSI(9)" in the above.
Mike Arnoldi
DYNAMIC ZONE WILLIAMS%R EXPLORATION ColA:
Mov(WillR(19),70,S)-(1.3185 * Stdev(WillR(19),70)) ColB:
Mov(WillR(19),70,s) Filter:
Cross(mov(WillR(19),70,s) , Mov(WillR(19),70,S)-(1.3185 * Stdev(WillR(19),70))) {from suggestions by J. Seed and A. Grau}
DYNAMIC ZONE WILLIAMS%R INDICATOR
I have written a Dynamic Zone Williams % R indicator that you may find useful. I have converted the Will%R to a +/- 50 oscillator. The formula is:
{DYNAMIC W%R}
PR:=Input("Enter Periods for W%R",1,100,14); PB:=Input("Enter Periods for BUY",1,100,20); PS:=Input("Enter Periods for SELL",1,100,20); {CONVERT W%R TO +/-50 OSC} DWR:=(Mov(WillR(PR),2,S))+50; UpZone:=Mov(DWR,PS,S)+(1.3185 *Stdev(DWR,PS)); LwZone:=Mov(DWR,PB,S)-(1.3185 *Stdev(DWR,PB)); MidZone:=(UpZone + LwZone)/2; MidZone; UpZone; LwZone; DWR
This will plot 3 dynamic zones and a Dynamic Williams%R. To use in an exploration you would need to use the Fml Var call function of the indicator.
from J. S
NEGATIVE CLOSES – DOWN DAYS
EXPLORE THE NUMBER OF NEGATIVE CLOSES AND THE PERCENT LOSS CHANGING THE > WITH < WE HAVE THE POSITIVE DAYS .
COL A: BarsSince(C>Ref(C,-1)) {NUMBER OF NEG. DAYS ) COL B: ROC(C, LastValue(BarsSince(C>Ref(C,-1))),%) {PERCENT}
From "KAKARIDIS NIKOS"
FIND RSI ABOVE 80
Col A: RSI(14) Filter colA>=80 Filter enabled Yes Periodicity Daily Records required 18
KASE DEV STOP
Hi Lino,
Here is what I found for her Kase DevStop: {Cynthia Kase} Per1:=Input("Max Length",2,100,30); RWH:=(H-Ref(L,-Per1))/(ATR(Per1)*Sqrt(Per1)); RWL:=(Ref(H,-Per1)-L)/(ATR(Per1)*Sqrt(Per1)); Pk:=Mov((RWH-RWL),3,W); AVTR:=Mov(HHV(H,2) - LLV(L,2),20, S); SD:=Stdev(HHV(H,2) - LLV(L,2),20); Val4:=If(Pk>0,HHV(H-AVTR-3*SD,20),LLV(L+AVTR+3*SD,20)); Val3:=If(Pk>0,HHV(H-AVTR-2*SD,20),LLV(L+AVTR+2*SD,20)); Val2:=If(Pk>0,HHV(H-AVTR-SD,20),LLV(L+AVTR+SD,20)); Val1:=If(Pk>0,HHV(H-AVTR,20),LLV(L+AVTR,20)); Val4;Val3;Val2;Val1;
WOLF WAVE PATTERNS
Here's a simple Metastock exploration for locating Wolf Wave patterns. It doesn't hit all that often, but when it does, it's best to pay attention.
ColA: WW
Pa:=Trough(4,LOW,5); Pb:=Peak(3,HIGH,5); P1:=Trough(3,LOW,5); P2:=Peak(2,HIGH,5);
P3:=Trough(2,LOW,5); P4:=Peak(1,HIGH,5); P5:=Trough(1,LOW,5); tb:=TroughBars(1,LOW,5); tb<=4 AND p1 > pa AND pb < p2 AND p1 < p2 AND p1 < p4 AND p1 > p3 AND p3 > p5 AND p4 < p2 AND ColB: Tangents p1:=Trough(3,LOW,5); p3:=Trough(2,LOW,5); p5:=Trough(1,LOW,5); o1:=p1-p3; o2:=p1-p5; a1:=TroughBars(3,LOW,5)-TroughBars(2,LOW,5); a2:=TroughBars(3,LOW,5)-TroughBars(1,LOW,5); tan1:=o1/a1; tan2:=o2/a2; Abs(tan1-tan2) Filter:
colA AND colB <= .2
THE MARKET FACILITATION INDEX
In the August 1996 STOCKS & COMMODITIES, an article by Thom Hartle titled "The Market Facilitation Index" showed how to color chart bars to identify chart patterns based on changes in the market facilitation index and volume.
The first step is to create a new expert by choosing Expert Advisor from MetaStock's Tool menu, and then choose New from the Expert Advisor. Name the expert "Market Facilitation Index," enter any notes you like, and then click on the Highlights tab. Enter the following Highlights by choosing New, choosing the color and then entering the following formulas:
Green Bar (Green bar) ROC((H-L)/V,1,$) > 0 AND ROC(V,1,$) > 0
Fade Bar (Blue bar)
ROC((H-L)/V,1,$) < 0 AND ROC(V,1,$) < 0
Fake Bar (Dk Gray bar) ROC((H-L)/V,1,$) > 0 AND ROC(V,1,$) < 0
Squat Bar (Red bar)
ROC(V,1,$) > 0
After you have entered the four Highlights, click OK to finish editing the expert's properties. You can now right-click on the heading or background of any chart. Next, select Expert Advisor and then Attach from the Chart shortcut menu. Attach the market facilitation index expert, and it will highlight the four market facilitation patterns that were discussed in Hartle's article. Note: You can save a chart as a template with this expert attached, and then any time you apply the template to a chart, the market facilitation index expert will automatically attach to the chart. from Allan J. McNichol, EQUIS International
www.equis.com Sender: [email protected]
TRUE STRENGTH INDEX
Walter Lake [email protected]
True Strength Index = TSI
TSI(close,r,s) = 100*EMA(EMA(mtm,r),s / EMA(EMA(ImtmI,r),s) Numerator
mtm = one-day momentum of close r-day EMA of mtm {25 day}
s-day EMA {13 day double smoothing} Demoninator
ImtmI = absolute value of mtm r-day EMA of ImtmI
s-day EMA {double smoothing} TSI(close,25,13)
Signal Line = EMA(TSI,7) thresholds at +25, 0, -25 0
-5 day EMA of 20 day EMA of 1 day momentum {little lag Vs smoothing of price} 0
-Ergodic Oscillator = -Ergodic + Signal line {TSI version of Slow Stochastic} Erodic(close,r) = TSI(close,r,5) {double smoothing is fixed at 5}
Signal Line(close,r) = EMA(TSI(close,r,5),5) r = 20days
thresholds are +20, -20
interesting comparision chart between 20 Slow Stochastic and 20 Erodic {more head room in oversold-bought areas}
another chart showing Ergodic Osc = TSI(close,32,5) with 5-day EMA signal line 0 –
Trading Ergodics with the Trend - Rules
1. Enter or hold position only when slope of Erogodic Signal line has the same direction as the trend
2. Stand aside when slope of Erogodic Signal Line is in the opposite diretion of trend
3. Enter or exit position when Erogodic and its Signal Line cross 0
Thresholds set at +15 & -15
Trading Ergodics with Slow TSI Trend
1st window - Slow TSI Trend = TSI(close,64,64) 2nd window - Ergodic Osc = TSI(close,64,5)
{Fibonacci Trader-Dynamic Balance Point Step} DPS:=(ValueWhen(1,FmlVar("FT-DBP","DBC"), FmlVar("FT-DBP","DBC"))+ ValueWhen(5,FmlVar("FT-DBP","DBC"), FmlVar("FT-DBP","DBC"))+ ValueWhen(10,FmlVar("FT-DBP","DBC"), FmlVar("FT-DBP","DBC"))+ ValueWhen(15,FmlVar("FT-DBP","DBC"), FmlVar("FT-DBP","DBC"))+ ValueWhen(20,FmlVar("FT-DBP","DBC"), FmlVar("FT-DBP","DBC")))/5; DPS;
{created by Adam Hefner 9-1-99}
EXAMPLE OF HOW TO CREATE A MACD Crossover SYSTEM TEST IN MetaStock
Enter Long:
Mov(C,5,E) > Mov(C,13,E)
AND Mov(C,13,E) > Mov(C,40,E) Close Long:
Cross(Mov(C,13,E),Mov(C,5,E))
Now you can play with these combinations on both the enter long and close long side. For example,
keep the same Enter Long but change the Close Long to = Cross(Mov(C,40,E) ,Mov(C,5,E) )
This will keep you in the trade longer. You may want to enter when the 5 crosses above the 13 and not wait for the 40 OR, you may just want to use the 5 cross above the 40 and forget about the 13.
(created by David Evans) Trending Bandini Mov(C,2,S)> Mov(Mov(C,2,S),2,S) AND Mov(Mov(C,2,S),2,S)> Mov(Mov(Mov(C,2,S),2,S),2,S) AND Mov(Mov(Mov(C,2,S),2,S),2,S)>
Mov(Mov(Mov(Mov(C,2,S),2,S),2,S),2,S) AND Mov(Mov(Mov(Mov(C,2,S),2,S),2,S),2,S)> Mov(Mov(Mov(Mov(Mov(C,2,S),2,S),2,S),2,S),2,S) AND Mov(Mov(Mov(Mov(Mov(C,2,S),2,S),2,S),2,S),2,S)> Mov(Mov(Mov(Mov(Mov(Mov(C,2,S),2,S),2,S),2,S),2,S),2,S) AND Mov(Mov(Mov(Mov(Mov(Mov(C,2,S),2,S),2,S),2,S),2,S),2,S)> Mov(Mov(Mov(Mov(Mov(Mov(Mov(C,2,S),2,S),2,S),2,S),2,S),2,S),2,S) AND Mov(Mov(Mov(Mov(Mov(Mov(Mov(C,2,S),2,S),2,S),2,S),2,S),2,S),2,S)> Mov(Mov(Mov(Mov(Mov(Mov(Mov(Mov(C,2,S),2,S),2,S),2,S),2,S),2,S),2,S),2,S) AND Mov(Mov(Mov(Mov(Mov(Mov(Mov(Mov(C,2,S),2,S),2,S),2,S),2,S),2,S),2,S),2,S)> Mov(Mov(Mov(Mov(Mov(Mov(Mov(Mov(Mov(C,2,S),2,S),2,S),2,S),2,S),2,S),2,S), 2,S),2,S) AND Mov(Mov(Mov(Mov(Mov(Mov(Mov(Mov(Mov(C,2,S),2,S),2,S),2,S),2,S),2,S),2,S), 2,S),2,S)> Mov(Mov(Mov(Mov(Mov(Mov(Mov(Mov(Mov(Mov(C,2,S),2,S),2,S),2,S),2,S),2,S), 2,S),2,S),2,S),2,S) {created by Brookelise} Elliot Oscillator Mov((H+L)/2,5,S)-Mov((H+L)/2,34,S) GRII
This is a long formula so I broke it up into four pieces. GRII is derived from formulas 1, 2, and 3.
This is a nifty momentum oscillator that I've used for about five years to help me determine the direction of a given market when I have evidence that the market is about to turn. test formula 1 GRIIF1 tsf(C,9)-ref(tsf(C,9),-1) 2 GRIIF2 (ref(tsf(C,9),-1)-(ref(tsf(C,9),-2))) 3 GRIIF3 (ref(tsf(C,9),-2)-(ref(tsf(C,9),-3))) 4 GRII (tsf(C,9)-ref(tsf1))+((ref(tsf1)-ref(tsf2)))+((ref(tsf (C,9),-2)-(ref(tsf(C,9),-3))))
(written by Eddie Kwong)
SPECIAL TRIX
This is my own version of the well-known indicator, TRIX. I have had much better results with this than the canned version that comes with every charting program.
trix(12)-ref((trix(12)),-1) (created by Eddie Kwong)
{Fibonacci Trader - Fixed Balance Point} {NOTE: under Color/Style options, change plot to last "style" option}
{Fixed Balance Point Calculation}
FBC:=If(DayOfWeek()=1 AND Ref(DayOfWeek(),-1) <5, {then}(HighestSince(2,DayOfWeek()=1,H)+ LowestSince(1,DayOfWeek()=1,L)+ CLOSE)/3, {else}If(DayOfWeek()=5, {then}(HighestSince(1,DayOfWeek()=1,H)+ LowestSince(1,DayOfWeek()=1,L)+ CLOSE)/3, {else}0));
{Fixed Balance Point Plot}
FBP:=ValueWhen(1,FBC>0,FBC); FBP
{created by Adam Hefner}
GANN SWING HILOW ACTIVATOR
I was only able to implement Krausz's Gann Swing HiLow Activator in Metastock, because it's simply the average of the last three bars High (stop for short position or long entry) or Low (stop for long position or short entry) plotted one period forward: Ref(Mov(L,3,S),-1) or Ref(Mov(H,3,S),-1)
(from Thorsten Buhmann in Germany) Tema PV Binary Wave
Use of Tema PV Binary Wave and Tema QStick Formulas in MetaStock, from "JimG"
There are really two different ways to use these formulas. Since the Binary Wave is a smoothed addition of several technical indicators that each give +1 when bullish, 0 when neutral and -1 when negative, it makes sense that a positive number is bullish and rising numbers are bullish. Similarly negative numbers and falling numbers are bearish.
The QStick is really a candlestick type indicator, but can be read as bullish or bearish in same way as the Binary Wave.
The two traditional ways to play them are to buy on a rise from a negative peak and sell on a fall from a positive peak, or to buy on a zero cross over to the upside and sell on a zero crossover to the downside. Of course you can optimize and find various buy and sell levels as long as you understand what is bearish and what is bullish.
My own MetaStock system tests alerts on the BW crossing a moving average of itself and buys or sells on a confirmation of Qstick turning positive or negative respectively. Having said that, I don't make my buy an sell decisions from the indicators or the system test. I do use the system test as an initial screen and use a buy signal as a flag to move the stock to my watch list. I make all buying and selling decisions based on the trend channels. Over the years, I've found that works best for me.
RUGGERIO'S TREND
Ruggiero's rules for trend mode quoting his table 4.9: 1. If ADX crosses above 25, then the market is trending. 2. If ADX crosses below 20, then the market is consolidating.
3. If ADX crosses below 45 from above, then the market is consolidating. 4. If ADX rises from below 10 on 3 out of 4 days, then the market will start to trend.
5. If a trend is based on rule 4, it remains in effect until the 5 day difference in ADX is less than 0.
Ruggiero employs a 14 day ADX but that is based on T-Bonds data. He suggests employing the above rules as a filter. I make the indicator take the value +1 if trending, a -1 if consolidating according to the above criteria but I guess the zero is for the grey area
in between. Anyway according to definition: If a market is not trending it must be consolidating. However the zero may contain additional useful information. Ruggiero suggests tweaking the threshold values.
periods:=Input("Periods?",1,63,14);
If((ADX(periods)>25 AND (BarsSince(Cross(45,ADX(periods))) > BarsSince(Cross(ADX(periods),25)))) OR (ADX(periods) > 10 AND
Ref(ADX(periods),-4)<10 AND (ADX(periods)-Ref(ADX(periods),-5)>0)), 1, If(ADX(periods)<20 OR ((BarsSince(Cross(45,ADX(periods))) <
BarsSince(Cross(ADX(periods),25))) AND ADX(periods) < 45),-1,0))
AUTOMATIC METASTOCK TRENDLINE FORMULA Trough(1,L,10)+
((((Trough(1,L,10)-Trough(2,L,10)) /
(TroughBars(2,L,10)-TroughBars(1,L,10))) *TroughBars(1,L,10)))
This formula will draw a trendline from the most recent bottom. The L (low) can be changed to C (close) and the 10 can be changed to a different percent value.
You will also need to change the line style to the last one in the drop down list.
www.techanalysis.com
Those who know me have found out I vacillate between the VERY complicated and the very simple. I have been following a few stocks (medium volatility, but good %% moves both up and down over a 2-5 week time frame) and tracking them with about 15 templates on which most of the formulas that I have acquired reside. I wanted to track those that did best and those that were not as effective. I also tracked those formulas that were late in showing turns in momentum vs those that caught the turn close on. In this regard, I was looking for finding stocks at intermediate term lows and highs, NOT for indicators that identified stocks that had begun their run in any
direction and were destined to continue. As a result, I came up with a very simple indicator that showed a HIGH degree of accuracy in "turn-calling", but it did NOT give me indication of the strength or duration of the new move, only that it probably would occur. I believe that I have finally discovered that any signal of a change in momentum will NEVER give you a sense of strength or duration BY ITS VERY NATURE, and that only signals that identify stocks WITHIN a momentum trend (ie..already established) are able to do that. My momentum trend change indicator is derived from an intermediate trend indicator I've used for some time in MSWIN 6.0... PDI(34) - MDI(34)
My new formula is...
((PDI(8) - MDI(8)) - (PDI(21) - MDI(21))) + (PDI(13) - MDI(13))
Try it...I think you'll like it...and it's the same coding in WOW, I believe...BW Chan
I have posted an update to the RMTA and TOSC formula's, >the first formulas had an "Absolute Value" that wasn't called for >in the article ( I had mistaken the "[" "]" to mean "|" "|"). The new >formulas seem to plot exactly as the old...but I wanted the code >to match the math in the article.
>Thanks go out to William Golson for the help. >
>{Recursive Moving Trend Average} >Lb:=Input("Look-Back Period?",3,100,21); >Alpha:=2/(LB+1); >Bot:=(1-Alpha)*(If(Cum(1)<Lb,C,PREV))+C; >RMTA:=(1-Alpha)*(If(Cum(1)<Lb,C,PREV))+ > (Alpha*(C+Bot-Ref(Bot,-1))); >RMTA; > >{TOSC} >Lb:=Input("Look-Back Period?",3,100,21); >Alpha:=2/(LB+1); >Bot:=(1-Alpha)*(If(Cum(1)<Lb,C,PREV))+C; >RMTA:=(1-Alpha)*(If(Cum(1)<Lb,C,PREV))+ > (Alpha*(C+Bot-Ref(Bot,-1))); >TOSC:=RMTA-Mov(C,lb,E); >TOSC; > Best wishes, > Adam Hefner. e-mail: [email protected]
THE RECURSIVE MOVING TREND AVERAGE
Is the name of an article in the December issue of TASC, written by >Dennis Meyers. In it he describes what he calls " The Recursive >Moving Trend Average" . I wont go into all the article right now, but >here is my translation of his math (for Metastock 6.5) :
>
> {Recursive Moving Trend Average} >Lb:=Input("Look-Back Period?",3,100,21); >Alpha:=2/(LB+1); >Bot:=(1-Alpha)*(If(Cum(1)<Lb,C,PREV))+C; >RMTA:=(1-Alpha)*(If(Cum(1)<Lb,C,PREV))+ > (Alpha*Abs(C+Bot-Ref(Bot,-1))); >RMTA; >
>He then explains how to make an oscillator by subtracting an >Exponential MA form the Recursive MA... again here is the code: > > {TOSC} >Lb:=Input("Look-Back Period?",3,100,21); >Alpha:=2/(LB+1); >Bot:=(1-Alpha)*(If(Cum(1)<Lb,C,PREV))+C; >RMTA:=(1-Alpha)*(If(Cum(1)<Lb,C,PREV))+ > (Alpha*Abs(C+Bot-Ref(Bot,-1))); >TOSC:=RMTA-Mov(C,lb,E); >TOSC; > >
>Here is the code for System Testing; > >Buy Long: > >Lb:=opt1; >ent:=3; >Alpha:=2/(LB+1); >Bot:=(1-Alpha)*(If(Cum(1)<Lb,C,PREV))+C; >RMTA:=(1-Alpha)*(If(Cum(1)<Lb,C,PREV))+ > (Alpha*Abs(C+Bot-Ref(Bot,-1))); >TOSC:=RMTA-Mov(C,lb,E); >Cross(tosc,(0-Abs(ent))) > >Sell short: > >Lb:=opt1; >ent:=3; >Alpha:=2/(LB+1); >Bot:=(1-Alpha)*(If(Cum(1)<Lb,C,PREV))+C; >RMTA:=(1-Alpha)*(If(Cum(1)<Lb,C,PREV))+ > (Alpha*Abs(C+Bot-Ref(Bot,-1))); >TOSC:=RMTA-Mov(C,lb,E);
>Cross((0+Abs(ent)),tosc1) >
>Opt1 is the look- back periods, of 3 to 30, and >Opt2 is the entry value of the oscillator, 0 to 5. >
>Now, after all the hours spent on figuring out the >code, I have discovered that the RMTA plots very similar to the DEMA, oh well...
> Adam Hefner.
> e-mail: [email protected]
Market Pressure - Ultimate:
This is the basic calculation:
If toadies close is greater than yesterdays close and
toadies volume is greater than yesterdays volume, write down toadies volume * close, otherwise,
If toadies close is less than yesterdays close and
toadies volume is less than yesterdays volume, write down todays volume as a negative number * close, otherwise write down 0.
Then add up the past 7 days and * 4, add this to the past 14 days total and * 2, add this to the past 28 days total.
Plot this grand total in your chart for each new trading day. Simple Interpretation:
Market Pressure - Ultimate can show divergences with the instrument it is plotted against.
It may show signs of support and resistance when the indicator hits areas of support/resistance on its own graph.
Comparing rates of change/moving averages of the indicator against that of the instrument may reveal accumulation/distribution pressures.
Market Pressure - Ultimate: Sum(If(C > Ref(C,-1) AND V > Ref(V,-1), V * C, If(C < Ref(C,-1) AND V < Ref(V,-1), Neg(V) * C,0)),7) * 4 + Sum(If(C > Ref(C,-1) AND V > Ref(V,-1), V * C, If(C < Ref(C,-1) AND V < Ref(V,-1), Neg(V) * C,0)),14) * 2 +