Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
100% found this document useful (1 vote)
278 views

Code

The document describes several trading strategies and indicators including: 1) A wick reversal strategy that generates buy and sell signals based on the size of candle wicks relative to the candle body. 2) Momentum indicators like the relative strength index (RSI). 3) Pivot point calculations and a strategy that trades off daily pivot levels. 4) Other patterns like engulfing and fading candles analyzed using average true range.

Uploaded by

Uma Mamadapur
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
278 views

Code

The document describes several trading strategies and indicators including: 1) A wick reversal strategy that generates buy and sell signals based on the size of candle wicks relative to the candle body. 2) Momentum indicators like the relative strength index (RSI). 3) Pivot point calculations and a strategy that trades off daily pivot levels. 4) Other patterns like engulfing and fading candles analyzed using average true range.

Uploaded by

Uma Mamadapur
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 26

study(title="Pivot Range + Extreme Reversal + Wick Reversal + Doji Reversal",

shorttitle="PIVOTS_STRAT", overlay=true)

sd = input(true, title="Show Daily Pivots?")

//Pivot Range Calculations - Mark Fisher

pivot = (high + low + close ) / 3.0

bc = (high + low ) / 2.0

tc = (pivot - bc) + pivot

//Daily Pivot Range

dtime_pivot = security(tickerid, 'D', pivot[1])

dtime_bc = security(tickerid, 'D', bc[1])

dtime_tc = security(tickerid, 'D', tc[1])

offs_daily = 0

wick_multiplier = input(title="Wick Multiplier", type=float, defval=2.5)

close_thresh = input(title="Close Value Percent", type=float, defval=0.35, minval=0.0, maxval=1.0)

// basic candle computations

top_body = max(close, open)

bot_body = min(close, open)

top_wick_size = high - top_body

body_size = top_body - bot_body

bot_wick_size = bot_body - low

range = high - low

bull_signal = (bot_wick_size > (wick_multiplier*body_size)) and (close > (low +


(range*(1-close_thresh))))

bear_signal = (top_wick_size > (wick_multiplier*body_size)) and (close < (low +


(range*close_thresh)))

smaPeriod = input(title="SMA Period", type=integer, defval=10, minval=0)


tolerance = input(title="Tolerance", type=float, defval=0.1, minval=0)

avg = sma(close, smaPeriod)

is_last_doji = (abs(close[1] - open[1]) / (high[1] - low[1])) < tolerance

signal_bull_last = is_last_doji and (high[1] < avg[1]) and (close > high[1])

signal_bear_last = is_last_doji and (low[1] > avg[1]) and (close < low[1])

is_last2_doji = (abs(close[2] - open[2]) / (high[2] - low[2])) < tolerance

signal_bull_last2 = is_last2_doji and (high[2] < avg[2]) and (close > high[2])

signal_bear_last2 = is_last2_doji and (low[2] > avg[2]) and (close < low[2])

lookbackPeriod = input(title="Lookback Period", type=integer, defval=20, minval=0)

atrMultiplier = input(title="Bar ATR Multiplier", type=float, defval=2.0, minval=0)

barBodyPercentMin = input(title="Minimum Bar Body %", type=float, defval=0.65, minval=0.0,


maxval=1.0)

barBodyPercentMax = input(title="Maximum Bar Body %", type=float, defval=0.85, minval=0.0,


maxval=1.0)

typicalAtr = atr(lookbackPeriod)

firstBar_body_size = abs(close[1] - open[1])

firstBar_range = high[1] - low[1]

firstBar_body_pct = firstBar_body_size / firstBar_range

firstBar_signal = (firstBar_range > (atrMultiplier * typicalAtr)) and (firstBar_body_pct >=


barBodyPercentMin) and (firstBar_body_pct <= barBodyPercentMax)

bull_signal = firstBar_signal and (close[1] < open[1]) and (close > open)

bear_signal = firstBar_signal and (close[1] > open[1]) and (close < open)

plot(sd and dtime_pivot ? dtime_pivot : na, title="Daily Pivot",style=circles,


color=fuchsia,linewidth=3)
plot(sd and dtime_bc ? dtime_bc : na, title="Daily BC",style=circles, color=blue,linewidth=3)

plot(sd and dtime_tc ? dtime_tc : na, title="Daily TC",style=circles, color=blue,linewidth=3)

