Traders' Tips from TASC Magazine
Targeting Your Pattern
Massimiliano Scorpio’s article, “Targeting Your Pattern,” describes a Easy Language Show Me study to analyze price patterns. Below is the formula to create a MetaStock Expert Advisor version of this study. Most of the Expert Advisor is contained in the Commentary and will produce a display similar to the example shown here. This is a mix of formatted text and formulas. You do not have to format your display to exactly match the sample output. Bolded and underlined text and bullets were used for esthetics but are not required.
To create the Expert Advisor in MetaStock:
- In the Tools menu, select Expert Advisor.
- Click New to open the Expert Editor for a new expert.
- In the Tools menu, select Expert Advisor.
- Type a name for the expert, like "Pattern Analysis"
- Click the Commentary tab.
- Enter the following text:
- Select the Symbols tab
- Click New to make a new symbol.
- Type the name of the symbol. (for example: "3535 pattern")
- Click in the condition window and type in the following formula:
target:=3535; p1:=Ref(L,-1)-ATR(10); p2:=Ref(L,-1); p3:=Ref((H+L)/2,-1); p4:=Ref(H,-1); p5:=Ref(H,-1)+ATR(10); patpos:=If(O<=p1,0, If(O>p1 AND O<=p2,1, If(O>p2 AND O<=p3,2, If(O>p3 AND O<=p4,3, If(O>p4 AND O<=p5,4, 5)))))*1000 + If(H<=p1,0, If(H>p1 AND H<=p2,1, If(H>p2 AND H<=p3,2, If(H>p3 AND H<=p4,3, If(H>p4 AND H<=p5,4, 5)))))* 100 + If(L<=p1,0, If(L>p1 AND L<=p2,1, If(L>p2 AND L<=p3,2, If(L>p3 AND L<=p4,3, If(L>p4 AND L<=p5,4, 5)))))* 10 + If(C<=p1,0, If(C>p1 AND C<=p2,1, If(C>p2 AND C<=p3,2, If(C>p3 AND C<=p4,3, If(C>p4 AND C<=p5,4, 5))))); patpos=target - Select the Graphics tab
- Choose a symbol (like diamond).
- Select a color for the symbol
- Choose whether to display the symbol above or below the price bar
- Click OK
- Additional symbols can be created by repeating steps 7-14. To find different patterns, change the number on the first line to the desired pattern. Make sure this line ends with a semi-colon.
- Click OK to close the Expert Editor.
Analysis of <Name>
(<Symbol>)as of <date>
The current bar has the Open/High/Low/Close pattern Writeval(p1:=Ref(L,-1)-ATR(10);
p2:=Ref(L,-1);
p3:=Ref((H+L)/2,-1);
p4:=Ref(H,-1);
p5:=Ref(H,-1)+ATR(10);
If(O<=p1,0, If(O>p1 AND O<=p2,1, If(O>p2 AND O<=p3,2, If(O>p3 AND O<=p4,3, If(O>p4 AND O<=p5,4, 5))))),5.0) Writeval(p1:=Ref(L,-1)-ATR(10);
p2:=Ref(L,-1);
p3:=Ref((H+L)/2,-1);
p4:=Ref(H,-1);
p5:=Ref(H,-1)+ATR(10);
If(H<=p1,0, If(H>p1 AND H<=p2,1, If(H>p2 AND H<=p3,2, If(H>p3 AND H<=p4,3, If(H>p4 AND H<=p5,4, 5))))),0.0) Writeval(p1:=Ref(L,-1)-ATR(10);
p2:=Ref(L,-1);
p3:=Ref((H+L)/2,-1);
p4:=Ref(H,-1);
p5:=Ref(H,-1)+ATR(10);
If(L<=p1,0, If(L>p1 AND L<=p2,1, If(L>p2 AND L<=p3,2, If(L>p3 AND L<=p4,3, If(L>p4 AND L<=p5,4, 5))))),0.0) Writeval(p1:=Ref(L,-1)-ATR(10);
p2:=Ref(L,-1);
p3:=Ref((H+L)/2,-1);
p4:=Ref(H,-1);
p5:=Ref(H,-1)+ATR(10);
If(C<=p1,0, If(C>p1 AND C<=p2,1, If(C>p2 AND C<=p3,2, If(C>p3 AND C<=p4,3, If(C>p4 AND C<=p5,4, 5))))),0.0)
This means:
• The Open is writeif(O<=Ref(L,-1)-ATR(10),"less than the previous bar's Low minus a 10-period Average True Range","writeif((O>Ref(L,-1)-ATR(10)) AND O<=Ref(L,-1),"less than the previous bar's Low but greater than the previous Low minus a 10-period Average True Range","writeif(O>Ref(L,-1) AND O<=Ref((H+L)/2,-1),"less than the previous bar's midpoint but greater than the previous Low","writeif(O>Ref((H+L)/2,-1) AND O<=Ref(H,-1),"greater than the previous bar's midpoint but less than the previous bar's High","writeif(O>Ref(H,-1) AND (O<=Ref(H,-1)+ATR(10)),"greater than the previous bar's High but less than the previous High plus a 10-period Average True Range","writeif(O>Ref(H,-1)+ATR(10),"greater than the previous bar's High plus a 10-period Average True Range.")")")")")")
• The High is writeif(H<=Ref(L,-1)-ATR(10),"less than the previous bar's Low minus a 10-period Average True Range","writeif((H>Ref(L,-1)-ATR(10)) AND H<=Ref(L,-1),"less than the previous bar's Low but greater than the previous Low minus a 10-period Average True Range","writeif(H>Ref(L,-1) AND H<=Ref((H+L)/2,-1),"less than the previous bar's midpoint but greater than the previous Low","writeif(H>Ref((H+L)/2,-1) AND H<=Ref(H,-1),"greater than the previous bar's midpoint but less than the previous bar's High","writeif(H>Ref(H,-1) AND (H<=Ref(H,-1)+ATR(10)),"greater than the previous bar's High but less than the previous High plus a 10-period Average True Range","writeif(H>Ref(H,-1)+ATR(10),"greater than the previous bar's High plus a 10-period Average True Range.")")")")")")
• The Low is writeif(L<=Ref(L,-1)-ATR(10),"less than the previous bar's Low minus a 10-period Average True Range","writeif((L>Ref(L,-1)-ATR(10)) AND L<=Ref(L,-1),"less than the previous bar's Low but greater than the previous Low minus a 10-period Average True Range","writeif(L>Ref(L,-1) AND L<=Ref((H+L)/2,-1),"less than the previous bar's midpoint but greater than the previous Low","writeif(L>Ref((H+L)/2,-1) AND L<=Ref(H,-1),"greater than the previous bar's midpoint but less than the previous bar's High","writeif(L>Ref(H,-1) AND (L<=Ref(H,-1)+ATR(10)),"greater than the previous bar's High but less than the previous High plus a 10-period Average True Range","writeif(L>Ref(H,-1)+ATR(10),"greater than the previous bar's High plus a 10-period Average True Range.")")")")")")
• The Close is writeif(C<=Ref(L,-1)-ATR(10),"less than the previous bar's Low minus a 10-period Average True Range","writeif((C>Ref(L,-1)-ATR(10)) AND C<=Ref(L,-1),"less than the previous bar's Low but greater than the previous Low minus a 10-period Average True Range","writeif(C>Ref(L,-1) AND C<=Ref((H+L)/2,-1),"less than the previous bar's midpoint but greater than the previous Low","writeif(C>Ref((H+L)/2,-1) AND C<=Ref(H,-1),"greater than the previous bar's midpoint but less than the previous bar's High","writeif(C>Ref(H,-1) AND (C<=Ref(H,-1)+ATR(10)),"greater than the previous bar's High but less than the previous High plus a 10-period Average True Range","writeif(C>Ref(H,-1)+ATR(10),"greater than the previous bar's High plus a 10-period Average True Range.")")")")")")
Out of the writeval(cum(1),0.0) prior bars, this pattern was repeated writeval( p1:=Ref(L,-1)-ATR(10);
p2:=Ref(L,-1);
p3:=Ref((H+L)/2,-1);
p4:=Ref(H,-1);
p5:=Ref(H,-1)+ATR(10);
patpos:= If(O<=p1,0, If(O>p1 AND O<=p2,1, If(O>p2 AND O<=p3,2, If(O>p3 AND O<=p4,3, If(O>p4 AND O<=p5,4, 5)))))*1000 +
If(H<=p1,0, If(H>p1 AND H<=p2,1, If(H>p2 AND H<=p3,2, If(H>p3 AND H<=p4,3, If(H>p4 AND H<=p5,4, 5)))))* 100 +
If(L<=p1,0, If(L>p1 AND L<=p2,1, If(L>p2 AND L<=p3,2, If(L>p3 AND L<=p4,3, If(L>p4 AND L<=p5,4, 5)))))* 10 +
If(C<=p1,0, If(C>p1 AND C<=p2,1, If(C>p2 AND C<=p3,2, If(C>p3 AND C<=p4,3, If(C>p4 AND C<=p5,4, 5)))));
cum(patpos=lastvalue(patpos+prev-prev)),0.0) times.
For this data the pattern has occured writeval( p1:=Ref(L,-1)-ATR(10);
p2:=Ref(L,-1);
p3:=Ref((H+L)/2,-1);
p4:=Ref(H,-1);
p5:=Ref(H,-1)+ATR(10);
patpos:= If(O<=p1,0, If(O>p1 AND O<=p2,1, If(O>p2 AND O<=p3,2, If(O>p3 AND O<=p4,3, If(O>p4 AND O<=p5,4, 5)))))*1000 +
If(H<=p1,0, If(H>p1 AND H<=p2,1, If(H>p2 AND H<=p3,2, If(H>p3 AND H<=p4,3, If(H>p4 AND H<=p5,4, 5)))))* 100 + If(L<=p1,0, If(L>p1 AND L<=p2,1, If(L>p2 AND L<=p3,2, If(L>p3 AND L<=p4,3, If(L>p4 AND L<=p5,4, 5)))))* 10 + If(C<=p1,0, If(C>p1 AND C<=p2,1, If(C>p2 AND C<=p3,2, If(C>p3 AND C<=p4,3, If(C>p4 AND C<=p5,4, 5)))));
(cum(patpos=lastvalue(patpos+prev-prev))/cum(1))*100,5.1) percent of the time.
On the writeval( p1:=Ref(L,-1)-ATR(10);
p2:=Ref(L,-1);
p3:=Ref((H+L)/2,-1);
p4:=Ref(H,-1);
p5:=Ref(H,-1)+ATR(10);
patpos:= If(O<=p1,0, If(O>p1 AND O<=p2,1, If(O>p2 AND O<=p3,2, If(O>p3 AND O<=p4,3, If(O>p4 AND O<=p5,4, 5)))))*1000 +
If(H<=p1,0, If(H>p1 AND H<=p2,1, If(H>p2 AND H<=p3,2, If(H>p3 AND H<=p4,3, If(H>p4 AND H<=p5,4, 5)))))* 100 +
If(L<=p1,0, If(L>p1 AND L<=p2,1, If(L>p2 AND L<=p3,2, If(L>p3 AND L<=p4,3, If(L>p4 AND L<=p5,4, 5)))))* 10 +
If(C<=p1,0, If(C>p1 AND C<=p2,1, If(C>p2 AND C<=p3,2, If(C>p3 AND C<=p4,3, If(C>p4 AND C<=p5,4, 5)))));
cum(patpos=lastvalue(patpos+prev-prev))-1,0.0) previous occurrences of this pattern:
The next days close was greater than its open writeval(p1:=Ref(L,-1)-ATR(10);
p2:=Ref(L,-1);
p3:=Ref((H+L)/2,-1);
p4:=Ref(H,-1);
p5:=Ref(H,-1)+ATR(10);
patpos:= If(O<=p1,0, If(O>p1 AND O<=p2,1, If(O>p2 AND O<=p3,2, If(O>p3 AND O<=p4,3, If(O>p4 AND O<=p5,4, 5)))))*1000 +
If(H<=p1,0, If(H>p1 AND H<=p2,1, If(H>p2 AND H<=p3,2, If(H>p3 AND H<=p4,3, If(H>p4 AND H<=p5,4, 5)))))* 100 +
If(L<=p1,0, If(L>p1 AND L<=p2,1, If(L>p2 AND L<=p3,2, If(L>p3 AND L<=p4,3, If(L>p4 AND L<=p5,4, 5)))))* 10 +
If(C<=p1,0, If(C>p1 AND C<=p2,1, If(C>p2 AND C<=p3,2, If(C>p3 AND C<=p4,3, If(C>p4 AND C<=p5,4, 5)))));
cum(ref(patpos,-1)=lastvalue(patpos+prev-prev) AND C>O),0.0) time(s) or writeval(p1:=Ref(L,-1)-ATR(10);
p2:=Ref(L,-1);
p3:=Ref((H+L)/2,-1);
p4:=Ref(H,-1);
p5:=Ref(H,-1)+ATR(10);
patpos:= If(O<=p1,0, If(O>p1 AND O<=p2,1, If(O>p2 AND O<=p3,2, If(O>p3 AND O<=p4,3, If(O>p4 AND O<=p5,4, 5)))))*1000 +
If(H<=p1,0, If(H>p1 AND H<=p2,1, If(H>p2 AND H<=p3,2, If(H>p3 AND H<=p4,3, If(H>p4 AND H<=p5,4, 5)))))* 100 +
If(L<=p1,0, If(L>p1 AND L<=p2,1, If(L>p2 AND L<=p3,2, If(L>p3 AND L<=p4,3, If(L>p4 AND L<=p5,4, 5)))))* 10 +
If(C<=p1,0, If(C>p1 AND C<=p2,1, If(C>p2 AND C<=p3,2, If(C>p3 AND C<=p4,3, If(C>p4 AND C<=p5,4, 5)))));
(cum(ref(patpos,-1)=lastvalue(patpos+prev-prev) and c>O))/cum(ref(patpos,-1)=lastvalue(patpos+prev-prev))*100,5.1) percent.
The next days close was less than its open writeval(p1:=Ref(L,-1)-ATR(10);
p2:=Ref(L,-1);
p3:=Ref((H+L)/2,-1);
p4:=Ref(H,-1);
p5:=Ref(H,-1)+ATR(10);
patpos:= If(O<=p1,0, If(O>p1 AND O<=p2,1, If(O>p2 AND O<=p3,2, If(O>p3 AND O<=p4,3, If(O>p4 AND O<=p5,4, 5)))))*1000 +
If(H<=p1,0, If(H>p1 AND H<=p2,1, If(H>p2 AND H<=p3,2, If(H>p3 AND H<=p4,3, If(H>p4 AND H<=p5,4, 5)))))* 100 +
If(L<=p1,0, If(L>p1 AND L<=p2,1, If(L>p2 AND L<=p3,2, If(L>p3 AND L<=p4,3, If(L>p4 AND L<=p5,4, 5)))))* 10 +
If(C<=p1,0, If(C>p1 AND C<=p2,1, If(C>p2 AND C<=p3,2, If(C>p3 AND C<=p4,3, If(C>p4 AND C<=p5,4, 5)))));
cum(ref(patpos,-1)=lastvalue(patpos+prev-prev) AND C < O),0.0) time(s) or writeval(p1:=Ref(L,-1)-ATR(10);
p2:=Ref(L,-1);
p3:=Ref((H+L)/2,-1);
p4:=Ref(H,-1);
p5:=Ref(H,-1)+ATR(10);
patpos:= If(O <=p1,0, If(O>p1 AND O<=p2,1, If(O>p2 AND O<=p3,2, If(O>p3 AND O<=p4,3, If(O>p4 AND O<=p5,4, 5)))))*1000 +
If(H<=p1,0, If(H>p1 AND H<=p2,1, If(H>p2 AND H<=p3,2, If(H>p3 AND H<=p4,3, If(H>p4 AND H<=p5,4, 5)))))* 100 +
If(L<=p1,0, If(L>p1 AND L<=p2,1, If(L>p2 AND L<=p3,2, If(L>p3 AND L<=p4,3, If(L>p4 AND L<=p5,4, 5)))))* 10 +
If(C<=p1,0, If(C>p1 AND C<=p2,1, If(C>p2 AND C<=p3,2, If(C>p3 AND C<=p4,3, If(C>p4 AND C<=p5,4, 5)))));
(cum(ref(patpos,-1)=lastvalue(patpos+prev-prev) and c < O))/cum(ref(patpos,-1)=lastvalue(patpos+prev-prev))*100,5.1) percent.
The next days close was equal to its open writeval(p1:=Ref(L,-1)-ATR(10);
p2:=Ref(L,-1);
p3:=Ref((H+L)/2,-1);
p4:=Ref(H,-1);
p5:=Ref(H,-1)+ATR(10);
patpos:= If(O<=p1,0, If(O>p1 AND O<=p2,1, If(O>p2 AND O<=p3,2, If(O>p3 AND O<=p4,3, If(O>p4 AND O<=p5,4, 5)))))*1000 +
If(H<=p1,0, If(H>p1 AND H<=p2,1, If(H>p2 AND H<=p3,2, If(H>p3 AND H<=p4,3, If(H>p4 AND H<=p5,4, 5)))))* 100 +
If(L<=p1,0, If(L>p1 AND L<=p2,1, If(L>p2 AND L<=p3,2, If(L>p3 AND L<=p4,3, If(L>p4 AND L<=p5,4, 5)))))* 10 +
If(C<=p1,0, If(C>p1 AND C<=p2,1, If(C>p2 AND C<=p3,2, If(C>p3 AND C<=p4,3, If(C>p4 AND C<=p5,4, 5)))));
cum(ref(patpos,-1)=lastvalue(patpos+prev-prev) AND C=O),0.0) time(s) or writeval(p1:=Ref(L,-1)-ATR(10);
p2:=Ref(L,-1);
p3:=Ref((H+L)/2,-1);
p4:=Ref(H,-1);
p5:=Ref(H,-1)+ATR(10);
patpos:= If(O<=p1,0, If(O>p1 AND O<=p2,1, If(O>p2 AND O<=p3,2, If(O>p3 AND O<=p4,3, If(O>p4 AND O<=p5,4, 5)))))*1000 +
If(H<=p1,0, If(H>p1 AND H<=p2,1, If(H>p2 AND H<=p3,2, If(H>p3 AND H<=p4,3, If(H>p4 AND H<=p5,4, 5)))))* 100 +
If(L<=p1,0, If(L>p1 AND L<=p2,1, If(L>p2 AND L<=p3,2, If(L>p3 AND L<=p4,3, If(L>p4 AND L<=p5,4, 5)))))* 10 +
If(C<=p1,0, If(C>p1 AND C<=p2,1, If(C>p2 AND C<=p3,2, If(C>p3 AND C<=p4,3, If(C>p4 AND C<=p5,4, 5)))));
(cum(ref(patpos,-1)=lastvalue(patpos+prev-prev) and c=O))/cum(ref(patpos,-1)=lastvalue(patpos+prev-prev))*100,5.1) percent.
As a reminder, here are the definitions of the six numbers:
0: below the previous bar's low minus the value of the 10-bar ATR
1: between the previous bar's low and its low minus the value of the 10-bar ATR
2: between the previous bar's low and the middle of its range
3: between the previous bar's high and the middle of its range
4: between the previous bar's high and the high plus the value of the 10-bar ATR
5: above the previous bar's high plus the value of the 10-bar ATR
After entering the above text, you may click OK to close the Expert Editor, or you may create symbols to show where specific patterns are occurring. For the latter:
Contents
- Affine transformation
- Anticipating Moving Average Crossovers
- At Last! A Trend-Friendly Oscillator
- Average True Range or Standard Deviation
- Balance of Market Power
- Between Price and Volume
- Bollinger Band Targets
- BONUS ISSUE: Mutual Fund Screen
- Boosting Profitability - the AIM Indicator
- Breakout_Range2
- Bridging the Gap, Linking Point & Figure and Bar Charts
- Buff Up Your Moving Averages
- Bull and Bear Balance Indicator
- Candlestick Filtering
- Coding Candlesticks (II)
- Confirming the Price Trend
- Creating Multi-Colored Indicators in MetaStock
- Darvas-Style Trading and Something Darvas
- Deviation Oscillator
- Directional Breakout
- Ehlers Filters
- Elastic Volume Weighted Moving Average
- Finding Key Reversals
- Fisher Transform
- FVE - %b
- FVE - lin reg slope
- FVE - Storz's divergence
- FVE w/ linear regression slope
- High Low Strategy
- High Tech Mesa Adaptive Moving Averages
- Hilbert Indicators Tell You When to Trade
- Holding Overnight Positions
- Hot Zones
- How Smooth is Your Data Smoother
- Ichimoku Charts
- Index of Chart Sentiment
- Laguerre Filter
- Laguerre RSI
- MACD of Relative Strength
- Moving Average Crossovers
- Moving Average: Long on Talk, Sort on Action
- Normalization
- Now's The Time To Trade Crude
- Pivot point Strategy
- Profit with ETFs
- Quicken Your Averages
- Red-Green Strategy
- Refining the Hilbert Indicator
- Regularization
- Relative Performance Charting
- RSI Bands
- Squelch Those Whipsaws
- sRSI - Original
- sRSI - Using Wilders
- Stochastics
- Tandem Studies on Market Movement
- Targeting Your Pattern
- TC 2000 Scans
- The Average Peak Excursion
- The Cocked Gun Revisited
- The Inverse Fisher Transform
- The Self-Adjusting RSI
- The Truth about Volatility
- The Wilson Relative Price Channel
- Thrust Oscillator
- Trade Against the Gap
- Trade Into the Gap
- Trade the Swing Price
- Trend Continuation Factor
- Trend Quality Indicator
- Trend Trigger Factor
- TrendIV & Volume - Buy Signal
- TrendIV & Volume - Sell Signal
- Triggering Your Trading System
- Using Money Flow to Stay with the Trend
- Using Volume to Detect Shifts In Power
- Volatility System
- VWAP for Support and Resistance
- When and When not to Trade