Detection of the candlestick pattern 3 Black Crows and 3 White Soldiers. The indicator contains extra parameters for detecting any sequence of alternative numbers of crows/soldiers (e.g. 2, 3, 4, etc). Extra optional condition is inserted to take into account the minimum ratio between the body and the range of candle. (e.g. the bodies must be at least 70% of the total candle)
//Candlestick pattern x crows / x soldiers
//With or without body length compared to the wicks
//E.g. body must be at least 70% of total candle
//Parameters
NbrCandles = 3
Bodysize = 70 //in percentage
BodySizeOnOff = 1 //standard 'On'
//3 or x white soldiers
for i=0 to NbrCandles-1 do
CondSoldier = close[i] > open[i] and close[i] > close[i+1]
If BodySizeOnOff then
CondBodySizeSoldier = (((close[i] - open[i]) / (high[i]- low[i])) > (BodySize / 100))
if CondSoldier and CondBodySizeSoldier then
else
CondSoldier = 0
break
endif
elsif CondSoldier then
else
CondSoldier = 0
break
endif
next
//3 or x black crows
for i=0 to NbrCandles-1 do
CondCrows = close[i] < open[i] and close[i] < close[i+1]
If BodySizeOnOff then
CondBodySizeCrows = (((open[i] - close[i]) / (high[i]- low[i])) > (BodySize / 100))
if CondCrows and CondBodySizeCrows then
else
CondCrows = 0
break
endif
elsif CondCrows then
else
CondCrows = 0
break
endif
next
//Determining and drawing of indicator
if CondSoldier = 1 then
//3 or x White Soldiers
CrowSoldier = 1
elsif CondCrows = 1 then
//3 or x Black Crows
CrowSoldier = -1
else
CrowSoldier = 0
endif
HorLine = 0
return CrowSoldier as "CrowSoldier", HorLine coloured (0,0,255) as "HorLine"