plotshape(bull_signal, "Bullish Wick Reversal", style=shape.triangleup,

location=location.belowbar, color=green, size=size.tiny)

plotshape(bear_signal, "Bearish Wick Reversal", style=shape.triangledown,

location=location.abovebar, color=red, size=size.tiny)

plotshape(signal_bull_last or signal_bull_last2, "Bullish Reversal", shape.labelup,

location.belowbar, green,

text="DR", textcolor=black, size=size.tiny)

plotshape(signal_bear_last or signal_bear_last2, "Bearish Reversal", shape.labeldown,

location.abovebar, red,

plotshape(bull_signal, "Bullish Reversal", shape.labelup, location.belowbar, green,

text="XR", textcolor=black, size=size.tiny)

plotshape(bear_signal, "Bearish Reversal", shape.labeldown, location.abovebar, red,

text="XR", textcolor=black, size=size.tiny)

lookbackPeriod = input(title="Lookback Period", type=integer, defval=20, minval=0)

atrMultiplier = input(title="Bar ATR Multiplier", type=float, defval=1.05, minval=0)

typicalAtr = atr(lookbackPeriod)

firstBar_body_size = abs(close[1] - open[1])

firstBar_range = high[1] - low[1]

firstBar_signal = (firstBar_range > (atrMultiplier * typicalAtr))


bull_signal = (low < low[1]) and (close > high[1]) and firstBar_signal

bear_signal = (high > high[1]) and (close < low[1]) and firstBar_signal

plotshape(bull_signal, "Bullish Reversal", shape.labelup, location.belowbar, green,

text="OR", textcolor=black, size=size.tiny)

plotshape(bear_signal, "Bearish Reversal", shape.labeldown, location.abovebar, red,

text="OR", textcolor=black, size=size.tiny)

ELLIOT WAVE INDICATOR

study(title = "Elliot Wave Oscillator [LazyBear]", shorttitle="EWO_LB")

s2=ema(close, 5) - ema(close, 35)

c_color=s2 <= 0 ? red : lime

plot(s2, color=c_color, style=histogram, linewidth=2)

Candle_Range = high - low

Body_Range = abs( close - open )

barcolor( (Body_Range <= Candle_Range * 0.5) ? blue : na)

higherTF = input("D", type=input.resolution)

Dynamic volume profile

// lazybear

length1 = input(20, title="BB Length")


mult = input(2.0,title="BB MultFactor")

lengthKC=input(20, title="KC Length")

multKC = input(1.5, title="KC MultFactor")

useTrueRange = input(true, title="Use TrueRange (KC)", type=bool)

// Calculate BB

source = close

basis = sma(source, length1)

dev = multKC * stdev(source, length1)

upperBB = basis + dev

lowerBB = basis - dev

// Calculate KC

ma = sma(source, lengthKC)

range1 = useTrueRange ? tr : (high - low)

rangema = sma(range, lengthKC)

upperKC = ma + rangema * multKC

lowerKC = ma - rangema * multKC

sqzOn = (lowerBB > lowerKC) and (upperBB < upperKC)

sqzOff = (lowerBB < lowerKC) and (upperBB > upperKC)

noSqz = (sqzOn == false) and (sqzOff == false)

val = linreg(source - avg(avg(highest(high, lengthKC), lowest(low, lengthKC)),sma(close,lengthKC)),


lengthKC,0)

bcolor = iff( val > 0, iff( val > nz(val[1]), lime, green),iff( val < nz(val[1]), red, maroon))

scolor = noSqz ? blue : sqzOn ? black : gray

plot(val, color=bcolor, style=histogram, linewidth=4)

plot(0, color=scolor, style=cross, linewidth=2)


Wick Reversal Stratergy

stratergy(“Wick”)

wick_multiplier = input(title="Wick Multiplier", type=float, defval=2.5)

close_thresh = input(title="Close Value Percent", type=float, defval=0.35, minval=0.0, maxval=1.0)

// basic candle computations

top_body = max(close, open)

bot_body = min(close, open)

top_wick_size = high - top_body

body_size = top_body - bot_body

bot_wick_size = bot_body - low

range = high - low


bull_signal = (bot_wick_size > (wick_multiplier*body_size)) and (close > (low +
(range*(1-close_thresh))))

bear_signal = (top_wick_size > (wick_multiplier*body_size)) and (close < (low +


(range*close_thresh)))

plotshape(bull_signal, "Bullish Wick Reversal", style=shape.triangleup,

location=location.belowbar, color=green, size=size.tiny)

plotshape(bear_signal, "Bearish Wick Reversal", style=shape.triangledown,

location=location.abovebar, color=red, size=size.tiny)

longCondition = bull_signal

if (longCondition)

strategy.entry("Long", strategy.long)

shortCondition = bear_signal

if (shortCondition)

strategy.entry("Short", strategy.short)

Example

longCondition = close >dtime_h4 and open < dtime_h4 and EMA < close

if (longCondition)

strategy.entry("Long", strategy.long)

strategy.exit ("Exit Long","Long", trail_points = 40,trail_offset = 1, loss =70)

//trail_points = 40, trail_offset = 3, loss =70 and

shortCondition = close <dtime_l4 and open >dtime_l4 and EMA > close

if (shortCondition)
strategy.entry("Short", strategy.short)

strategy.exit ("Exit Short","Short", trail_points = 10,trail_offset = 1, loss =20)

Test code

if (longCondition and (low[2]>((high[1]+low[1])/2)) )

strategy.entry("Long", strategy.long)

strategy.close("Long Exit", when= (low[1]>((high+low)/2)) )

shortCondition = bear_signal

if (shortCondition and (high[2]<((high[1]+low[1])/2)) )

strategy.entry("Short", strategy.short)

//strategy.close("Short Exit", when= bull_signal )

strategy.close("Short Exit", when= (high[1]<((high+low)/2)) )

shortCondition = bear_signal

if (shortCondition and (high[2] < close[1] ) and (high[1] < ((high+low)/2)))

strategy.entry("Short", strategy.short)
Momentum Indicator

study(title="Relative Strength Index", shorttitle="RSI", format=format.price, precision=2)

src = close, len = input(14, minval=1, title="Length")

up = rma(max(change(src), 0), len)

down = rma(-min(change(src), 0), len)

rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))

