JT_479 piqued my interest into Pastor Dave's Candle Indicators from B4 Indicators, https://usethinkscript.com/threads/...estick-patterns-in-thinkorswim.77/post-109514
This study will differentiate specific candles and provide support / resistance lines based on one and two candle studies.
Here's an online resource for S/R levels based on candle, they use Stop Loss and Buy Stops levels, https://www.candlesticker.com/BullishPatterns.aspx?lang=en
Sleepy Z helped in with keeping Lines from drawing at the zero level.
I added a Hanging Man and strict Tweezer Implementation for now.. Need to figure out an appropriate Errmargin value and statement to use, have not set up a look back to find additional tweezer levels)
One thing I've noticed is a lack of standards/ ideal coding for patterns, length of 10 vs 20, hammer below 21 SMA, trend periods etc..
I have been using this As-IS lately and haven't spent any time lately tweaking it, so I thought I'd toss this out here for review/comments/use.
For the price Action Candlestick experts, what's missing and or needs to be fixed?
For the coders, any help/ thoughts appreciated. My coding card started and expired with Fortran IV, IBM Keypunch (Later upgraded to TTY I/O)
I'd also like to add a label of the latest Support Level Green and resistance Level Red
http://tos.mx/YeGovso
This study will differentiate specific candles and provide support / resistance lines based on one and two candle studies.
- You can deselect each pattern individually along with Extensions
- S/R will repaint until candle is closed... I like that for an early entry if a new support line is drawn over an older S/R level.
- I combine this with an SMA 8/13/21, Mobius Trend Pivot Points, all important Volume, and a few lower studies.
- I make decisions using three charts at Daily/Hourly/ 15 min, intraday; Hr/15min/5min..... gets a bit messy at the lower time frames
Here's an online resource for S/R levels based on candle, they use Stop Loss and Buy Stops levels, https://www.candlesticker.com/BullishPatterns.aspx?lang=en
Sleepy Z helped in with keeping Lines from drawing at the zero level.
I added a Hanging Man and strict Tweezer Implementation for now.. Need to figure out an appropriate Errmargin value and statement to use, have not set up a look back to find additional tweezer levels)
One thing I've noticed is a lack of standards/ ideal coding for patterns, length of 10 vs 20, hammer below 21 SMA, trend periods etc..
I have been using this As-IS lately and haven't spent any time lately tweaking it, so I thought I'd toss this out here for review/comments/use.
For the price Action Candlestick experts, what's missing and or needs to be fixed?
For the coders, any help/ thoughts appreciated. My coding card started and expired with Fortran IV, IBM Keypunch (Later upgraded to TTY I/O)
I'd also like to add a label of the latest Support Level Green and resistance Level Red
http://tos.mx/YeGovso
Code:
#Candle Indicators
#Pastor Dave B4 indicators.
#Modified By atcsam 01/6/23
#Rev1
#-------------------------------------------------
#Candle Indicators
#----------------------------------------
#Bullish Candle
#----------------------------------------
input ColorBars = Yes;
input length3 = 10;
def GreenCandle =
IsLongWhite(length3);
#def Bullish = GreenCandle;
#----------------------------------------------------------
#Spinning Top - Immediately preceding trend losing momemtum
#----------------------------------------------------------
def body_top = Max(open, close);
def body_bottom = Min(open, close);
def upper_shadow = high - body_top;
def lower_shadow = body_bottom - low;
def candle_height = high - low;
def body_height_is_less_than_one_third_candle_height = candle_height > 3 * BodyHeight();
def upper_shadow_height_is_less_than_one_half_ish_candle_height = upper_shadow < (.001 + candle_height) / 2;
def lower_shadow_height_is_less_than_one_half_ish_candle_height = lower_shadow < (.001 + candle_height) / 2;
def smallbody = body_height_is_less_than_one_third_candle_height
and upper_shadow_height_is_less_than_one_half_ish_candle_height
and lower_shadow_height_is_less_than_one_half_ish_candle_height;
plot Spinning_Top = smallbody;
Spinning_Top.SetPaintingStrategy(PaintingStrategy.BOOLEAN_POINTS);
Spinning_Top.SetDefaultColor(Color.White);
#-----------------------------------------------------------------------------------------
#-------------------------------------------------------------------
#Inside Bar - Consolidation. There is a fight going on for direction
#-------------------------------------------------------------------
def IsUp = close > open;
def IsDown = close < open;
def IsDoji = IsDoji();
def avgRange = 0.05 * Average(high - low, 20);
def InsideBar =
((Sum(IsUp, 1)[1] >= 0)) and
((Sum(IsUp, 1)[0] >= 0)) and
Highest(high[1], 1) >= Highest(high[0], 1) and
Lowest(low[1], 1) <= Lowest(low[0], 1);
#-------------------------------------------------------------------------------------------
# High Wave Candlestick Pattern - Market is "confused." You do not want to stay in the trade
# Assembled by BenTen at useThinkScript.com
#-------------------------------------------------------------------------------------------
def Day = (high - low);
def Day_1 = (high[1] - low[1]);
def Day_2 = (high[2] - low[2]);
def Day_3 = (high[3] - low[3]);
def Day_4 = (high[4] - low[4]);
def Day_5 = (high[5] - low[5]);
def Avg = ((Day_1 + Day_2 + Day_3 + Day_4 + Day_5) / 5);
input Highwave_Wick_Multiplier = 3.0;
input Range_Multiplier = 1.0;
def Highwave = (((high - low) - (AbsValue(open - close))) > ((AbsValue(open - close)) * Highwave_Wick_Multiplier)) and ((Day > (Avg * Range_Multiplier)));
#----------------------------------------------------------------------
#Hammer - "A chance to buy at the bottom." Use Low of hammer as Support
#----------------------------------------------------------------------
def MovingAvg = 52;
def Avg2 = SimpleMovingAvg(close, MovingAvg);
def CandleBody = AbsValue(open - close);
def UpperWick = high - Max(open, close);
def LowerWick = Min(open, close) – low;
def Hammer = LowerWick > CandleBody * 2 and UpperWick <= LowerWick * 0.2 and low < low[1] and low < low[2] and low < low[3] and low < low[4] and low < low[5] and low < low[6] and low < low[7] and low < low[8]and close > Avg;
#HammerSupport-------------
def HammerSupport = if Hammer then low else HammerSupport [1];
plot Hammer2 = if HammerSupport == 0 then Double.NaN else HammerSupport;
#plot Hammer2 = if Hammer then low else Double.NaN;
Hammer2.SetPaintingStrategy(PaintingStrategy.DASHES);
Hammer2.SetDefaultColor(Color.GREEN);
Hammer2.SetLineWeight(1);
def hammer2ext = if IsNaN(Close) then hammer2ext[1] else Hammer2;
plot Hammer2extline = hammer2ext;
Hammer2extline.SetPaintingStrategy(PaintingStrategy.DASHES);
Hammer2extline.SetDefaultColor(Color.Light_GREEN);
#----------------------------------------------------------
#Bullish Engulfing - A Bottom Reversal. The bullish candle wraps around the entire body of the previous candle in a downtrend. Lowest low of the two sessions is Support.
#----------------------------------------------------------
def BullEngulf =
IsDescending(close, 3)[2] and
IsDown[1] and
IsUp[0] and
open[1] < close[0] and
close[1] >= open[0];
def BullengulfSupport = if BullEngulf and low > low [1]
then low[1]
else if (BullEngulf) and low <= low[1]
then low
else BullengulfSupport[1];
plot bullsupport = if BullengulfSupport == 0 then Double.NaN else BullengulfSupport;
def Supportcount = if (bullsupport) then 1 else 0;
bullsupport.SetPaintingStrategy(PaintingStrategy.DASHES);
bullsupport.SetDefaultColor(Color.DARK_ORANGE);
bullsupport.SetLineWeight(2);
def Bullext = if IsNaN(close)
then Bullext[1]
else bullsupport;
#Problem Child inhibit plot before BullSuppot defined
plot Bullextline = Bullext;
Bullextline.SetPaintingStrategy(PaintingStrategy.DASHES);
Bullextline.SetDefaultColor(Color.DARK_ORANGE);
#---------------------------------------------------
#Doji - Market is at a point of indecision. Highest high of doji and prior candle used for resistance. No support.
#-----------------------------------------------------------------------------------------
input length = 20;
input bodyFactor = 0.05;
Assert(bodyFactor >= 0, "'body factor' must not be negative: " + bodyFactor);
def Doji = IsDoji(length, bodyFactor);
# DojiRsupport
def DojiRsupport = if Doji and high < high[1] then high[1] else if Doji and high >= high[1] then high else DojiRsupport [1];
plot DojiR = if DojiRsupport == 0 then Double.Nan else DojiRsupport;
DojiR.SetPaintingStrategy(PaintingStrategy.DASHES);
DojiR.SetDefaultColor(Color.RED);
DojiR.SetLineWeight(2);
def DojiRext = if IsNaN(Close) then DojiRext[1] else DojiR;
plot DojiRextline = DojiRext;
DojiRextline.SetPaintingStrategy(PaintingStrategy.DASHES);
DojiRextline.SetDefaultColor(Color.RED);
#----------------------------------------------------------------------------------------------
#Bullish Harami - Market in a downtrend. First Candle is unusually Long Downward Candle. Second candle has a small body within the prior red candle body. Prior trend is "losing breathe."
#----------------------------------------------------------------------------------------------
input length1 = 20;
input trendSetup1 = 3;
input bodyFactor1 = 0.3;
Assert(bodyFactor1 >= 0, "'body factor' must not be negative: " + bodyFactor1);
def BodyHeight = BodyHeight();
def IsShort = BodyHeight < bodyFactor1 * Average(BodyHeight, length);
def BodyMax = Max(open, close);
def BodyMin = Min(open, close);
def IsEngulfing = BodyMax < BodyMax[1] and
BodyMin > BodyMin[1];
plot BullishHarami = IsDescending(close, trendSetup1)[1] and
IsLongBlack(length)[1] and
IsEngulfing and
IsShort;
BullishHarami.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_UP);
BullishHarami.SetDefaultColor(color.green);
#----------------------------------------
#Bearish Candles - Typical Bearish Candles
#----------------------------------------
input length4 = 10;
def RedCandles =
IsLongBlack(length4);
#def Bearish = RedCandles;
#-------------------------
#Bearish Engulfing Candle - A Top Reversal. The bearish candle wraps around the entire body of the previous candle in a uptrend. Highest High of the two sessions is Resistance.
#-------------------------
def BearEngulf =
IsAscending(close, 3)[2] and
IsUp[1] and
IsDown[0] and
close[1] < open[0] and
open[1] > close[0];
def BearEngulfSupport = if BearEngulf and high < high[1] then high[1] else if BearEngulf and high >= high[1] then high else BearEngulfSupport[1];
plot BResistance = if BearEngulfSupport == 0 then Double.NaN else BearEngulfSupport;
BResistance.SetPaintingStrategy(PaintingStrategy.DASHES);
BResistance.SetDefaultColor(Color.Yellow);
BResistance.SetLineWeight(1);
def BRext = if IsNaN(Close) then BRext[1] else BResistance;
plot BRextline = BRext;
BRextline.SetPaintingStrategy(PaintingStrategy.DASHES);
BRextline.SetDefaultColor(Color.Yellow);
#-----------------------------------------------------------------------------------------------
#Piercing Line - Market in Downtrend. Candle opens below prior low and closes more than 50% into prior down candle. Lowest low of the two candles is Support.
#-----------------------------------------------------------------------------------------------
input length2 = 20;
input trendSetup = 3;
def PierceCandle = IsDescending(close, trendSetup)[1] and
IsLongBlack(length2)[1] and
open < low[1] and
close > MidBodyVal()[1] and
close < open[1];
def PiercingLine = PierceCandle;
def PierceLSupport = if PiercingLine and low > low [1] then low[1] else if PiercingLine and low <= low[1] then low else PierceLSupport[1];
plot PierceSupport = if PierceLSupport == 0 then Double.Nan else PierceLSupport;
PierceSupport.SetPaintingStrategy(PaintingStrategy.DASHES);
PierceSupport.SetDefaultColor(Color.CYAN);
PierceSupport.SetLineWeight(2);
def Pext = if IsNaN(close) then Pext[1] else PierceSupport;
plot Pextline = Pext;
Pextline.SetPaintingStrategy(PaintingStrategy.DASHES);
Pextline.SetDefaultColor(Color.CYAN);
#------------------
#Dark Cloud Covers - Market in Uptrend. Candle opens above prior high and closes more than 50% into prior high candle. Highest high of the two candles is Resistance.
#------------------
def CloudCandle = IsAscending(close, trendSetup)[1] and
IsLongWhite(length)[1] and
open > high[1] and
close < MidBodyVal()[1] and
close > open[1];
def DarkCloudCover = CloudCandle;
def DRSupport = if DarkCloudCover and high < high[1] then high[1] else if DarkCloudCover and high >= high[1] then high else DRSupport[1];
plot DResistance = if DRSupport == 0 then Double.NaN else DRSupport;
DResistance.SetPaintingStrategy(PaintingStrategy.DASHES);
DResistance.SetDefaultColor(Color.Magenta);
DResistance.SetLineWeight(2);
def DRext = if IsNaN(close) then DRext[1] else DResistance;
plot DRextline = DRext;
DRextline.SetPaintingStrategy(PaintingStrategy.DASHES);
DRextline.SetDefaultColor(Color.Magenta);
#--------------
#Bearish Harami - Market in a uptrend. First Candle is unusually Long Upward Candle. Second candle has a small body within the prior green candle body. Prior trend is "losing breathe."
#--------------
Assert(bodyFactor >= 0, "'body factor' must not be negative: " + bodyFactor);
def BodyHeight1 = BodyHeight();
def IsShort1 = BodyHeight < bodyFactor * Average(BodyHeight, length);
def BodyMax1 = Max(open, close);
def BodyMin1 = Min(open, close);
def IsEngulfing1 = BodyMax < BodyMax[1] and
BodyMin > BodyMin[1];
plot BearishHarami = IsAscending(close, trendSetup)[1] and
IsLongWhite(length)[1] and
IsEngulfing and
IsShort;
BearishHarami.SetPaintingStrategy(PaintingStrategy.BOOLEAN_wEDGE_DOWN);
BearishHarami.SetDefaultColor(color.Red);
#----------------------------------------------------------------------------------------------
#----------------------------------------------------------------------------------------------
#Shooting Star - Market in an uptrend. Small real body of candle at or near the bottom of range
#Upper shadow at least 2x height of body of candle
#----------------------------------------------------------------------------------------------
input Star_length = 30;
input Star_trendSetup = 3;
input Star_bodyFactor = 0.3;
input Star_shadowFactor = 2.0;
Assert(Star_bodyFactor >= 0, "'body factor' must not be negative: " + Star_bodyFactor);
Assert(Star_shadowFactor >= 0, "'shadow factor' must not be negative: " + Star_shadowFactor);
def Star_BodyHeight = BodyHeight();
def Star_AverageBodyHeight = Average(Star_BodyHeight, Star_length);
def Star_ErrMargin = 0.25 * Star_AverageBodyHeight;
def Star_IsShort = Star_BodyHeight <= Star_bodyFactor * Star_AverageBodyHeight;
def ShootingStar = IsAscending(close, Star_trendSetup)[1] and
Star_IsShort and
Min(open, close) - low <= Star_ErrMargin and
high - Max(open, close) > Star_shadowFactor * Star_BodyHeight;
def SSTest = if ShootingStar then high else SSTest[1];
plot SSR = if SStest == 0 then Double.NaN else SSTest;
SSR.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SSR.SetDefaultColor(Color.Red);
def SSRext = if IsNaN(close) then SSRext[1] else SSR;
plot SSRextline = SSRext;
SSRextline.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SSRextline.SetDefaultColor(Color.Red);
#-------------------------------------------------------
#hanging Man
#--------------------------------------------------------
#input length = 20;
#input trendSetup = 3;
#input bodyFactor = 0.3;
input shadowFactor = 2.0;
assert(bodyFactor >= 0, "'body factor' must not be negative: " + bodyFactor);
assert(shadowFactor >= 0, "'shadow factor' must not be negative: " + shadowFactor);
#def BodyHeight = BodyHeight();
def AverageBodyHeight = Average(BodyHeight, length);
def ErrMargin = 0.05 * AverageBodyHeight;
#def IsShort = BodyHeight < bodyFactor * AverageBodyHeight;
plot BearishHM = IsAscending(close, trendSetup) and
IsShort and
high - Max(open, close) <= ErrMargin and
Min(open, close) - low > shadowFactor * BodyHeight;
BearishHM.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
BearishHM.SetDefaultColor(GetColor(1));
BearishHM.SetLineWeight(1);
#-------------------------------------------------
#Fuzzy Twwezers
#-------------------------------------------------
#def IsUp = close > open;
#def IsDown = close < open;
#----------------------------------------------------------
#Tweezer Bottom
#----------------------------------------------------------
def TweezerB =
IsDescending(close, 3) and
IsDown[1] and
IsUp[0] and
((close[1] == open[0]) or (Low[1] == low));
def TweezerBlvl = if TweezerB then open
else TweezerBlvl[1];
plot TweezerBpl = if TweezerBlvl == 0 then Double.NaN else TweezerBlvl;
TweezerBpl.SetPaintingStrategy(PaintingStrategy.DASHES);
TweezerBpl.SetDefaultColor(Color.White);
TweezerBpl.SetLineWeight(1);
def TWZBext = if IsNaN(close)
then TWZBext[1]
else TweezerBpl;
#Problem Child inhibit plot before BullSuppot defined
plot TWZBextline = TWZBext;
TWZBextline.SetPaintingStrategy(PaintingStrategy.DASHES);
TWZBextline.SetDefaultColor(Color.White);
#---------------------------------------------------
#AddChartBubble ( TweezerB, low[1], "TwEz", Color.LIGHT_GRAY, no);
#---------------------------------------------------No
#Tweezer Top
#----------------------------------------------------------
#def IsUp = close > open;
#def IsDown = close < open;
def TweezerT =
IsAscending(close, 3) and
IsUp[1] and
IsDown[0] and
((close[1] == open) or (high[1] == high));
#Support Test
def TweezerSupportT = if TweezerT and high > high [1]
then high[1]
else if TweezerT and high <= high[1]
then high
else TweezerSupportT[1];
plot TweezeSupportTP = if TweezerSupportT == 0 then Double.NaN else TweezerSupportT;
TweezeSupportTP.SetPaintingStrategy(PaintingStrategy.DASHES);
TweezeSupportTP.SetDefaultColor(Color.Blue);
TweezeSupportTP.SetLineWeight(1);
def TweezerextTP = if IsNaN(close)
then TweezerextTP[1]
else TweezeSupportTP;
#Problem Child inhibit plot before BullSuppot defined
plot TweezerextlineTP = TweezerextTP;
TweezerextlineTP.SetPaintingStrategy(PaintingStrategy.DASHES);
TweezerextlineTP.SetDefaultColor(Color.Blue);
#AddChartBubble ( TweezerT, high[1], "TwEz", Color.LIGHT_GRAY, yes);
#--------------------------------------------------------
AssignPriceColor(if !ColorBars then Color.Current else if spinning_top then CreateColor (0,128,255) else if BullEngulf or BearEngulf then Color.DARK_ORANGE else if Doji then CreateColor (255,4,38)else if PiercingLine or DarkCloudCover then Color.CYAN else if Highwave then Color.PLUM else if InsideBar then Color.Gray else if ShootingStar then Color.White else Color.CURRENT);
#--------------------------------------------------------
Last edited: