R Function for stocks
Project detail
in R, I need to find this pattern so I can do some backtesting in quantstrat.
3 bars. The pattern is composed of three bars, a gap followed by two higher highs and two higher lows.
Price gap = Look for price to gap higher. Yesterday’s low price is above the prior days high, forming a gap.
Higher high = The third bar in the pattern makes a higher high.
Higher low = The third bar in the pattern makes a higher low, but it remains below the 2nd bar’s high.
Attached two examples.
So I will need a function to find the gap2H, the function will be used as add.indicator.
Ideally, the function will return the start_date and end_date of the pattern.
I only need the function.