plot(rsi, color=color.purple)

band1 = hline(70)

band0 = hline(30)

fill(band1, band0, color=color.purple, transp=90)

// Volume
showMA = input(true)

barColorsOnPrevClose = input(title="Color bars based on previous close", type=input.bool,


defval=false)

palette = barColorsOnPrevClose ? close[1] > close ? color.red : color.green : open > close ?
color.red : color.green

plot(volume, color = palette, style=plot.style_columns, title="Volume", transp=65)

plot(showMA ? sma(volume,20) : na, style=plot.style_area, color=color.blue, title="Volume MA",


transp=65)
Trigger

study("PivotBoss Triggers Test", overlay=true)

// -- DEFAULT STYLE VALUES --

bull_color = #77dd77

bear_color = #ff6961

shape_style_up = shape.labelup

shape_style_down = shape.labeldown

shape_transp = 33

shape_size = size.tiny

text_wr = "WR"

text_fr = "FR"

text_er = "ER"

text_dr = "DR"

// --- INPUTS ---

// wick reversal

wr_factor = input(title="Wick Reversal Factor", type=float, defval=2.5)

wr_close_thresh = input(title="Wick Reversal Body Percent", type=float, defval=0.35,

minval=0.0, maxval=1.0)

wr_strict = input(title="Wick Reversal Strict Rules?", type=bool, defval=true)

// fade & engulfing reversal

atr_period = input(title="ATR Period", type=integer, defval=20, minval=0)

extreme_factor = input(title="Extreme Candle Factor", type=float, defval=2.0, minval=0)


doji_max_pct = input(title="Doji Candle Max Percent", type=float, defval=0.1,

minval=0.0, maxval=1.0)

// fade reversal

fade_body_min_pct = input(title="Minimum Fade Bar Body %", type=float, defval=0.65,

minval=0.0, maxval=1.0)

fade_body_max_pct = input(title="Maximum Fade Bar Body %", type=float, defval=0.85,

minval=0.0, maxval=1.0)

// doji reversal

trend_period = input(title="Trend Comparison Period", type=integer, defval=4)

// --- SIGNAL COMPUTATION ---

// common candlestick body values

full_size = high - low

body_high = max(close, open)

body_low = min(close, open)

body_size = body_high - body_low

wick_high_size = high - body_high

wick_low_size = body_low - low

recent_atr = atr(atr_period)

body_ratio = body_size / full_size

extreme_signal = full_size > (extreme_factor * recent_atr)

