PHP Code:
//@version=5
indicator('kombin', shorttitle='.', overlay=true, max_polylines_count = 100, max_lines_count = 100, max_labels_count = 100, precision=2)
length = input.int(19, "TTM Squeeze Length")
//BOLLINGER BANDS
BB_mult = input.float(2.0, "Bollinger Band STD Multiplier")
BB_basis = ta.sma(close, length)
dev = BB_mult * ta.stdev(close, length)
BB_upper = BB_basis + dev
BB_lower = BB_basis - dev
atr = ta.atr(14)
//KELTNER CHANNELS
KC_mult_high = input.float(1.0, "Keltner Channel #1")
KC_mult_mid = input.float(1.5, "Keltner Channel #2")
KC_mult_low = input.float(2.0, "Keltner Channel #3")
KC_basis = ta.sma(close, length)
devKC = ta.sma(ta.tr, length)
KC_upper_high = KC_basis + devKC * KC_mult_high
KC_lower_high = KC_basis - devKC * KC_mult_high
KC_upper_mid = KC_basis + devKC * KC_mult_mid
KC_lower_mid = KC_basis - devKC * KC_mult_mid
KC_upper_low = KC_basis + devKC * KC_mult_low
KC_lower_low = KC_basis - devKC * KC_mult_low
//SQUEEZE CONDITIONS
NoSqz = BB_lower < KC_lower_low or BB_upper > KC_upper_low //NO SQUEEZE: GREEN
LowSqz = BB_lower >= KC_lower_low or BB_upper <= KC_upper_low //LOW COMPRESSION: BLACK
MidSqz = BB_lower >= KC_lower_mid or BB_upper <= KC_upper_mid //MID COMPRESSION: RED
HighSqz = BB_lower >= KC_lower_high or BB_upper <= KC_upper_high //HIGH COMPRESSION: ORANGE
//MOMENTUM OSCILLATOR
mom = ta.linreg(close - math.avg(math.avg(ta.highest(high, length), ta.lowest(low, length)), ta.sma(close, length)), length, 0)
//MOMENTUM HISTOGRAM COLOR
iff_1 = mom > nz(mom[1]) ? color.new(color.aqua, 0) : color.new(#2962ff, 0)
iff_2 = mom < nz(mom[1]) ? color.new(color.red, 0) : color.new(color.yellow, 0)
mom_color = mom > 0 ? iff_1 : iff_2
// Bullsqueeze and Bearsqueeze Conditions
bullsqueeze = ((NoSqz and mom_color == color.new(color.aqua, 0)) or (mom_color == color.new(color.aqua, 0) and mom_color[1] == color.new(color.red, 0)))
bearsqueeze = ((NoSqz and mom_color == color.new(color.red, 0)) or (mom_color == color.new(color.red, 0) and mom_color[1] == color.new(color.aqua, 0)))
// BULL AND BEAR WATCH OUT Conditions
buyConf = (mom_color == color.new(color.aqua, 0) and mom_color[1] == color.new(color.yellow, 0)) and not bullsqueeze
sellConf = (mom_color == color.new(color.red, 0) and mom_color[1] == color.new(#2962ff, 0)) and not bearsqueeze
// User inputs for colors and widths related to the BAND
userColorBullish = input.color(color.white, "Bullish Band Color", group= "Customize BAND")
userColorBearish = input.color(color.red, "Bearish Band Color",group= "Customize BAND")
bandWidthMultiplier = input.float(2.0, "Band Width Multiplier", minval=1.0,group= "Customize BAND")
userWidth = input.int(2, "Band Width", minval=1,group= "Customize BAND")
// Adjusted band calculations
upperBand = high + (atr * bandWidthMultiplier)
lowerBand = low - (atr * bandWidthMultiplier)
// Initialize a color variable for the band
var color bandColor = na
// Initialize a variable to store the previous band color
var color prevBandColor = na
// Update the previous band color for the next bar
prevBandColor := bandColor[1]
// Create variables to store the previous squeeze state
var bool prevBullSqueeze = false
var bool prevBearSqueeze = false
// Update the previous squeeze state at the beginning of each new bar
if (barstate.isnew)
prevBullSqueeze := bandColor == color.new(userColorBullish, 0)
prevBearSqueeze := bandColor == color.new(userColorBearish, 00)
// Determine the band color based on custom conditions
if (bullsqueeze)
bandColor := color.new(userColorBullish, 0)
else if (bearsqueeze)
bandColor := color.new(userColorBearish, 00)
else if (sellConf and prevBullSqueeze)
bandColor := color.new(userColorBullish, 50)
else if (sellConf)
bandColor := color.new(userColorBearish, 00)
else if (buyConf and prevBearSqueeze)
bandColor := color.new(userColorBearish, 00)
else if (buyConf)
bandColor := color.new(userColorBullish, 50)
// Plot the bands and store the plot references
upperBandPlot = plot(upperBand, "H", color=bandColor, linewidth=userWidth)
lowerBandPlot = plot(lowerBand, "L", color=bandColor, linewidth=userWidth)
///////////////////////////////
//@version=5
dual_color=false
var bar_value= 1 //(1-16)
currentHigh = high
previousHigh = high[1]
currentClose = close
previousClose = close[1]
currentLow = low
previousLow = low[1]
//
condition1 = currentHigh > previousHigh and currentClose > previousClose and currentLow > previousLow
condition2 = currentHigh < previousHigh and currentClose > previousClose and currentLow > previousLow
condition3 = currentHigh > previousHigh and currentClose > previousClose and currentLow < previousLow
condition4 = currentHigh < previousHigh and currentClose > previousClose and currentLow < previousLow
//--------------------------------------------------------
condition5 = currentHigh > previousHigh and currentClose < previousClose and currentLow > previousLow
condition6 = currentHigh < previousHigh and currentClose < previousClose and currentLow > previousLow
condition7 = currentHigh > previousHigh and currentClose < previousClose and currentLow < previousLow
condition8 = currentHigh < previousHigh and currentClose < previousClose and currentLow < previousLow
open_up = close > open[1]
open_down = close < open[1]
switch
condition1 and open_up => bar_value:=16
condition1 and open_down => bar_value:=15
condition2 and open_up => bar_value:=14
condition2 and open_down => bar_value:=13
condition3 and open_up => bar_value:=12
condition3 and open_down => bar_value:=11
condition4 and open_up => bar_value:=10
condition4 and open_down => bar_value:=9
condition5 and open_up => bar_value:=8
condition5 and open_down => bar_value:=7
condition6 and open_up => bar_value:=6
condition6 and open_down => bar_value:=5
condition7 and open_up => bar_value:=4
condition7 and open_down => bar_value:=3
condition8 and open_up => bar_value:=2
condition8 and open_down => bar_value:=1
//plot(bar_value,display = display.none,title="Bar Value")
barcolor(condition1 and not dual_color ? color.rgb(247, 223, 2) : na, title="C+L+H+")
//barcolor(condition2 and not dual_color ? color.rgb(247, 223, 2) : na, title="C+L+H-")
//barcolor(condition3 and not dual_color ? color.rgb(247, 223, 2) : na, title="C+L-H+")
//barcolor(condition4 and not dual_color ? color.rgb(252, 223, 2) : na, title="C+L-H-")
//--------------------------------------------------------------------------
//barcolor(condition5 and not dual_color ? color.rgb(213, 4, 250) : na, title="C-L+H+")
//barcolor(condition6 and not dual_color ? color.rgb(213, 4, 250) : na, title="C-L+H-")
//barcolor(condition7 and not dual_color ? color.rgb(213, 4, 250) : na, title="C-L-H+")
barcolor(condition8 and not dual_color ? color.rgb(213, 4, 250) : na, title="C-L-H-")
///////////////////////
//@version=5
type bar
float o = open
float h = high
float l = low
float c = close
int i = bar_index
type trend
float h = na
float l = na
type scythe
polyline a = na
line b = na
type target
float u = na
float l = na
float p = na
int d = 0
bool r = false
line v = na
line h = na
label e = na
type alerts
bool u = na
bool d = na
bool b = na
bool s = na
type prompt
string s = ''
bool c = false
method notify(prompt p) =>
if p.c
alert(p.s, alert.freq_once_per_bar_close)
method any(alerts a) =>
string s = switch
a.s => 'Target Reached '
a.b => 'Target Invalidated'
a.u => 'Breakout '
a.d => 'Breakdown'
=> na
prompt.new(s, not na(s))
method atr(bar b, simple int len = 1) =>
float tr =
na(b.h[1]) ?
b.h - b.l :
math.max(
math.max(
b.h - b.l,
math.abs(b.h - b.c[1])),
math.abs (b.l - b.c[1]))
len == 1 ? tr : ta.rma(tr, len)
method piv(trend t) =>
bool b = switch
na(t.h) and na(t.l) => false
=> true
b
method blade(array<chart.point> a, bool p, simple color u, simple color d) =>
polyline.new(a, false, true, xloc.bar_index, p ? d : u, p ? color.new(d, 100) : color.new(u, 100))
method handle(bar b, trend t, float s) =>
line l = switch
not na(t.l) =>
line.new(b.i, b.h + s, b.i, b.l , xloc.bar_index, extend.none, #fcfaf8, line.style_solid, 3)
not na(t.h) =>
line.new(b.i, b.h , b.i, b.l - s, xloc.bar_index, extend.none, #fcfaf8, line.style_solid, 3)
l
method goal(target t, bar b, simple int len) =>
t.v := line .new(b.i, b.c, b.i , t.p, xloc.bar_index, extend.none, chart.fg_color, line.style_dashed)
t.h := line .new(b.i, t.p, b.i + len, t.p, xloc.bar_index, extend.none, chart.fg_color, line.style_dashed)
t.e := label.new(b.i + len, t.p, "YÖRÜK", xloc.bar_index, yloc.price, #f0a71f78, label.style_label_left, chart.fg_color, size.normal)
method cu(target t, bar b) =>
t.l[1] < b.c[1] and t.l > b.c
method co(target t, bar b) =>
t.u[1] > b.c[1] and t.u < b.c
method cr(target t, bar b) =>
((t.d == 1 and b.c > t.p) or
(t.d == -1 and b.c < t.p))
method reached(target t, bar b) =>
t.h.set_xy2(b.i, t.h.get_y2())
t.e.set_xy (b.i, t.h.get_y2())
t.e.set_color(#4caf4f78)
t.e.set_text ('YES' )
method failed(target t, bar b) =>
t.h.set_xy2(b.i, t.h.get_y2())
t.e.set_xy (b.i, t.h.get_y2())
t.e.set_color(#a53a3a78)
t.e.set_text ('NO' )
const string ts = 'Controls how restrained the target calculation is, higher values will result in tighter targets.'
const string tb = 'Adjusts the length of the scythes blade'
const string tp = 'Swing detection length'
const string gs = 'Scythes', const string gt = 'Targets', const string gu = 'UI Options'
len = input.int (20 , "Pivot Length" , 1, 100, 1 , tp, group = gs)
ext = input.int (100 , "Scythe Length" , 1, 200, 1 , tb, group = gs)
sen = input.int (100 , "Sensitivity %", 0 , 100, 10, ts, group = gt)
bts = input.bool (true , "Display" , group = gt)
bbs = input.bool (true , "Breakouts" , group = gu)
colu = input.color(#eee7df, "" , inline = '1', group = gu)
cold = input.color(#c71313, "" , inline = '1', group = gu)
bar b = bar .new( )
float s = b .atr( len) / len
trend t = trend.new(
ta.pivothigh(len, len),
ta.pivotlow (len, len))
var target g = target.new ()
var map<int, float> u = map .new<int, float>()
var map<int, float> l = map .new<int, float>()
if t.piv()
array<chart.point> a = array.new<chart.point>()
bar z = b[len]
bool p = na(t.l)
for i = 0 to ext - 1
float c = s * i + s * math.pow(i, 2) / ext
a.push(chart.point.from_index(z.i + i, (p ? (z.h - c) : (z.l + c))))
a.push(chart.point.from_index(z.i, (p ? (z.h - s * ext / 5) : (z.l + s * ext / 5))))
switch
not na(t.l) =>
l.clear()
for point in a
l.put(point.index, point.price)
not na(t.h) =>
u.clear()
for point in a
u.put(point.index, point.price)
scythe n = scythe.new(a.blade(p, colu, cold), z.handle(t, s * len))
g.u := u.contains(b.i) ? u.get(b.i) : na
g.l := l.contains(b.i) ? l.get(b.i) : na
bool ucon = false
bool dcon = false
bool bcon = false
bool scon = false
if g.cr(b) and not g.r and bts
g.reached(b)
g.r := true
scon := true
if g.co(b) and bts
if not g.r
g.failed(b)
bcon := true
else
ucon := true
g.r := false
g.d := 1
g.p := b.c + s * ext * (2 - sen / 100)
g.goal(b, len)
if g.cu(b) and bts
if not g.r
g.failed(b)
bcon := true
else
dcon := true
g.r := false
g.d := -1
g.p := b.c - s * ext * (2 - sen / 100)
g.goal(b, len)
alerts a = alerts.new(
ucon,
dcon,
bcon,
scon)
plotshape(not na(t.l) ? (b[len]).l + s * len / 5 : na, "ÇIPA", shape.diamond, location.absolute, colu, -len, size = size.normal)
plotshape(not na(t.h) ? (b[len]).h - s * len / 5 : na, "TIRPAN", shape.diamond, location.absolute, cold, -len, size = size.normal)
//plotshape(bbs and a.d, "KIRILIM", shape.labeldown, location.abovebar, color.new(cold, 60), 0, 'AK', chart.fg_color, size = size.normal)
//plotshape(bbs and a.u, "KIRILIM", shape.labelup , location.belowbar, color.new(colu, 60), 0, 'YK', chart.fg_color, size = size.normal)
//alertcondition(a.b, 'Target Reached ', 'Target Reached ')
//alertcondition(a.s, 'Target Invalidated', 'Target Invalidated')
//alertcondition(a.u, 'Breakout ' , 'Breakout ' )
//alertcondition(a.d, 'Breakdown' , 'Breakdown' )
a.any().notify()
///////////////////////////////
//@version=5
import twingall/BasicVisibleChart/1
useBodies =input.bool(true, "use Candle Bodies to anchor range")
showFibBox = input.bool(true, "show Fib Box", group = "OTE box", inline = "2")
boxColor = input.color(color.new(color.yellow, 50), "", group = "OTE box", inline = "2")
showText = input.bool(true, "show Text",group = "Ote box", inline = "2")
showHighLowLines=input.bool(true, "high/low lines", group = "fib retracements",inline = "3")
lineColor = input.color(color.rgb(217, 76, 217), "", group = "fib retracements",inline = "3")
showMidline =input.bool(true, "Midline", group = "fib retracements",inline = "3")
midlineColor = input.color(color.white,"", group = "fib retracements",inline = "3")
show61eight=input.bool(false, "show 61.8 line", group = "fib retracements",inline = "5")
show78six=input.bool(false, "show 78.6 line", group = "fib retracements",inline = "6")
show88six=input.bool(false, "show 88.6 line", group = "fib retracements",inline = "7")
showfibExt1=input.bool(true,"Ext#1", group ="fib extensions",inline="9")
fibExt1Color=input.color(color.lime,"", group ="fib extensions",inline="9")
fibExt1=input.float(1.618, "", group ="fib extensions",inline="9")
showfibExt2=input.bool(true,"Ext#2", group ="fib extensions",inline="9")
fibExt2Color=input.color(color.red,"", group ="fib extensions",inline="9")
fibExt2=input.float(2.0, "", group ="fib extensions",inline="9")
showfibExt3=input.bool(false,"Ext#3", group ="fib extensions",inline="10")
fibExt3Color=input.color(color.red,"", group ="fib extensions",inline="10")
fibExt3=input.float(1.5, "", group ="fib extensions",inline="10")
showfibExt4=input.bool(false,"Ext#4", group ="fib extensions",inline="10")
fibExt4Color=input.color(color.red,"", group ="fib extensions",inline="10")
fibExt4=input.float(2.5, "", group ="fib extensions",inline="10")
showfibExt5=input.bool(false,"Ext#5", group ="fib extensions",inline="11")
fibExt5Color=input.color(color.red,"", group ="fib extensions",inline="11")
fibExt5=input.float(3.0, "", group ="fib extensions",inline="11")
showfibExt6=input.bool(false,"Ext#6", group ="fib extensions",inline="11")
fibExt6Color=input.color(color.red,"", group ="fib extensions",inline="11")
fibExt6=input.float(3.5, "", group ="fib extensions",inline="11")
_88sixColor = input.color(color.green, "", group = "fib retracements",inline = "7")
_61eightColor = input.color(color.green, "", group = "fib retracements",inline = "5")
_78sixColor = input.color(color.green, "", group = "fib retracements",inline = "6")
colorNone = color.new(color.white,100)
showExtLabels=input.bool(true,"Show Labels (Fib extensions)", group ="fib extensions",inline="11")
flipInvertExts=input.bool(false,"flip/invert extensions", group ="fib extensions",inline="12")
showFibLabels = input.bool(true, "Show Labels (Fib retracements)", group="fib retracements", inline="8")
// Calling Library functions to get: high/low, body high / body low, timings, bull/bear
float chartHigh = useBodies? BasicVisibleChart.highestBody():BasicVisibleChart.high()
float chartLow =useBodies?BasicVisibleChart.lowestBody():BasicVisibleChart.low()
int highTime = BasicVisibleChart.highBarTime()
int lowTime = BasicVisibleChart.lowBarTime()
int leftTime = math.min(highTime, lowTime)
int rightTime = math.max(highTime, lowTime)
bool isBull = lowTime < highTime
// Function to manage fib lines. It declares fib lines and label the first time it is called, then sets their properties on subsequent calls.
fibLine(series color fibColor, series float fibLevel, bool _showPriceLabels) =>
float fibRatio = 1-(fibLevel / 100)
float fibPrice = isBull ? chartLow + ((chartHigh - chartLow) * fibRatio) :
chartHigh - ((chartHigh - chartLow) * fibRatio)
float _fibLabel = fibLevel /100
var line fibLine = line.new(na, na, na, na, xloc.bar_time, extend.right, fibColor, line.style_dotted, 2)
line.set_xy1(fibLine, leftTime, fibPrice)
line.set_xy2(fibLine, rightTime, fibPrice)
var label fibLabel = label.new(na, na, "", xloc.bar_time, yloc.price, color(na), label.style_label_up, _showPriceLabels? fibColor:colorNone)
label.set_xy(fibLabel, int(math.avg(leftTime, rightTime)), fibPrice)
label.set_text(fibLabel, str.tostring(fibPrice, format.mintick))
//label.set_text(fibLabel, str.format("{0, number, #.###} ({1})", _fibLabel , str.tostring(fibPrice, format.mintick)))
//Function for Fib Extension lines..
fibExt(series color fibColor, series float fibLevel, bool _showExt) =>
float fibRatio = fibLevel / 100
float fibPrice = isBull ? chartLow - ((chartHigh - chartLow) * fibRatio) :
chartHigh + ((chartHigh - chartLow) * fibRatio)
float fibLabel = not flipInvertExts? -(fibLevel /100) :(fibLevel /100)+1 //getting both normal and inverted ext labels to display as positive numbers
var line fibLine = line.new(na, na, na, na, xloc.bar_time, extend.right, fibColor, line.style_dotted, 2)
line.set_xy1(fibLine, leftTime, fibPrice)
line.set_xy2(fibLine, rightTime, fibPrice)
var label fibExtLabel = label.new(na, na, "", xloc.bar_time, yloc.price, color(na), label.style_label_up, _showExt? fibColor:colorNone)
label.set_xy(fibExtLabel, int(math.avg(leftTime, rightTime)), fibPrice)
label.set_text(fibExtLabel, str.format("{0, number, #.###} ({1})", fibLabel , str.tostring(fibPrice, format.mintick)))
//Fib Box function; similar to the above but highlighting the area between 2 fib levels
fibBox(series color fibColor, series float fibLevel_1, series float fibLevel_2) =>
float fibRatio_1 = 1-(fibLevel_1 / 100)
float fibPrice_1 = isBull ? chartLow + ((chartHigh - chartLow) * fibRatio_1) : chartHigh - ((chartHigh - chartLow) * fibRatio_1)
float fibRatio_2 = 1-(fibLevel_2 / 100)
float fibPrice_2 = isBull ? chartLow + ((chartHigh - chartLow) * fibRatio_2) : chartHigh - ((chartHigh - chartLow) * fibRatio_2)
var b = box.new(na, na, na, na, xloc=xloc.bar_time, border_style=line.style_dashed, extend = extend.right, border_color=colorNone, text_color=color.new(color.white,00), text_halign=text.align_left)
box.set_lefttop(b, leftTime, fibPrice_1)
box.set_rightbottom(b, rightTime,fibPrice_2)
box.set_bgcolor(b, fibColor)
box.set_text(b, text = showText? " Scalping Trade by @yörük@ 2024 ":"")
// Display code that only runs on the last bar but displays visuals on visible bars, wherever they might be in the dataset.
if barstate.islast
//Declare fib lines and fib box
fibLine(lineColor, 100,showFibLabels )
fibLine(showMidline?midlineColor :colorNone, 50,showFibLabels )
fibLine(lineColor, 0,showFibLabels )
fibBox(showFibBox?boxColor:colorNone, 78.6, 61.8)
fibLine(show88six?_88sixColor:colorNone, 88.6,showFibLabels )
fibLine(show61eight?_61eightColor:colorNone, 61.8,showFibLabels )
fibLine(show78six?_78sixColor:colorNone, 78.6,showFibLabels )
//more fib lines
//fibLine(_88sixColor, 11.4)
//fibLine(_61eightColor, 38.2)
//fibLine(_78sixColor, 21.4)
//Declare Fib extensions
if barstate.islast and showfibExt1 and flipInvertExts
fibExt(fibExt1Color, (fibExt1*100)-100, showExtLabels)
if barstate.islast and showfibExt2 and flipInvertExts
fibExt(fibExt2Color, (fibExt2*100)-100, showExtLabels)
if barstate.islast and showfibExt3 and flipInvertExts
fibExt(fibExt3Color, (fibExt3*100)-100, showExtLabels)
if barstate.islast and showfibExt4 and flipInvertExts
fibExt(fibExt4Color, (fibExt4*100)-100, showExtLabels)
if barstate.islast and showfibExt5 and flipInvertExts
fibExt(fibExt5Color, (fibExt5*100)-100, showExtLabels)
if barstate.islast and showfibExt6 and flipInvertExts
fibExt(fibExt6Color, (fibExt6*100)-100, showExtLabels)
if barstate.islast and showfibExt1 and not flipInvertExts
fibExt(fibExt1Color, -(fibExt1*100), showExtLabels)
if barstate.islast and showfibExt2 and not flipInvertExts
fibExt(fibExt2Color, -(fibExt2*100), showExtLabels)
if barstate.islast and showfibExt3 and not flipInvertExts
fibExt(fibExt3Color, -(fibExt3*100), showExtLabels)
if barstate.islast and showfibExt4 and not flipInvertExts
fibExt(fibExt4Color, -(fibExt4*100), showExtLabels)
if barstate.islast and showfibExt5 and not flipInvertExts
fibExt(fibExt5Color, -(fibExt5*100), showExtLabels)
if barstate.islast and showfibExt6 and not flipInvertExts
fibExt(fibExt6Color, -(fibExt6*100), showExtLabels)
//////////////////////////////
Yer İmleri