First I would ask if you have checked the several dozen candle stick patterns already included in the scan engine. It may very well be this code was the result of someone else requesting those scans be made into a chart study. Have you consulted with the author, Mobius?
Within this code you find there are three distinct signals. Each is based on a candle pattern and each is define within a plot statement. This gives us three plot statements and a scan can only contain a single plot statement. Knowing this is 90% of the solution. This method of converting chart studies to scans has been demonstrated before in previous videos. Be sure to study up so that you can perform these conversions on your own in the future.
Here is the code, modified to work in a scan:
input n = 10;
input n2 = 5;
def o = open;
def h = high;
def l = low;
def c = close;
def RelRange = (close – Lowest(low, n)) / (highest(high, n) – lowest(low, n)) > .8;
def Range = High – Low;
def hR = Range == GetValue(Range, GetMaxValueOffset(range, n), n);
def hh = high == GetValue(high, GetMaxValueOffset(high, n), n);
def bodyTop = Max(close, open);
def BlownTop = (high – bodyTop) > .75 * Average(BodyHeight(), n);
plot HighRB = RelRange and hR and hh and BlownTop and Low < Low[1] and close < open;
# Saikou / Hikui Candles that indicate a reveresal in trend # Candle Pattern originated by Mobius #Saikou (Supreme Candle) Hikui (low/humble Candle) # V01.2014
#plot Saikou = h == GetValue(h, GetMaxValueOffset(h, n2), n2) and c < c[2] and isLongBlack() and BodyHeight() > Average(BodyHeight(), n2) and l <= getValue(l, GetMaxValueOffset(l, n2), n2);
#plot Hikui = l == GetValue(l, GetMinValueOffset(l, n2), n2) and c > c[2] and BodyHeight() > Average(BodyHeight(), n2) and h > h[1];
All I have done was to remove all the style statements (plot color, plot types and chart bubbles). I then placed comment marks ‘#’ in front of two of the three plots. As it is presented here, the current active scan is the HighRB plot. The Saikou plot and the Hikui plot are commented out. In order to scan for the Saikou pattern, you will comment out the HighRB and remove the comment mark from the Saikou plot. Likewise for the third pattern.