doji_signal = (body_size / full_size) < doji_max_pct

// wick reversal

wr_min_wick_size = wr_factor * body_size

wr_bull_thresh = high - (full_size * wr_close_thresh)

wr_bear_thresh = low + (full_size * wr_close_thresh)

wr_bull_src = wr_strict ? close : body_high

wr_bear_src = wr_strict ? close : body_low

wr_bull_signal = (wick_low_size > wr_min_wick_size) and (wr_bull_src > wr_bull_thresh)

wr_bear_signal = (wick_high_size > wr_min_wick_size) and (wr_bear_src < wr_bear_thresh)

// fade reversal

fr_body_check_min = body_ratio[1] >= fade_body_min_pct

fr_body_check_max = body_ratio[1] <= fade_body_max_pct


fr_body_check_fade = extreme_signal[1] and fr_body_check_min and fr_body_check_max

fr_bull_signal = fr_body_check_fade and (close[1] < open[1]) and (close > open)

fr_bear_signal = fr_body_check_fade and (close[1] > open[1]) and (close < open)

// engulfing reversal

er_bull_signal = extreme_signal and (low < low[1]) and (close > high[1])

er_bear_signal = extreme_signal and (high > high[1]) and (close < low[1])

// doji reversal

dr_early_bull = doji_signal[1] and (close > high[1]) and (high[1] < close[trend_period])

dr_early_bear = doji_signal[1] and (close < low[1]) and (low[1] > close[trend_period])

dr_late_bull = doji_signal[2] and (close > high[2]) and (high[2] < close[trend_period + 1])

dr_late_bear = doji_signal[2] and (close < low[2]) and (low[2] > close[trend_period + 1])

dr_bull_signal = dr_early_bull or dr_late_bull

dr_bear_signal = dr_early_bear or dr_late_bear

// --- SIGNAL PLOTTING ---

// wick reversal

plotshape(wr_bull_signal, "Bullish Wick Reversal", shape_style_up, location.belowbar,


bull_color,text=text_wr, textcolor=black, size=shape_size, transp=shape_transp)

plotshape(wr_bear_signal, "Bearish Wick Reversal", shape_style_down, location.abovebar,


bear_color,text=text_wr, textcolor=black, size=shape_size, transp=shape_transp)

// fade reversal

//plotshape(fr_bull_signal, "Bullish Fade Reversal", shape_style_up, location.belowbar,


bull_color,text=text_fr, textcolor=black, size=shape_size, transp=shape_transp)

//plotshape(fr_bear_signal, "Bearish Fade Reversal", shape_style_down, location.abovebar,


bear_color, text=text_fr, textcolor=black, size=shape_size, transp=shape_transp)

// engulfing reversal

//plotshape(er_bull_signal, "Bullish Engulfing Reversal", shape_style_up, location.belowbar,


bull_color, text=text_er, textcolor=black, size=shape_size, transp=shape_transp)

//plotshape(er_bear_signal, "Bearish Engulfing Reversal", shape_style_down, location.abovebar,


bear_color, text=text_er, textcolor=black, size=shape_size, transp=shape_transp)

// doji reversal

plotshape(dr_bull_signal, "Bullish Doji Reversal", shape_style_up, location.belowbar, bull_color,


text=text_dr, textcolor=black, size=shape_size, transp=shape_transp)
plotshape(dr_bear_signal, "Bearish Doji Reversal", shape_style_down, location.abovebar,
bear_color, text=text_dr, textcolor=black, size=shape_size, transp=shape_transp)

combined_signal = (

wr_bull_signal

or wr_bear_signal

or fr_bull_signal

or fr_bear_signal

or er_bull_signal

or er_bear_signal

or dr_bull_signal

or dr_bear_signal)

//lotshape(combined_signal, "Any Reversal", shape.flag, location.bottom, black,size=shape_size,


transp=100)

Full Fledge Code

//

lookbackPeriod = input(title="Lookback Period", type=integer, defval=20, minval=0)

atrMultiplier = input(title="Bar ATR Multiplier", type=float, defval=1.05, minval=0)

typicalAtr = atr(lookbackPeriod)

firstBar_body_size = abs(close[1] - open[1])

firstBar_range = high[1] - low[1]

firstBar_signal = (firstBar_range > (atrMultiplier * typicalAtr))

bull_signal = (low < low[1]) and (close > high[1]) and firstBar_signal

