Pages

Saturday, August 25, 2018

codes to detect Rejection and Retest

//Codes by Chrismoody
study(title="CM_Williams_Vix_Fix_V3_Upper_Text-Plots", shorttitle="Market checker", overlay=true)
//Inputs Tab Criteria.
pd = input(22, title="LookBack Period Standard Deviation High")
bbl = input(20, title="Bolinger Band Length")
mult = input(2.0 , minval=1, maxval=5, title="Bollinger Band Standard Devaition Up")
lb = input(50 , title="Look Back Period Percentile High")
ph = input(.85, title="Highest Percentile - 0.90=90%, 0.95=95%, 0.99=99%")
new = input(false, title="-------Text Plots Below Use Original Criteria-------" )
sbc = input(false, title="Market Check")
sbcc = input(false, title="Show Text Plot if Buttom")
new2 = input(false, title="-------Text Plots Below Use FILTERED Criteria-------" )
sbcFilt = input(true, title="Show Text Plot For Filtered Entry")
sbcAggr = input(true, title="Show Text Plot For AGGRESSIVE Filtered Entry")
ltLB = input(40, minval=25, maxval=99, title="Long-Term Look Back Current Bar Has To Close Below This Value OR Medium Term--Default=40")
mtLB = input(14, minval=10, maxval=20, title="Medium-Term Look Back Current Bar Has To Close Below This Value OR Long Term--Default=14")
str = input(3, minval=1, maxval=9, title="Entry Price Action Strength--Close > X Bars Back---Default=3")
//Alerts Instructions and Options Below...Inputs Tab
new4 = input(false, title="-------------------------Turn On/Off ALERTS Below---------------------" )
new5 = input(false, title="----To Activate Alerts You HAVE To Check The Boxes Below For Any Alert Criteria You Want----")
sa1 = input(false, title=" choose what to alert")
sa2 = input(false, title="Market Check?")
sa3 = input(false, title="Confirm Entry?")
sa4 = input(false, title="Aggresive Entry?")
//Williams Vix Fix Formula
wvf = ((highest(close, pd)-low)/(highest(close, pd)))*100
sDev = mult * stdev(wvf, bbl)
midLine = sma(wvf, bbl)
lowerBand = midLine - sDev
upperBand = midLine + sDev
rangeHigh = (highest(wvf, lb)) * ph
//Filtered Bar Criteria
upRange = low > low[1] and close > high[1]
upRange_Aggr = close > close[1] and close > open[1]
//Filtered Criteria
filtered = ((wvf[1] >= upperBand[1] or wvf[1] >= rangeHigh[1]) and (wvf < upperBand and wvf < rangeHigh))
filtered_Aggr = (wvf[1] >= upperBand[1] or wvf[1] >= rangeHigh[1]) and not (wvf < upperBand and wvf < rangeHigh)
//Alerts Criteria
alert1 = wvf >= upperBand or wvf >= rangeHigh ? 1 : 0
alert2 = (wvf[1] >= upperBand[1] or wvf[1] >= rangeHigh[1]) and (wvf < upperBand and wvf < rangeHigh) ? 1 : 0
alert3 = upRange and close > close[str] and (close < close[ltLB] or close < close[mtLB]) and filtered ? 1 : 0
alert4 = upRange_Aggr and close > close[str] and (close < close[ltLB] or close < close[mtLB]) and filtered_Aggr ? 1 : 0
plotshape(sbcc and alert1 ? alert1 : na, title="WVF Is True Text", color=lime, style=shape.arrowup, location=location.belowbar ,text='Buttom', transp=0)
plotshape(sbc and alert2 ? alert2 : na, title="Entry/Rev Text", color=aqua, style=shape.arrowup, location=location.belowbar ,text='Entry/Rev', transp=0)
plotshape(sbcAggr and alert4 ? alert4 : na, title="Early in/Rev Text",color=orange, style=shape.arrowup, location=location.belowbar ,text='Early in/Rev', transp=0)
plotshape(sbcFilt and alert3 ? alert3 : na, title="Confirm Entry/Rev Text", color=fuchsia, style=shape.arrowup, location=location.belowbar ,text='confirm entry/Rev', transp=0)
// Find all Fractals.
// This section based on [RS]Fractal Levels by RicardoSantos
hidefractals = input(false)
hidelevels = input(false)
topfractal = high[2] > high[1] and high[2] > high and high[2] > high[3] and high[2] > high[4]
botfractal = low[2] < low[1] and low[2] < low and low[2] < low[3] and low[2] < low[4]
plotshape(hidefractals ? na : topfractal, color=green, transp=0, style=shape.triangleup, location=location.abovebar, offset=-2, size=size.tiny)
plotshape(hidefractals ? na : botfractal, color=red, transp=0, style=shape.triangledown, location=location.belowbar, offset=-2, size=size.tiny)
topfractals = topfractal ? high[2] : topfractals[1]
botfractals = botfractal ? low[2] : botfractals[1]
topfcolor = topfractals != topfractals[1] ? na : green
botfcolor = botfractals != botfractals[1] ? na : red
plot(hidelevels ? na : topfractals, color=topfcolor, transp=0, linewidth=2)
plot(hidelevels ? na : botfractals, color=botfcolor, transp=0, linewidth=2)
//Coloring Criteria of Williams Vix Fix
col = wvf >= upperBand or wvf >= rangeHigh ? lime : gray
//Plots for Williams Vix Fix Histogram and Alerts
plot(sa2 and alert2 ? alert2 : 0, title="Alert If Entry/Rev", style=line, linewidth=2, color=aqua)
plot(sa3 and alert3 ? alert3 : 0, title="Alert Confirm Entry/Rev", style=line, linewidth=2, color=fuchsia)
plot(sa4 and alert4 ? alert4 : 0, title="Alert Early in/Rev", style=line, linewidth=2, color=orange)
matype = input(defval="HullMA", title="Fast MA Type: SMA, EMA, WMA, VWMA, SMMA, DEMA, TEMA, HullMA, TMA, ZEMA ( case sensitive )", type=string)
malength = input(defval=20, title="Moving Average Length", minval=1)
src = input(close,title="Moving average Source")
// Returns MA input selection variant, default to SMA if blank or typo.
variant(type, src, len) =>
     v1 = sma(src, len) // Simple
     v2 = ema(src, len) // Exponential
     v3 = wma(src, len) // Weighted
     v4 = vwma(src, len) // Volume Weighted
     v5 = na(v5[1]) ? sma(src, len) : (v5[1] * (len - 1) + src) / len // Smoothed
     v6 = 2 * v2 - ema(v2, len) // Double Exponential
     v7 = 3 * (v2 - ema(v2, len)) + ema(ema(v2, len), len) // Triple Exponential
     v8 = wma(2 * wma(src, len / 2) - wma(src, len), round(sqrt(len))) // Hull
     ema1 = ema(src, len)
     ema2 = ema(ema1, len)
     v10 = ema1+(ema1-ema2) // Zero Lag Exponential
     v11 = sma(sma(src,len),len) // Trianglular
     // return variant, defaults to SMA if input invalid.
     type=="EMA"?v2 : type=="WMA"?v3 : type=="VWMA"?v4 : type=="SMMA"?v5 : type=="DEMA"?v6 :         type=="TEMA"?v7 : type=="HullMA"?v8 : type=="ZEMA"?v10 : type=="TMA"?v11 : v1
// Calculate selected MA and get direction of trend from it.
zlema= variant(matype,src,malength)
up = zlema > zlema[1] ? 1 : 0
down = zlema < zlema[1] ? 1 : 0
// This section based on Candlestick Patterns With EMA by rmwaddelljr
//
ufb = input(false, title="Use Fractal S/R Cross Patterns")
udc = input(true, title="Use Dark Cloud Cover Patterns" )
upl = input(true, title="Use Piecing Line Patterns" )
ube = input(true, title="Use Engulfing Candle Patterns" )
ubh = input(true, title="Use Harami Candle Patterns" )
upb = input(true, title="Use Defined PinBar Patterns")
pctP = input(66, minval=1, maxval=99, title="Directional PBars, % of Range of Candle the Long Wick Has To Be")
// This section based on CM_Price-Action-Bars by ChrisMoody
//EOF

No comments:

Post a Comment