Here's the code that I wrote for the price action reversal candles. Nice and simple.
Code: Select all //Bullish/Bearish Candle Detector with trend strength, volume and alignment with 10/20/60 EMAs (ie price reversals back into trend)
//Detection of Hammer / Shooting Star
Timeframe(default)
L=3 //length of tail.
maxi = max(open,close)
mini = min(open,close)
body= abs(open-close)
lowertail = abs(low-mini) > ( L * body ) and (abs(low-mini) > abs(high-maxi))
uppertail = abs(high-maxi) > ( L * body ) and (abs(high-maxi) > abs(low-mini))
// candle high above 10ema
c1 = (high > exponentialaverage[10])
// candle low below 10ema
c2 = (low < exponentialaverage[10])
// Determine the "force" of the preceding down trend.
// Find the lowest low over the last 10bars
TIMEFRAME (Daily)
Low10 = lowest[10](low)
// Determine the decline since this point
Decline1 = Low10 - Close
// Determine the normal volatility of the security (median of true range over the last 3 bars)
NormalV1 = summation[3](TR) - lowest[3](TR) - highest[3](TR)
// Condition: Bullish Engulfing
Filter2 =close[1]>open[1] AND open>close[1] AND close<open[1] AND close<open and low[0]>low[1]
//Sorting criteria: Decline/NormalV (preceding down trend force)
//Determine the "force" of the preceding UP trend.
// Find the highest high over the last 10bars
TIMEFRAME (Daily)
High10 = highest[10](High)
// Determine the decline since this point
Decline = High10 - Close
// Determine the normal volatility of the security (median of true range over the last 3 bars)
NormalV = summation[3](TR) - highest[3](TR) - lowest[3](TR)
//Condition: Bullish Engulfing
Filter = close[1]<open[1] AND open<close[1] AND close>open[1] AND close>open
// EMA 10 greater than EMA 20 (for bullish with trend detection)
c6 = (exponentialaverage[10] > exponentialaverage[20])
// MEMA 10 Less than EMA 20 (for bearish with trend detection)
c7 = (exponentialaverage[10] < exponentialaverage[20])
//volume >(n)(change as required)
c8 = (volume > 500000)
// detection of Dark Cloud Cover (Bearish)
C9 = (open >high[1] and close < high[1] and close > close[1]and open < close)
// detection of piercing line (opposite to dark cloud cover) Bullish
c10 = (open < low[1] and close <high[1] and close >close[1] and open > close)
// detect BUOB where 10ema > 20ema (ie with trend)and candle high >10ema
SCREENER[Filter and c1 and C6](Decline / NormalV AS "Down Trend Force")//BUOB
// detect BEOB where 10ema < 20ema (ie with trend) and candle low < 10ema
SCREENER[Filter2 and C2 and C7](Decline1 / NormalV1 AS "Down Trend Force")//BEOB
// detect hammer candle at bottom of recent down trend
screener [ close[1] < close[2] and lowertail and C8] (Decline1 / NormalV1 AS "Down Trend Force")//finds hammer
// detects shooting star candle above recent up trend
screener [ close[1] > close[2] and uppertail and c8](Decline / NormalV AS "Down Trend Force") //finds shooting star
//detects Dark cloud cover (DCC) at top of recent uptrend
Screener [C9] (Decline1 / NormalV1 AS "Down Trend Force")//finds Dark Cloud Cover
//detect piercing line (bullish opposite to DCC) at base of down trend
Screener [c10](Decline / NormalV AS "Down Trend Force") //finds Opposite to dark cloud cover
|