bear_signal = (high > high[1]) and (close < low[1]) and firstBar_signal
plotshape(bull_signal, "Bullish Reversal", shape.labelup, location.belowbar, green,

text="OR", textcolor=black, size=size.tiny)

plotshape(bear_signal, "Bearish Reversal", shape.labeldown, location.abovebar, red,

text="OR", textcolor=black, size=size.tiny)

// WICK REVERSAL

//@version=3

study("Wick Reversal Setup", overlay=true)

wick_multiplier = input(title="Wick Multiplier", type=float, defval=2.5)

close_thresh = input(title="Close Value Percent", type=float, defval=0.35, minval=0.0,


maxval=1.0)

// basic candle computations

top_body = max(close, open)

bot_body = min(close, open)

top_wick_size = high - top_body

body_size = top_body - bot_body

bot_wick_size = bot_body - low

range = high - low

bull_signal = (bot_wick_size > (wick_multiplier*body_size)) and (close > (low +


(range*(1-close_thresh))))

bear_signal = (top_wick_size > (wick_multiplier*body_size)) and (close < (low +


(range*close_thresh)))

plotshape(bull_signal, "Bullish Wick Reversal", style=shape.triangleup,

location=location.belowbar, color=green, size=size.tiny)

plotshape(bear_signal, "Bearish Wick Reversal", style=shape.triangledown,

location=location.abovebar, color=red, size=size.tiny)

//Extreme Reversal
//@version=3

study("Extreme Reversal Setup", overlay=true)

lookbackPeriod = input(title="Lookback Period", type=integer, defval=20, minval=0)

atrMultiplier = input(title="Bar ATR Multiplier", type=float, defval=2.0, minval=0)

barBodyPercentMin = input(title="Minimum Bar Body %", type=float, defval=0.65, minval=0.0,


maxval=1.0)

barBodyPercentMax = input(title="Maximum Bar Body %", type=float, defval=0.85, minval=0.0,


maxval=1.0)

typicalAtr = atr(lookbackPeriod)

firstBar_body_size = abs(close[1] - open[1])

firstBar_range = high[1] - low[1]

firstBar_body_pct = firstBar_body_size / firstBar_range

firstBar_signal = (firstBar_range > (atrMultiplier * typicalAtr)) and (firstBar_body_pct >=


barBodyPercentMin) and (firstBar_body_pct <= barBodyPercentMax)

bull_signal = firstBar_signal and (close[1] < open[1]) and (close > open)

bear_signal = firstBar_signal and (close[1] > open[1]) and (close < open)

plotshape(bull_signal, "Bullish Reversal", shape.labelup, location.belowbar, green,

text="XR", textcolor=black, size=size.tiny)

plotshape(bear_signal, "Bearish Reversal", shape.labeldown, location.abovebar, red,

text="XR", textcolor=black, size=size.tiny)

//PIVOT TRIGGER

//@version=3

study("PivotBoss Triggers", overlay=true)

// -- DEFAULT STYLE VALUES --

bull_color = #77dd77
bear_color = #ff6961

shape_style_up = shape.labelup

shape_style_down = shape.labeldown

shape_transp = 33

shape_size = size.tiny

text_wr = "👠"

text_fr = "👠"

text_er = "👠"

text_dr = "👠"

// --- INPUTS ---

// wick reversal

wr_factor = input(title="Wick Reversal Factor", type=float, defval=2.5)

wr_close_thresh = input(title="Wick Reversal Body Percent", type=float, defval=0.35,

minval=0.0, maxval=1.0)

wr_strict = input(title="Wick Reversal Strict Rules?", type=bool, defval=true)

// fade & engulfing reversal

atr_period = input(title="ATR Period", type=integer, defval=20, minval=0)

extreme_factor = input(title="Extreme Candle Factor", type=float, defval=2.0, minval=0)

doji_max_pct = input(title="Doji Candle Max Percent", type=float, defval=0.1,

minval=0.0, maxval=1.0)

// fade reversal

fade_body_min_pct = input(title="Minimum Fade Bar Body %", type=float, defval=0.65,

minval=0.0, maxval=1.0)

fade_body_max_pct = input(title="Maximum Fade Bar Body %", type=float, defval=0.85,

minval=0.0, maxval=1.0)

// doji reversal

trend_period = input(title="Trend Comparison Period", type=integer, defval=4)

