Cup or Cup with Handle pattern code example

Discussion in 'App Development' started by gaihosa, Nov 25, 2018.

  1. gaihosa

    gaihosa

    Looking to make a screener that can find cup with/without handle patterns in a chart. Sort of have a few ideas how to do it if anyone has an example in any programming language that would be great.
     
  2. tommcginnis

    tommcginnis

    There are innumerable ways to define/specify the so-called "pattern" of "a cup."

    To execute it on your own screen, you'll have to specify what the cup is -- is it the bottom of a parabola? Or is it broader like a soup bowl? Maybe as shallow as a saucer?

    Then, you have to specify *what* is executing that pattern: is it the daily close? The daily MID or VWAP? Perhaps a Moving Average? An SMA or an EMA? How far back does this MA look?

    Once you have those two things, you can decide how you want to screen:
    are you going to backtest daily? Weekly? Back 180 days?

    Back 3 years ago or so, the market was handing out sweet buy/writes and covered calls like they were Easter candy -- the only thing I did was screen on three criteria:
    Recent drop (3-6 months out)
    Recent bottom (2wks-4wks out)
    Recent highs (w/in last two weeks)
    and I caught a bunch of stuff that had had some sort of issue,
    got pasted (re market price), and
    hit an obvious rebound.

    All that on three screening criteria.
    (But the patterns would've looked like "a cup" if anyone had cared.)
     
  3. I've been fantasizing about writing some image recognition code that would take a crappy drawing of a pattern I'm looking for and find instances of the pattern on any time scale.
     
  4. wlnd

    wlnd

    you must have an idea of how to quantify the pattern

    multicharts has an eg code here- https://www.multicharts.com/support/base/patterns-gt-cup-handle/

    note where the bottom (B) is. it is not that straight forward. not easy but doable. imagine starting with a higher high & 'prolonged' (have to exercise your creativity here) lower low. then a swing towards the previous high, followed by a small & tight higher low