!Cup and handle code
MinPrice is [close]>15.
MaxPrice is [close]<200.
MinVolume is [volume esa]>750.
CloseAboveMovAvg is [close]>[LT MA].
CloseBelowMovAvg is [close]<[LT MA].
MovAvgSlopeUp is slope([LT MA],21)>0.
Filter if MinPrice and MaxPrice and MinVolume and CloseAboveMovAvg.
!Look back 40 to 80 days for the downleg to begin, off a 240 day
high,
! and drop up to 20%, 20 to 39 days ago. Today's close can be no
higher
! than 100% of the top of the downleg and no lower than 85%. Look
for
! a cup & handle pattern in the formation stage on the charts.
CupHandle if Filter and (hival([close],19,20)<=hival([close],40,40)*0.80)
and [close]<=hival([close],40,40) and ([close]>=hival([close],40,40)*0.85)
and hival([close],40,40)=hival([close],240).
! A basic double bottom strategy. Looks for todays low price and
! compares this to the lowest low price between 8 and 70 days
! ago. If the two lows are very close to each other in price
! (between 99.5 and 99.9%) the stock had a double bottom.
! Vary the periods back to check the low, or vary the percentage
! between the two lows to suit your needs. You may use close
! instead of low
Currentlow is [low].
Previouslow is Loval([low],70,8).
Low if Currentlow/ Previouslow > 0.995 and Currentlow /Previouslow
< 0.999.
! A basic double top strategy. Looks for todays high price and
! compares this to the highest high price between 8 and 70 days
! ago. If the the two highs are very close to each other in price
! (between 99.5 and 99.9%) the stock had a double top.
! Vary the periods back to check the high, or vary the percentage
! between the two highs to suit your needs. You may use close
! instead of high
Currenthigh is [high].
Previoushigh is Hival([high],70,8).
Doubletop if Currenthigh/ Previoushigh > 0.995 and Currenthigh /Previoushigh
< 0.999.
Symmetry is 0.28.
Apex is ([high] + [low]) / 2.
WB is valresult([high], 2) - val([low], 2).
High is [high].
Low is [low].
YLow is val([low], 1).
Day2Low is val([low], 2).
YHigh is val([high], 1).
Day2High is val([high], 2).
Shark if (apex <= (Day2High - (WB * Symmetry))) and (apex >= (Day2Low
+ (WB * Symmetry))).
SharkUDF is shark.
SharkPattern if iff((high < YHigh) and (low > YLow) and (YHigh <
Day2High) and (YLow > Day2Low) = 1, sharkudf, 0). !! Example stock
is