// --- SIGNAL COMPUTATION ---

// common candlestick body values

full_size = high - low

body_high = max(close, open)


body_low = min(close, open)

body_size = body_high - body_low

wick_high_size = high - body_high

wick_low_size = body_low - low

recent_atr = atr(atr_period)

body_ratio = body_size / full_size

extreme_signal = full_size > (extreme_factor * recent_atr)

doji_signal = (body_size / full_size) < doji_max_pct

// wick reversal

wr_min_wick_size = wr_factor * body_size

wr_bull_thresh = high - (full_size * wr_close_thresh)

wr_bear_thresh = low + (full_size * wr_close_thresh)

wr_bull_src = wr_strict ? close : body_high

wr_bear_src = wr_strict ? close : body_low

wr_bull_signal = (wick_low_size > wr_min_wick_size) and (wr_bull_src > wr_bull_thresh)

wr_bear_signal = (wick_high_size > wr_min_wick_size) and (wr_bear_src < wr_bear_thresh)

// fade reversal

fr_body_check_min = body_ratio[1] >= fade_body_min_pct

fr_body_check_max = body_ratio[1] <= fade_body_max_pct

fr_body_check_fade = extreme_signal[1] and fr_body_check_min and fr_body_check_max

fr_bull_signal = fr_body_check_fade and (close[1] < open[1]) and (close > open)

fr_bear_signal = fr_body_check_fade and (close[1] > open[1]) and (close < open)

// engulfing reversal

er_bull_signal = extreme_signal and (low < low[1]) and (close > high[1])

er_bear_signal = extreme_signal and (high > high[1]) and (close < low[1])

// doji reversal

dr_early_bull = doji_signal[1] and (close > high[1]) and (high[1] < close[trend_period])

dr_early_bear = doji_signal[1] and (close < low[1]) and (low[1] > close[trend_period])

dr_late_bull = doji_signal[2] and (close > high[2]) and (high[2] < close[trend_period + 1])

dr_late_bear = doji_signal[2] and (close < low[2]) and (low[2] > close[trend_period + 1])

dr_bull_signal = dr_early_bull or dr_late_bull

dr_bear_signal = dr_early_bear or dr_late_bear


// --- SIGNAL PLOTTING ---

// wick reversal

plotshape(wr_bull_signal, "Bullish Wick Reversal", shape_style_up, location.belowbar,


bull_color,

text=text_wr, textcolor=black, size=shape_size, transp=shape_transp)

plotshape(wr_bear_signal, "Bearish Wick Reversal", shape_style_down, location.abovebar,


bear_color,

text=text_wr, textcolor=black, size=shape_size, transp=shape_transp)

// fade reversal

plotshape(fr_bull_signal, "Bullish Fade Reversal", shape_style_up, location.belowbar, bull_color,

text=text_fr, textcolor=black, size=shape_size, transp=shape_transp)

plotshape(fr_bear_signal, "Bearish Fade Reversal", shape_style_down, location.abovebar,


bear_color,

text=text_fr, textcolor=black, size=shape_size, transp=shape_transp)

// engulfing reversal

plotshape(er_bull_signal, "Bullish Engulfing Reversal", shape_style_up, location.belowbar,


bull_color,

text=text_er, textcolor=black, size=shape_size, transp=shape_transp)

plotshape(er_bear_signal, "Bearish Engulfing Reversal", shape_style_down, location.abovebar,


bear_color,

text=text_er, textcolor=black, size=shape_size, transp=shape_transp)

// doji reversal

plotshape(dr_bull_signal, "Bullish Doji Reversal", shape_style_up, location.belowbar, bull_color,

text=text_dr, textcolor=black, size=shape_size, transp=shape_transp)

plotshape(dr_bear_signal, "Bearish Doji Reversal", shape_style_down, location.abovebar,


bear_color,

text=text_dr, textcolor=black, size=shape_size, transp=shape_transp)

combined_signal = (

wr_bull_signal

or wr_bear_signal

or fr_bull_signal

or fr_bear_signal

or er_bull_signal

or er_bear_signal
or dr_bull_signal

or dr_bear_signal)

plotshape(combined_signal, "Any Reversal", shape.flag, location.bottom, black,

size=shape_size, transp=100)

// VWAP

l1=input(1.0, title="VWAP 1 Multiplier")

l2=input(2.0, title="VWAP 1 Multiplier")

