// This source code is subject to the terms of the Mozilla Public License 2.
0 at
https://mozilla.org/MPL/2.0/
// � lookvikram
study(title="ALL IN ONE", shorttitle="ALL IN ONE", overlay=true)
active = input(true, title="Show On Chart")
pricehigh = security(tickerid, 'D', high[1])
pricelow = security(tickerid, 'D', low[1])
prepricehigh = security(tickerid, 'D', high[2])
prepricelow = security(tickerid, 'D', low[2])
offs_daily = 0
plot(active and pricehigh ? pricehigh : na, title="Previous Daily High", style=line
, linewidth=2, color=gray)
plot(active and pricelow ? pricelow : na, title="Previous Daily Low", style=line,
linewidth=2, color=gray)
plot(active and prepricehigh ? prepricehigh : na, title="Second Daily High",
style=line, linewidth=2, color=red)
plot(active and prepricelow ? prepricelow : na, title="Second Daily Low",
style=line, linewidth=2, color=red)
plot(ema(high,9), color=red, linewidth=1, style=line, transp=25, title="EMA 9")
plot(ema(close,5), color=blue, linewidth=1, style=line, transp=25, title="LEMA 5")
plot(ema(high,50), color=teal, linewidth=1, style=line, transp=25, title="HEMA 50")
vwapval = vwap(close)
plot(vwapval, color=black, title="vwapval")
// EMA Golden/Death Cross Indicator
fastEmaPeriod = input(5, minval=1, title="Fast EMA Periods")
slowWmaPeriod = input(9, minval=1, title="Slow WMA Periods")
showCrosses = input(true, title="Show EMA Crosses?")
fastEma = ema(close, fastEmaPeriod)
slowWma = wma(close, slowWmaPeriod)
plot(fastEma, title = 'Fast EMA', linewidth=1, color=lime)
plot(slowWma, title = 'Slow WMA', linewidth=1, color=fuchsia)
goldenCross = crossover(fastEma, slowWma)
deathCross = crossover(slowWma, fastEma)
plotarrow(showCrosses and goldenCross ? goldenCross : na, title="Golden Cross",
colorup=green, maxheight=50, minheight=50, transp=0)
plotarrow(showCrosses and deathCross*-1 ? deathCross*-1 : na, title="Death Cross",
colordown=red, maxheight=50, minheight=50, transp=0)
// Script created by JoinFree
// BollingerBands added for reference
// Buy Long when you see a Green colour bar
// Sell Short when you see a Red colour bar
mysignal = ema(close, 12) - ema(close, 26)
barcolor(mysignal[0] > mysignal[1] ? green : red)
source = close
length = input(20, minval=1), mult = input(2.0, minval=0.001, maxval=50)
basis = sma(source, length)
dev = mult * stdev(source, length)
upper = basis + dev
lower = basis - dev
plot(basis, color=red)
p1 = plot(upper, color=blue)
p2 = plot(lower, color=blue)
fill(p1, p2)
showPatterns = input(false)
showBarColors = input(false)
// ||--- Fractal Recognition:
filterBW = input(false, title="filter Bill Williams Fractals:")
//
||---------------------------------------------------------------------------------
--------------------||
// ||--- Fractal Recognition Functions:
---------------------------------------------------------------||
isRegularFractal(mode) =>
ret = mode == 1 ? high[4] < high[3] and high[3] < high[2] and high[2] > high[1]
and high[1] > high[0] :
mode == -1 ? low[4] > low[3] and low[3] > low[2] and low[2] < low[1] and
low[1] < low[0] : false
isBWFractal(mode) =>
ret = mode == 1 ? high[4] < high[2] and high[3] <= high[2] and high[2] >=
high[1] and high[2] > high[0] :
mode == -1 ? low[4] > low[2] and low[3] >= low[2] and low[2] <= low[1] and
low[2] < low[0] : false
//
||---------------------------------------------------------------------------------
--------------------||
filteredtopf = filterBW ? isRegularFractal(1) : isBWFractal(1)
filteredbotf = filterBW ? isRegularFractal(-1) : isBWFractal(-1)
plotshape(filteredtopf, title='Filtered Top Fractals', style=shape.triangledown,
location=location.abovebar, color=red, offset=-2)
plotshape(filteredbotf, title='Filtered Bottom Fractals', style=shape.triangleup,
location=location.belowbar, color=lime, offset=-2)
//
||---------------------------------------------------------------------------------
--------------------||
// ||--- Higher Highs, Lower Highs, Higher Lows, Lower Lows
-------------------------------------------||
ShowHHLL = input(false)
higherhigh = filteredtopf == false ? false : (
valuewhen(filteredtopf == true, high[2], 1) < valuewhen(filteredtopf ==
true, high[2], 0) and
valuewhen(filteredtopf == true, high[2], 2) < valuewhen(filteredtopf ==
true, high[2], 0)
)
lowerhigh = filteredtopf == false ? false : (
valuewhen(filteredtopf == true, high[2], 1) > valuewhen(filteredtopf ==
true, high[2], 0) and
valuewhen(filteredtopf == true, high[2], 2) > valuewhen(filteredtopf ==
true, high[2], 0)
)
higherlow = filteredbotf == false ? false : (
valuewhen(filteredbotf == true, low[2], 1) < valuewhen(filteredbotf ==
true, low[2], 0) and
valuewhen(filteredbotf == true, low[2], 2) < valuewhen(filteredbotf ==
true, low[2], 0)
)
lowerlow = filteredbotf == false ? false : (
valuewhen(filteredbotf == true, low[2], 1) > valuewhen(filteredbotf ==
true, low[2], 0) and
valuewhen(filteredbotf == true, low[2], 2) > valuewhen(filteredbotf ==
true, low[2], 0)
)
plotshape(ShowHHLL ? higherhigh : na, title='Higher High', style=shape.square,
location=location.abovebar, color=maroon, text="[HH]", offset=-2)
plotshape(ShowHHLL ? lowerhigh : na, title='Lower High', style=shape.square,
location=location.abovebar, color=maroon, text="[LH]", offset=-2)
plotshape(ShowHHLL ? higherlow : na, title='High Low', style=shape.square,
location=location.belowbar, color=green, text="[HL]", offset=-2)
plotshape(ShowHHLL ? lowerlow : na, title='Lower Low', style=shape.square,
location=location.belowbar, color=green, text="[LL]", offset=-2)
//
||---------------------------------------------------------------------------------
--------------------||
//
||---------------------------------------------------------------------------------
--------------------||
// ||--- Fractals from higher Timeframe:
--------------------------------------------------------------||
ShowTimeFractals1 = input(false)
timeframe1 = input("240")
isTFFractal(mode, tf) =>
ret = mode == 1 ? valuewhen(higherhigh == true, high[2], 0) >=
security(tickerid, tf, high) :
mode == -1 ? valuewhen(lowerlow == true, low[2], 0) <= security(tickerid,
tf, low) : false
higherhhigh = higherhigh == false ? false : isTFFractal(1, timeframe1)
lowerllow = lowerlow == false ? false : isTFFractal(-1, timeframe1)
plotshape(ShowTimeFractals1 ? higherhhigh : na, title='Timed Top Fractals',
style=shape.square, location=location.abovebar, color=maroon, text="[TH]", offset=-
2)
plotshape(ShowTimeFractals1 ? lowerllow : na, title='Timed Bottom Fractals',
style=shape.square, location=location.belowbar, color=green, text="[TL]", offset=-
2)
//
||---------------------------------------------------------------------------------
--------------------||
// ||--- V2 : Plot Lines based on the fractals.
showchannel1 = input(false)
plot(not showchannel1 ? na : (filteredtopf ? high[2] : na), title='Top Channel 1',
color=black, offset=-2)
plot(not showchannel1 ? na : (filteredbotf ? low[2] : na), title='Bottom Channel
1', color=black, offset=-2)
showchannel2 = input(false)
plot(not showchannel2 ? na : (higherhigh ? high[2] : na), title='Top Channel 2',
color=gray, offset=-2)
plot(not showchannel2 ? na : (lowerlow ? low[2] : na), title='Bottom Channel 2',
color=gray, offset=-2)
showchannel3 = input(false)
plot(not showchannel3 ? na : (higherhhigh ? high[2] : na), title='Top Channel 3',
color=silver, offset=-2)
plot(not showchannel3 ? na : (lowerllow ? low[2] : na), title='Bottom Channel 3',
color=silver, offset=-2)
//
||---------------------------------------------------------------------------------
--------------------||
// ||--- HLswings channel: unable to offset values
//plot(showchannel ? (highswings ? high[2] : na) : na, color=black, offset=-2)
//plot(showchannel ? (lowswings ? low[2] : na) : na, color=black, offset=-2)
//
||---------------------------------------------------------------------------------
--------------------||
//
||---------------------------------------------------------------------------------
------------------------------------------------------------------||
// ||--- ZigZag:
showZigZag = input(true)
istop = ShowTimeFractals1 ? (higherhhigh ? true : false) : (filteredtopf ? true :
false)
isbot = ShowTimeFractals1 ? (lowerllow ? true : false) : (filteredbotf ? true :
false)
topcount = barssince(istop)
botcount = barssince(isbot)
zigzag = (
istop and topcount[1] > botcount[1] ? high[2] :
isbot and topcount[1] < botcount[1] ? low[2] :
na )
//zigzag = not showZigZag ? na : ( filteredtopf == true ? high[2] : filteredbotf ==
true ? low[2] : na )
plot(not showZigZag ? na : zigzag, title= 'ZigZag', color=white, offset=-2)
//
||---------------------------------------------------------------------------------
--------------------||
bc = zigzag and high[2] == zigzag ? red : zigzag and low[2] == zigzag ? lime :
silver
barcolor(showBarColors ? bc : na, offset=-2)
// ||--- Pattern Recognition:
x = valuewhen(zigzag, zigzag, 4)
a = valuewhen(zigzag, zigzag, 3)
b = valuewhen(zigzag, zigzag, 2)
c = valuewhen(zigzag, zigzag, 1)
d = valuewhen(zigzag, zigzag, 0)
xab = (abs(b-a)/abs(x-a))
xad = (abs(a-d)/abs(x-a))
abc = (abs(b-c)/abs(a-b))
bcd = (abs(c-d)/abs(b-c))
// ||--> Functions:
isBat(_mode)=>
_xab = xab >= 0.382 and xab <= 0.5
_abc = abc >= 0.382 and abc <= 0.886
_bcd = bcd >= 1.618 and bcd <= 2.618
_xad = xad <= 0.886
_xab and _abc and _bcd and _xad and (_mode == 1 ? d < c : d > c)
isAltBat(_mode)=>
_xab = xab <= 0.382
_abc = abc >= 0.382 and abc <= 0.886
_bcd = bcd >= 2.0 and bcd <= 3.618
_xad = xad <= 1.13
_xab and _abc and _bcd and _xad and (_mode == 1 ? d < c : d > c)
isButterfly(_mode)=>
_xab = xab <= 0.786
_abc = abc >= 0.382 and abc <= 0.886
_bcd = bcd >= 1.618 and bcd <= 2.618
_xad = xad >= 1.27 and xad <= 1.618
_xab and _abc and _bcd and _xad and (_mode == 1 ? d < c : d > c)
isABCD(_mode)=>
_abc = abc >= 0.382 and abc <= 0.886
_bcd = bcd >= 1.13 and bcd <= 2.618
_abc and _bcd and (_mode == 1 ? d < c : d > c)
isGartley(_mode)=>
_xab = xab >= 0.5 and xab <= 0.618 // 0.618
_abc = abc >= 0.382 and abc <= 0.886
_bcd = bcd >= 1.13 and bcd <= 2.618
_xad = xad >= 0.75 and xad <= 0.875 // 0.786
_xab and _abc and _bcd and _xad and (_mode == 1 ? d < c : d > c)
isCrab(_mode)=>
_xab = xab >= 0.75 and xab <= 0.875 // 0.886
_abc = abc >= 0.382 and abc <= 0.886
_bcd = bcd >= 2.0 and bcd <= 3.618
_xad = xad >= 1.5 and xad <= 1.625 // 1.618
_xab and _abc and _bcd and _xad and (_mode == 1 ? d < c : d > c)
isShark(_mode)=>
_xab = xab >= 0.5 and xab <= 0.875 // 0.886
_abc = abc >= 1.13 and abc <= 1.618
_bcd = bcd >= 1.27 and bcd <= 2.24
_xad = xad >= 0.88 and xad <= 1.13
_xab and _abc and _bcd and _xad and (_mode == 1 ? d < c : d > c)
is5o(_mode)=>
_xab = xab >= 1.13 and xab <= 1.618
_abc = abc >= 1.618 and abc <= 2.24
_bcd = bcd >= 0.5 and bcd <= 0.625 // 0.5
_xad = xad >= 0.0 and xad <= 0.236 // negative?
_xab and _abc and _bcd and _xad and (_mode == 1 ? d < c : d > c)
isWolf(_mode)=>
_xab = xab >= 1.27 and xab <= 1.618
_abc = abc >= 0 and abc <= 5
_bcd = bcd >= 1.27 and bcd <= 1.618
_xad = xad >= 0.0 and xad <= 5
_xab and _abc and _bcd and _xad and (_mode == 1 ? d < c : d > c)
isHnS(_mode)=>
_xab = xab >= 2.0 and xab <= 10
_abc = abc >= 0.90 and abc <= 1.1
_bcd = bcd >= 0.236 and bcd <= 0.88
_xad = xad >= 0.90 and xad <= 1.1
_xab and _abc and _bcd and _xad and (_mode == 1 ? d < c : d > c)
isConTria(_mode)=>
_xab = xab >= 0.382 and xab <= 0.618
_abc = abc >= 0.382 and abc <= 0.618
_bcd = bcd >= 0.382 and bcd <= 0.618
_xad = xad >= 0.236 and xad <= 0.764
_xab and _abc and _bcd and _xad and (_mode == 1 ? d < c : d > c)
isExpTria(_mode)=>
_xab = xab >= 1.236 and xab <= 1.618
_abc = abc >= 1.000 and abc <= 1.618
_bcd = bcd >= 1.236 and bcd <= 2.000
_xad = xad >= 2.000 and xad <= 2.236
_xab and _abc and _bcd and _xad and (_mode == 1 ? d < c : d > c)
plotshape(not showPatterns ? na : isABCD(-1) and not isABCD(-1)[1], text="\nAB=CD",
title='Bear ABCD', style=shape.labeldown, color=maroon, textcolor=white,
location=location.top, transp=0, offset=-2)
plotshape(not showPatterns ? na : isBat(-1) and not isBat(-1)[1], text="Bat",
title='Bear Bat', style=shape.labeldown, color=maroon, textcolor=white,
location=location.top, transp=0, offset=-2)
plotshape(not showPatterns ? na : isAltBat(-1) and not isAltBat(-1)[1], text="Alt
Bat", title='Bear Alt Bat', style=shape.labeldown, color=maroon, textcolor=white,
location=location.top, transp=0)
plotshape(not showPatterns ? na : isButterfly(-1) and not isButterfly(-1)[1],
text="Butterfly", title='Bear Butterfly', style=shape.labeldown, color=maroon,
textcolor=white, location=location.top, transp=0)
plotshape(not showPatterns ? na : isGartley(-1) and not isGartley(-1)[1],
text="Gartley", title='Bear Gartley', style=shape.labeldown, color=maroon,
textcolor=white, location=location.top, transp=0)
plotshape(not showPatterns ? na : isCrab(-1) and not isCrab(-1)[1], text="Crab",
title='Bear Crab', style=shape.labeldown, color=maroon, textcolor=white,
location=location.top, transp=0)
plotshape(not showPatterns ? na : isShark(-1) and not isShark(-1)[1], text="Shark",
title='Bear Shark', style=shape.labeldown, color=maroon, textcolor=white,
location=location.top, transp=0)
plotshape(not showPatterns ? na : is5o(-1) and not is5o(-1)[1], text="5-O",
title='Bear 5-O', style=shape.labeldown, color=maroon, textcolor=white,
location=location.top, transp=0)
plotshape(not showPatterns ? na : isWolf(-1) and not isWolf(-1)[1], text="Wolf
Wave", title='Bear Wolf Wave', style=shape.labeldown, color=maroon,
textcolor=white, location=location.top, transp=0)
plotshape(not showPatterns ? na : isHnS(-1) and not isHnS(-1)[1], text="Head and
Shoulders", title='Bear Head and Shoulders', style=shape.labeldown, color=maroon,
textcolor=white, location=location.top, transp=0)
plotshape(not showPatterns ? na : isConTria(-1) and not isConTria(-1)[1],
text="Contracting Triangle", title='Bear Contracting triangle',
style=shape.labeldown, color=maroon, textcolor=white, location=location.top,
transp=0)
plotshape(not showPatterns ? na : isExpTria(-1) and not isExpTria(-1)[1],
text="Expanding Triangle", title='Bear Expanding Triangle', style=shape.labeldown,
color=maroon, textcolor=white, location=location.top, transp=0)
plotshape(not showPatterns ? na : isABCD(1) and not isABCD(1)[1], text="AB=CD\n",
title='Bull ABCD', style=shape.labelup, color=green, textcolor=white,
location=location.bottom, transp=0)
plotshape(not showPatterns ? na : isBat(1) and not isBat(1)[1], text="Bat",
title='Bull Bat', style=shape.labelup, color=green, textcolor=white,
location=location.bottom, transp=0)
plotshape(not showPatterns ? na : isAltBat(1) and not isAltBat(1)[1], text="Alt
Bat", title='Bull Alt Bat', style=shape.labelup, color=green, textcolor=white,
location=location.bottom, transp=0)
plotshape(not showPatterns ? na : isButterfly(1) and not isButterfly(1)[1],
text="Butterfly", title='Bull Butterfly', style=shape.labelup, color=green,
textcolor=white, location=location.bottom, transp=0)
plotshape(not showPatterns ? na : isGartley(1) and not isGartley(1)[1],
text="Gartley", title='Bull Gartley', style=shape.labelup, color=green,
textcolor=white, location=location.bottom, transp=0)
plotshape(not showPatterns ? na : isCrab(1) and not isCrab(1)[1], text="Crab",
title='Bull Crab', style=shape.labelup, color=green, textcolor=white,
location=location.bottom, transp=0)
plotshape(not showPatterns ? na : isShark(1) and not isShark(1)[1], text="Shark",
title='Bull Shark', style=shape.labelup, color=green, textcolor=white,
location=location.bottom, transp=0)
plotshape(not showPatterns ? na : is5o(1) and not is5o(1)[1], text="5-O",
title='Bull 5-O', style=shape.labelup, color=green, textcolor=white,
location=location.bottom, transp=0)
plotshape(not showPatterns ? na : isWolf(1) and not isWolf(1)[1], text="Wolf Wave",
title='Bull Wolf Wave', style=shape.labelup, color=green, textcolor=white,
location=location.bottom, transp=0)
plotshape(not showPatterns ? na : isHnS(1) and not isHnS(1)[1], text="Head and
Shoulders", title='Bull Head and Shoulders', style=shape.labelup, color=green,
textcolor=white, location=location.bottom, transp=0)
plotshape(not showPatterns ? na : isConTria(1) and not isConTria(1)[1],
text="Contracting Triangle", title='Bull Contracting Triangle',
style=shape.labelup, color=green, textcolor=white, location=location.bottom,
transp=0)
plotshape(not showPatterns ? na : isExpTria(1) and not isExpTria(1)[1],
text="Expanding Triangle", title='Bull Expanding Triangle', style=shape.labelup,
color=green, textcolor=white, location=location.bottom, transp=0)