l3=input(2.5, title="VWAP 3 Multiplier")

src=close

b=vwap(src)

length=input(34)

plot(b, color=gray, linewidth=2)

plot(b+l1*stdev(src, length), linewidth=2, color=red ,style = stepline )

plot(b+l2*stdev(src, length), linewidth=2, color=red, style=stepline)

plot(b+l3*stdev(src, length), linewidth=2, color=red, style=stepline)

plot(b-l1*stdev(src, length), linewidth=2, color=green, style=stepline)

plot(b-l2*stdev(src, length), linewidth=2, color=green, style=stepline)

plot(b-l3*stdev(src, length), linewidth=2, color=green, style=stepline)

//Boring Candle

Candle_Range = high - low

Body_Range = abs( close - open )

//Boring Candles or Basing Candles Body Range <= 50% of Candle Range

barcolor( (Body_Range <= Candle_Range * 0.5) ? blue : na)

//GAPS

plotshape(low[0] > high[1], "GAP_UP", shape.labelup, location.belowbar, white,

text="UG", textcolor=black, size=size.tiny)

plotshape(high[0] < low[1], "GAP_DOWN", shape.labeldown, location.abovebar, red,


text="DG", textcolor=black, size=size.tiny)

barcolor( (low[0] > high[1]) ? black : na)

barcolor( (high[0] < low[1]) ? white : na)

// Market Profile

// ||-- Inputs:

session_timeframe = input('D')

percent_of_tpo = input(0.70)

tf_high = high

tf_low = low

tf_close = close

// ||-- Bars since session started:

session_bar_counter = n - valuewhen(change(time(session_timeframe)) != 0, n, 0)

//plot(session_bar_counter)

// ||-- session high, low, range:

session_high = tf_high

session_low = tf_low

session_range = tf_high - tf_low

session_high := nz(session_high[1], tf_high)

session_low := nz(session_low[1], tf_low)

session_range := nz(session_high - session_low, 0.0)

// ||-- recalculate session high, low and range:

if session_bar_counter == 0

session_high := tf_high

session_low := tf_low

session_range := tf_high - tf_low

if tf_high > session_high[1]

session_high := tf_high
session_range := session_high - session_low

if tf_low < session_low[1]

session_low := tf_low

session_range := session_high - session_low

plot(series=session_high, title='Session High', color=blue ,style = stepline)

plot(series=session_low, title='Session Low', color=blue ,style = stepline)

//plot(series=session_range, title='Session Range', color=black)

// ||-- define tpo section range:

tpo_section_range = session_range / 21

// ||-- function to get the frequency a specified range is visited:

f_frequency_of_range(_src, _upper_range, _lower_range, _length)=>

_adjusted_length = _length < 1 ? 1 : _length

_frequency = 0

for _i = 0 to _adjusted_length-1

if (_src[_i] >= _lower_range and _src[_i] <= _upper_range)

_frequency := _frequency + 1

_return = nz(_frequency, 0) // _adjusted_length

// ||-- frequency the tpo range is visited:

tpo_00 = f_frequency_of_range(tf_close, session_high, session_high - tpo_section_range * 1,


session_bar_counter)

tpo_01 = f_frequency_of_range(tf_close, session_high - tpo_section_range * 1, session_high -


tpo_section_range * 2, session_bar_counter)

tpo_02 = f_frequency_of_range(tf_close, session_high - tpo_section_range * 2, session_high -


tpo_section_range * 3, session_bar_counter)

tpo_03 = f_frequency_of_range(tf_close, session_high - tpo_section_range * 3, session_high -


tpo_section_range * 4, session_bar_counter)

tpo_04 = f_frequency_of_range(tf_close, session_high - tpo_section_range * 4, session_high -


tpo_section_range * 5, session_bar_counter)

tpo_05 = f_frequency_of_range(tf_close, session_high - tpo_section_range * 5, session_high -


tpo_section_range * 6, session_bar_counter)

tpo_06 = f_frequency_of_range(tf_close, session_high - tpo_section_range * 6, session_high -


tpo_section_range * 7, session_bar_counter)

tpo_07 = f_frequency_of_range(tf_close, session_high - tpo_section_range * 7, session_high -


tpo_section_range * 8, session_bar_counter)

tpo_08 = f_frequency_of_range(tf_close, session_high - tpo_section_range * 8, session_high -


tpo_section_range * 9, session_bar_counter)
tpo_09 = f_frequency_of_range(tf_close, session_high - tpo_section_range * 9, session_high -
tpo_section_range * 10, session_bar_counter)

tpo_10 = f_frequency_of_range(tf_close, session_high - tpo_section_range * 10, session_high -


tpo_section_range * 11, session_bar_counter)

tpo_11 = f_frequency_of_range(tf_close, session_high - tpo_section_range * 11, session_high -


tpo_section_range * 12, session_bar_counter)

tpo_12 = f_frequency_of_range(tf_close, session_high - tpo_section_range * 12, session_high -


tpo_section_range * 13, session_bar_counter)

tpo_13 = f_frequency_of_range(tf_close, session_high - tpo_section_range * 13, session_high -


tpo_section_range * 14, session_bar_counter)

tpo_14 = f_frequency_of_range(tf_close, session_high - tpo_section_range * 14, session_high -


tpo_section_range * 15, session_bar_counter)

tpo_15 = f_frequency_of_range(tf_close, session_high - tpo_section_range * 15, session_high -


tpo_section_range * 16, session_bar_counter)

tpo_16 = f_frequency_of_range(tf_close, session_high - tpo_section_range * 16, session_high -


tpo_section_range * 17, session_bar_counter)

tpo_17 = f_frequency_of_range(tf_close, session_high - tpo_section_range * 17, session_high -


tpo_section_range * 18, session_bar_counter)

tpo_18 = f_frequency_of_range(tf_close, session_high - tpo_section_range * 18, session_high -


tpo_section_range * 19, session_bar_counter)

tpo_19 = f_frequency_of_range(tf_close, session_high - tpo_section_range * 19, session_high -


tpo_section_range * 20, session_bar_counter)

tpo_20 = f_frequency_of_range(tf_close, session_high - tpo_section_range * 20, session_high -


tpo_section_range * 21, session_bar_counter)

// ||-- function to retrieve a specific tpo value

f_get_tpo_count(_value)=>

_return = 0.0

if _value == 0

_return := tpo_00

if _value == 1

_return := tpo_01

if _value == 2

_return := tpo_02

if _value == 3

_return := tpo_03

if _value == 4

_return := tpo_04
if _value == 5

_return := tpo_05

if _value == 6

_return := tpo_06

if _value == 7

_return := tpo_07

if _value == 8

_return := tpo_08

if _value == 9

_return := tpo_09

if _value == 10

_return := tpo_10

if _value == 11

_return := tpo_11

if _value == 12

_return := tpo_12

if _value == 13

_return := tpo_13

if _value == 14

_return := tpo_14

if _value == 15

_return := tpo_15

if _value == 16

_return := tpo_16

if _value == 17

_return := tpo_17

if _value == 18

_return := tpo_18

if _value == 19

_return := tpo_19

if _value == 20

_return := tpo_20

_return
tpo_sum = 0.0

current_poc_position = 0.0

current_poc_value = 0.0

for _i = 0 to 20

_get_tpo_value = f_get_tpo_count(_i)

tpo_sum := tpo_sum + _get_tpo_value

if _get_tpo_value > current_poc_value

current_poc_position := _i

current_poc_value := _get_tpo_value

//plot(series=tpo_sum, title='tpo_sum', color=red)

poc_upper = session_high - tpo_section_range * current_poc_position

poc_lower = session_high - tpo_section_range * (current_poc_position + 1)

plot(series=poc_upper, title='POC Upper', color=green,style = stepline)

plot(series=poc_lower, title='POC Lower', color=green , style = stepline)

// ||-- get value area high/low

vah_position = current_poc_position

val_position = current_poc_position

current_sum = current_poc_value

for _i = 0 to 20

if current_sum < tpo_sum * percent_of_tpo

vah_position := max(0, vah_position - 1)

current_sum := current_sum + f_get_tpo_count(round(vah_position))

if current_sum < tpo_sum * percent_of_tpo

val_position := min(20, val_position + 1)

current_sum := current_sum + f_get_tpo_count(round(val_position))

vah_value = session_high - tpo_section_range * vah_position

val_value = session_high - tpo_section_range * (val_position + 1)

plot(series=vah_value, title='VAH', color=white , style = stepline)

plot(series=val_value, title='VAL', color=white , style = stepline)


//plot(series=current_sum, title='SUM', color=red)

You might also like