0% found this document useful (0 votes)
24 views12 pages

KB Al - Sat Kombi̇ne İndi̇katör

The document is a Pine Script code for a trading indicator that incorporates various technical analysis tools such as Hull Moving Averages, RSI, ADX, Bollinger Bands, and Fibonacci levels. It allows users to customize inputs for different parameters and visualize market trends and signals for buying and selling. The script includes features for plotting, coloring, and alert conditions based on the calculated indicators.

Uploaded by

olean87
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views12 pages

KB Al - Sat Kombi̇ne İndi̇katör

The document is a Pine Script code for a trading indicator that incorporates various technical analysis tools such as Hull Moving Averages, RSI, ADX, Bollinger Bands, and Fibonacci levels. It allows users to customize inputs for different parameters and visualize market trends and signals for buying and selling. The script includes features for plotting, coloring, and alert conditions based on the calculated indicators.

Uploaded by

olean87
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 12

//@version=5

indicator(title='KB_AL/SAT_SADE HAL�', overlay = true)

///////TRENDDD HULLL///////

//INPUT
src5 = input(close, title='Source')
modeSwitch = input.string('Hma', title='Hull Variation', options=['Hma', 'Thma',
'Ehma'])
length8 = input(20, title='Length(180-200 for floating S/R , 20 for swing entry)')
lengthMult = input(1.0, title='Length multiplier (Used to view higher timeframes
with straight band)')

useHtf = input(false, title='Show Hull MA from X timeframe? (good for scalping)')


htf = input.timeframe('240', title='Higher timeframe')

switchColor = input(true, 'Color Hull according to trend?')


candleCol = input(false, title='Color candles based on Hull\'s Trend?')
visualSwitch = input(true, title='Show as a Band?')
thicknesSwitch = input(1, title='Line Thickness')
transpSwitch = input.int(20, title='Band Transparency', step=3)

//FUNCTIONS
//HMA
HMA(_src5, _length) =>
ta.wma(2 * ta.wma(_src5, _length / 2) - ta.wma(_src5, _length),
math.round(math.sqrt(_length)))
//EHMA
EHMA(_src5, _length) =>
ta.ema(2 * ta.ema(_src5, _length / 2) - ta.ema(_src5, _length),
math.round(math.sqrt(_length)))
//THMA
THMA(_src5, _length) =>
ta.wma(ta.wma(_src5, _length / 3) * 3 - ta.wma(_src5, _length / 2) -
ta.wma(_src5, _length), _length)

//SWITCH
Mode(modeSwitch, src5, len) =>
modeSwitch == 'Hma' ? HMA(src5, len) : modeSwitch == 'Ehma' ? EHMA(src5, len) :
modeSwitch == 'Thma' ? THMA(src5, len / 2) : na

//OUT
_hull = Mode(modeSwitch, src5, int(length8 * lengthMult))
HULL = useHtf ? request.security(syminfo.ticker, htf, _hull) : _hull
MHULL = HULL[0]
SHULL = HULL[2]

//COLOR
hullColor = switchColor ? HULL > HULL[2] ? #00ff00 : #ff0000 : #ff9800
//PLOT
///< Frame
Fi1 = plot(MHULL, title='MHULL', color=hullColor, linewidth=thicknesSwitch,
transp=80)
Fi2 = plot(visualSwitch ? SHULL : na, title='SHULL', color=hullColor,
linewidth=thicknesSwitch, transp=80)
alertcondition(ta.crossover(MHULL, SHULL), title='Hull trending up.', message='Hull
trending up.')
alertcondition(ta.crossover(SHULL, MHULL), title='Hull trending down.',
message='Hull trending down.')
///< Ending Filler
fill(Fi1, Fi2, title='Band Filler', color=hullColor, transp=60)
///BARCOLOR
barcolor(color=candleCol ? switchColor ? hullColor : na : na)

/////////RSI ////////

Src = input(defval=close, title='Source')


rsilen = input.int(defval=14, title='RSI Length', minval=1)
length = input.int(defval=20, title='HULL UZUNLUK', minval=1)

ad = close == high and close == low or high == low ? 0 : (2 * close - low - high) /
(high - low) * volume
mf = math.sum(ad, length) / math.sum(volume, length)

//-------- ADX ----


showadx = input(defval=false, title='Show ADX')
adxlen = input(14, title='ADX Smoothing')
dilen = input(14, title='DI Length')

dirmov(len) =>
up = ta.change(high)
down = -ta.change(low)
plusDM = na(up) ? na : up > down and up > 0 ? up : 0
minusDM = na(down) ? na : down > up and down > 0 ? down : 0
truerange = ta.rma(ta.tr, len)
plus = fixnan(100 * ta.rma(plusDM, len) / truerange)
minus = fixnan(100 * ta.rma(minusDM, len) / truerange)
[plus, minus]
adx(dilen, adxlen) =>
[plus, minus] = dirmov(dilen)
sum = plus + minus
adx = 100 * ta.rma(math.abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen)
adx

sig = adx(dilen, adxlen)

Rsi = ta.rsi(Src, rsilen)

//src = Rsi

attt = ta.atr(14)

showrsma = input(defval=false, title='Show RSI MA')


malen = input.int(defval=20, title='RSI SMA Length', minval=2)
rsma = ta.sma(Rsi, malen)

var testTable = table.new(position = position.bottom_right, columns = 1, rows = 3,


bgcolor = color.red, border_width = 1)
if barstate.islast
table.cell(table_id = testTable, column = 0, row = 0, text = "RSI/" +
str.tostring(math.round(Rsi,1)), text_color=color.white)

///////20/50/200 HAREKETL� ORTALAMALAR/////


short20 = ta.sma(close, 20)
short50 = ta.sma(close, 50)
short200 = ta.sma(close, 200)

//plot(short20, color=color.new(color.purple, 0), linewidth = 2, title='SMA20')


//plot(short50, color=color.new(color.blue, 0), linewidth = 2,title='SMA50')
plot(short200, color=color.new(color.black, 0), linewidth = 2,title='SMA200')

//plot(ta.crossover(short20, short50) ? short20 : na, style=plot.style_cross,


linewidth=4, color=color.new(#eff314, 0))
//plot(ta.crossover(short20, short200) ? short50 : na, style=plot.style_cross,
linewidth=4, color=color.new(#eff314, 0))
//plot(ta.crossover(short50, short200) ? short50 : na, style=plot.style_cross,
linewidth=4, color=color.new(#eff314, 0))

//plot(ta.crossunder(short20, short50) ? short20 : na, style=plot.style_cross,


linewidth=4, color=color.new(#f314c3, 0))
//plot(ta.crossunder(short20, short200) ? short20 : na, style=plot.style_cross,
linewidth=4, color=color.new(#f314c3, 0))
//plot(ta.crossunder(short50, short200) ? short20 : na, style=plot.style_cross,
linewidth=4, color=color.new(#f314c3, 0))

//////RSI SAT AL//////

lengthSR = 14 //
highestHigh = ta.highest(high, lengthSR)
lowestLow = ta.lowest(low, lengthSR)

// RSI
lengthRSI = 9
rsiValue = ta.rsi(close, lengthRSI)
rsiOverbought = 85
rsiOversold = 17

//

// RSI
longCondition = rsiValue < rsiOversold and close > lowestLow
shortCondition = rsiValue > rsiOverbought and close < highestHigh

//
plotshape(series=longCondition, title="RSI-AL", location=location.belowbar,
color=color.new(color.green, 80), style=shape.labelup, text="AL")
plotshape(series=shortCondition, title="RSI-SAT", location=location.abovebar,
color=color.new(color.orange, 80),
style=shape.labeldown,textcolor=color.new(color.blue, 0), text="SAT")

////BOLL�NGERRR//////

length3 = input.int(20, minval=1)


maType = input.string("SMA", "Basis MA Type", options = ["SMA", "EMA", "SMMA
(RMA)", "WMA", "VWMA"])
src7 = input(close, title="Source")
mult = input.float(2.0, minval=0.001, maxval=50, title="StdDev")

ma(source, length3, _type) =>


switch _type
"SMA" => ta.sma(source, length3)
"EMA" => ta.ema(source, length3)
"SMMA (RMA)" => ta.rma(source, length3)
"WMA" => ta.wma(source, length3)
"VWMA" => ta.vwma(source, length3)

basis = ma(src7, length3, maType)


dev = mult * ta.stdev(src7, length3)
upper = basis + dev
lower = basis - dev
offset = input.int(0, "Offset", minval = -500, maxval = 500, display =
display.data_window)

p1 = plot(upper, "Upper", color=#2962FF, linewidth = 2,offset = offset)


p2 = plot(lower, "Lower", color=#2962FF, linewidth = 2, offset = offset)

//////FIBONACC� SEV�YELER�//////

Fibs = input.string('Plot Fibs based on Lookback', options=['Plot Fibs based on


Lookback', 'Plot Fibs based on Price Input'], title='Fibonacci Plot Type')

FIBS = Fibs == 'Plot Fibs based on Lookback' ? 1 : Fibs == 'Plot Fibs based on
Price Input' ? 2 : na

Foption = input.string(defval='1. Candles', title='Fibonacci Plot Lookback Type',


options=['2. Days', '1. Candles'])
FP = input(defval=100, title='Days/Candles to Lookback')
Reverse = input(defval=false, title='Reverse Fibonacci Levels?')
ExtraFibs = input(false, 'Show 0.886 and 1.113 Fibs')
ExtraFibs2 = input(false, 'Show 1.618 Fibs')
ExtraFibs3 = input(false, 'Show 2.618 Fibs')

Note = input(true, '==== ???????? ?????????? ???? ?????????? ?????????? ====')


High = input.float(0., minval=0, title='High - Enter Value')
Low = input.float(-1., minval=-1, title='Low - Enter Value')

Note2 = input(true, '====== ?????? ????????/?????????? ?????????? ======')


Bull_Color = input(#008000, title='Support Fibs Color')
Bear_Color = input(#ff0000, title='Resistance Fibs Color')
CurrentFib = input(false, 'Show Fib Level of Current Price')
Current_Color = input(color.orange, title='Current Fib Label Color')
LineStyle = input.string('Dotted', options=['Dotted', 'Solid'], title='Fib Line
Style')
LineWidth = input.int(1, minval=1, maxval=3, title='Fib Line Width')
Ext = input(false, 'Extend Lines Left')

// Transparency = input("Low", options = ["High", "Medium", "Low"], title="Fib Line


Transparency")

BullColor = Bull_Color //Transparency == "High"?color.new(#008000,75):Transparency


== "Medium"?color.new(#008000,50):Bull_Color
BearColor = Bear_Color //Transparency == "High"?color.new(#ff0000,75):Transparency
== "Medium"?color.new(#ff0000,50):Bear_Color

FPeriod = timeframe.isintraday and Foption == '2. Days' ? 1440 /


timeframe.multiplier * FP : timeframe.isdaily and Foption == '2. Days' ? FP /
timeframe.multiplier : timeframe.isweekly and Foption == '2. Days' ? FP / (7 *
timeframe.multiplier) : timeframe.ismonthly and Foption == '2. Days' ? FP / (28 *
timeframe.multiplier) : Foption == '1. Candles' ? FP : 100
Fhigh = FIBS == 1 ? ta.highest(FPeriod) : FIBS == 2 and High == 0 ?
ta.highest(high, 100) : FIBS == 2 and High != 0 ? High : na
Flow = FIBS == 1 ? ta.lowest(FPeriod) : FIBS == 2 and Low == -1 ? ta.lowest(low,
100) : FIBS == 2 and High != -1 ? Low : na
FH = FIBS == 1 ? ta.highestbars(high, FPeriod) : 1
FL = FIBS == 1 ? ta.lowestbars(low, FPeriod) : 2
revfibs = not Reverse ? FL > FH : FL < FH

Fib_x(n) =>
revfibs ? (Fhigh - Flow) * n + Flow : Fhigh - (Fhigh - Flow) * n

Current = revfibs ? (close - Flow) / (Fhigh - Flow) : (Fhigh - close) / (Fhigh -


Flow)

var label Current_Fib_Label = na


label.delete(Current_Fib_Label)

if CurrentFib and barstate.islast


Current_Fib_Label := label.new(bar_index, close, str.tostring(Current,
'##.##'), textcolor=Current_Color, color=color.new(#000000, 100),
style=label.style_label_left, yloc=yloc.price)
Current_Fib_Label

EXTEND = Ext ? extend.left : extend.none


STYLE = LineStyle == 'Dotted' ? line.style_dotted : line.style_solid
WIDTH = LineWidth

BB = FIBS == 1 ? FL < FH ? bar_index[-FL] : bar_index[-FH] : FIBS == 2 ?


bar_index[50] : bar_index[50]

Fib_line(x) =>
var line ln = na
line.delete(ln)
ln := line.new(BB, x, bar_index, x, color=close > x ? BullColor : BearColor,
extend=EXTEND, style=STYLE, width=WIDTH)
ln

Fib_label(x, _txt) =>


var label lbl = na
label.delete(lbl)
lbl := label.new(bar_index, x, _txt + str.tostring(x, '##.##') + ' )',
textcolor=close > x ? BullColor : BearColor, color=color.new(#000000, 100),
style=label.style_label_left, yloc=yloc.price)
lbl

Fib0 = Fib_line(Fib_x(0))
Fib236 = Fib_line(Fib_x(0.236))
Fib382 = Fib_line(Fib_x(0.382))
Fib500 = Fib_line(Fib_x(0.500))
Fib618 = Fib_line(Fib_x(0.618))
Fib786 = Fib_line(Fib_x(0.786))
Fib1000 = Fib_line(Fib_x(1.000))
Fib1618 = Fib_line(Fib_x(1.618))
Fib2618 = Fib_line(Fib_x(2.618))
LFib1618 = Fib_label(Fib_x(1.618), '1.618 ( ')
LFib2618 = Fib_label(Fib_x(2.618), '2.618 ( ')

Fib886 = ExtraFibs ? Fib_line(Fib_x(0.886)) : na


if FIBS == 2

Fib1113 = ExtraFibs ? Fib_line(Fib_x(1.113)) : na

Fib1272 = Fib_line(Fib_x(1.272))
Fib1618 = Fib_line(Fib_x(1.618))
Fib2000 = Fib_line(Fib_x(2.000))
Fib2236 = Fib_line(Fib_x(2.236))
Fib2618 = Fib_line(Fib_x(2.618))
Fib3236 = Fib_line(Fib_x(3.236))
Fib3618 = Fib_line(Fib_x(3.618))
Fib4236 = Fib_line(Fib_x(4.236))
Fib4618 = Fib_line(Fib_x(4.618))
Fib4618

LFib0 = Fib_label(Fib_x(0), '0 ( ')


LFib236 = Fib_label(Fib_x(0.236), '0.236 ( ')
LFib382 = Fib_label(Fib_x(0.382), '0.382 ( ')
LFib500 = Fib_label(Fib_x(0.500), '0.500 ( ')
LFib618 = Fib_label(Fib_x(0.618), '0.618 ( ')
LFib786 = Fib_label(Fib_x(0.786), '0.786 ( ')
LFib1000 = Fib_label(Fib_x(1.000), '1.000 ( ')

LFib886 = ExtraFibs ? Fib_label(Fib_x(0.886), '0.886 ( ') : na

if FIBS == 2

LFib1113 = ExtraFibs ? Fib_label(Fib_x(1.113), '1.113 ( ') : na

LFib1272 = Fib_label(Fib_x(1.272), '1.272 ( ')


LFib1618 = Fib_label(Fib_x(1.618), '1.618 ( ')
LFib2000 = Fib_label(Fib_x(2.000), '2.000 ( ')
LFib2236 = Fib_label(Fib_x(2.236), '2.236 ( ')
LFib2618 = Fib_label(Fib_x(2.618), '2.618 ( ')
LFib3236 = Fib_label(Fib_x(3.236), '3.236 ( ')
LFib3618 = Fib_label(Fib_x(3.618), '3.618 ( ')
LFib4236 = Fib_label(Fib_x(4.236), '4.236 ( ')
LFib4618 = Fib_label(Fib_x(4.618), '4.618 ( ')
LFib4618

///////CCI CROSS TREND�////

length23=input.int(defval=38, title= 'CCI Length')


cci=ta.cci(close,length23)
current = ta.cci(close[0], length23)
previous = ta.cci(close[1], length23)
bgcolor(current < 100 and previous>100 ? color.orange : na,transp=80)
bgcolor(current > -100 and previous<-100 ? color.blue : na,transp=80)

var testTable2 = table.new(position = position.bottom_center, columns = 1, rows =


3, bgcolor = color.red, border_width = 1)
if barstate.islast
table.cell(table_id = testTable2, column = 0, row = 0, text = "CCI/" +
str.tostring(math.round(cci,0)), text_color=color.white)

plotshape(current < 100 and previous>100, size=size.tiny, style=shape.labeldown,


title='CCI-SAT', text='SAT', location=location.top, color=color.new(color.orange,
60), textcolor=color.new(color.white, 0))
plotshape(current > -100 and previous<-100, size=size.tiny, style=shape.labelup,
title='CCI-AL', text='AL', location=location.bottom, color=color.new(color.blue,
80), textcolor=color.new(color.white, 0))

alertcondition((current < 100 and previous>100 ), title='SAT CCI', message='SAT


CCI')
alertcondition((current > -100 and previous<-100), title='AL CCI', message='AL
CCI')
//plot(100, style=area, transp=95, color=blue)
//plot(-100, style=area, transp=95, color=blue)
//plot(cci(close, length))

////////DESTEK-D�REN�////////

prd = input.int(defval=10, title='Pivot Period', minval=4, maxval=30,


group='Settings ??', tooltip='Used while calculating Pivot Points, checks
left&right bars')
ppsrc = input.string(defval='High/Low', title='Source', options=['High/Low',
'Close/Open'], group='Settings ??', tooltip='Source for Pivot Points')
ChannelW = input.int(defval=5, title='Maximum Channel Width %', minval=1, maxval=8,
group='Settings ??', tooltip='Calculated using Highest/Lowest levels in 300 bars')
minstrength = input.int(defval=1, title='Minimum Strength', minval=1,
group='Settings ??', tooltip='Channel must contain at least 2 Pivot Points')
maxnumsr = input.int(defval=6, title='Maximum Number of S/R', minval=1, maxval=10,
group='Settings ??', tooltip='Maximum number of Support/Resistance Channels to
Show') - 1
loopback = input.int(defval=290, title='Loopback Period', minval=100, maxval=400,
group='Settings ??', tooltip='While calculating S/R levels it checks Pivots in
Loopback Period')
res_col = input.color(defval=color.new(color.red, 90), title='Resistance Color',
group='Colors ??????')
sup_col = input.color(defval=color.new(color.lime, 90), title='Support Color',
group='Colors ??????')
inch_col = input.color(defval=color.new(color.gray, 90), title='Color When Price in
Channel', group='Colors ??????')
showpp = input.bool(defval=false, title='Show Pivot Points', group='Extras ??')
showsrbroken = input.bool(defval=false, title='Show Broken Support/Resistance',
group='Extras ??')
showthema1en = input.bool(defval=false, title='MA 1', inline='ma1')
showthema1len = input.int(defval=50, title='', inline='ma1')
showthema1type = input.string(defval='SMA', title='', options=['SMA', 'EMA'],
inline='ma1')
showthema2en = input.bool(defval=false, title='MA 2', inline='ma2')
showthema2len = input.int(defval=200, title='', inline='ma2')
showthema2type = input.string(defval='SMA', title='', options=['SMA', 'EMA'],
inline='ma2')
showthema3en = input.bool(defval=false, title='MA 3', inline='ma3')
showthema3len = input.int(defval=20, title='', inline='ma3')
showthema3type = input.string(defval='SMA', title='', options=['SMA', 'EMA'],
inline='ma3')

ma1 = showthema1en ? showthema1type == 'SMA' ? ta.sma(close, showthema1len) :


ta.ema(close, showthema1len) : na
ma2 = showthema2en ? showthema2type == 'SMA' ? ta.sma(close, showthema2len) :
ta.ema(close, showthema2len) : na
ma3 = showthema3en ? showthema3type == 'SMA' ? ta.sma(close, showthema3len) :
ta.ema(close, showthema3len) : na
plot(ma1, color=not na(ma1) ? color.gray : na,linewidth = 2)
plot(ma2, color=not na(ma2) ? color.yellow : na,linewidth = 2)
plot(ma3, color=not na(ma3) ? color.blue : na,linewidth = 2)
// get Pivot High/low
float src1 = ppsrc == 'High/Low' ? high : math.max(close, open)
float src2 = ppsrc == 'High/Low' ? low : math.min(close, open)
float ph = ta.pivothigh(src1, prd, prd)
float pl = ta.pivotlow(src2, prd, prd)

// draw Pivot points


plotshape(ph and showpp, text='H', style=shape.labeldown, color=na,
textcolor=color.new(color.red, 0), location=location.abovebar, offset=-prd)
plotshape(pl and showpp, text='L', style=shape.labelup, color=na,
textcolor=color.new(color.lime, 0), location=location.belowbar, offset=-prd)

//calculate maximum S/R channel width


prdhighest = ta.highest(300)
prdlowest = ta.lowest(300)
cwidth = (prdhighest - prdlowest) * ChannelW / 100

// get/keep Pivot levels


var pivotvals = array.new_float(0)
var pivotlocs = array.new_float(0)
if ph or pl
array.unshift(pivotvals, ph ? ph : pl)
array.unshift(pivotlocs, bar_index)
for x = array.size(pivotvals) - 1 to 0 by 1
if bar_index - array.get(pivotlocs, x) > loopback // remove old pivot
points
array.pop(pivotvals)
array.pop(pivotlocs)
continue
break

//find/create SR channel of a pivot point


get_sr_vals(ind) =>
float lo = array.get(pivotvals, ind)
float hi = lo
int numpp = 0
for y = 0 to array.size(pivotvals) - 1 by 1
float cpp = array.get(pivotvals, y)
float wdth = cpp <= hi ? hi - cpp : cpp - lo
if wdth <= cwidth // fits the max channel width?
if cpp <= hi
lo := math.min(lo, cpp)
lo
else
hi := math.max(hi, cpp)
hi

numpp += 20 // each pivot point added as 20


numpp
[hi, lo, numpp]

// keep old SR channels and calculate/sort new channels if we met new pivot point
var suportresistance = array.new_float(20, 0) // min/max levels
changeit(x, y) =>
tmp = array.get(suportresistance, y * 2)
array.set(suportresistance, y * 2, array.get(suportresistance, x * 2))
array.set(suportresistance, x * 2, tmp)
tmp := array.get(suportresistance, y * 2 + 1)
array.set(suportresistance, y * 2 + 1, array.get(suportresistance, x * 2 + 1))
array.set(suportresistance, x * 2 + 1, tmp)

if ph or pl
supres = array.new_float(0) // number of pivot, strength, min/max levels
stren = array.new_float(10, 0)
// get levels and strengs
for x = 0 to array.size(pivotvals) - 1 by 1
[hi, lo, strength] = get_sr_vals(x)
array.push(supres, strength)
array.push(supres, hi)
array.push(supres, lo)

// add each HL to strengh


for x = 0 to array.size(pivotvals) - 1 by 1
h = array.get(supres, x * 3 + 1)
l = array.get(supres, x * 3 + 2)
s = 0
for y = 0 to loopback by 1
if high[y] <= h and high[y] >= l or low[y] <= h and low[y] >= l
s += 1
s
array.set(supres, x * 3, array.get(supres, x * 3) + s)

//reset SR levels
array.fill(suportresistance, 0)
// get strongest SRs
src = 0
for x = 0 to array.size(pivotvals) - 1 by 1
stv = -1. // value
stl = -1 // location
for y = 0 to array.size(pivotvals) - 1 by 1
if array.get(supres, y * 3) > stv and array.get(supres, y * 3) >=
minstrength * 20
stv := array.get(supres, y * 3)
stl := y
stl
if stl >= 0
//get sr level
hh = array.get(supres, stl * 3 + 1)
ll = array.get(supres, stl * 3 + 2)
array.set(suportresistance, src * 2, hh)
array.set(suportresistance, src * 2 + 1, ll)
array.set(stren, src, array.get(supres, stl * 3))

// make included pivot points' strength zero


for y = 0 to array.size(pivotvals) - 1 by 1
if array.get(supres, y * 3 + 1) <= hh and array.get(supres, y * 3 +
1) >= ll or array.get(supres, y * 3 + 2) <= hh and array.get(supres, y * 3 + 2) >=
ll
array.set(supres, y * 3, -1)

src += 1
if src >= 10
break
for x = 0 to 8 by 1
for y = x + 1 to 9 by 1
if array.get(stren, y) > array.get(stren, x)
tmp = array.get(stren, y)
array.set(stren, y, array.get(stren, x))
changeit(x, y)

get_level(ind) =>
float ret = na
if ind < array.size(suportresistance)
if array.get(suportresistance, ind) != 0
ret := array.get(suportresistance, ind)
ret
ret

get_color(ind) =>
color ret = na
if ind < array.size(suportresistance)
if array.get(suportresistance, ind) != 0
ret := array.get(suportresistance, ind) > close and
array.get(suportresistance, ind + 1) > close ? res_col :
array.get(suportresistance, ind) < close and array.get(suportresistance, ind + 1) <
close ? sup_col : inch_col
ret
ret

var srchannels = array.new_box(10)


for x = 0 to math.min(9, maxnumsr) by 1
box.delete(array.get(srchannels, x))
srcol = get_color(x * 2)
if not na(srcol)
array.set(srchannels, x, box.new(left=bar_index, top=get_level(x * 2),
right=bar_index + 1, bottom=get_level(x * 2 + 1), border_color=srcol,
border_width=1, extend=extend.both, bgcolor=srcol))

resistancebroken = false
supportbroken = false

// check if it's not in a channel


not_in_a_channel = true
for x = 0 to math.min(9, maxnumsr) by 1
if close <= array.get(suportresistance, x * 2) and close >=
array.get(suportresistance, x * 2 + 1)
not_in_a_channel := false
not_in_a_channel

// if price is not in a channel then check broken ones


if not_in_a_channel
for x = 0 to math.min(9, maxnumsr) by 1
if close[1] <= array.get(suportresistance, x * 2) and close >
array.get(suportresistance, x * 2)
resistancebroken := true
resistancebroken
if close[1] >= array.get(suportresistance, x * 2 + 1) and close <
array.get(suportresistance, x * 2 + 1)
supportbroken := true
supportbroken
/////////DMI TREND//////

lensig = input.int(14, title='ADX Smoothing', minval=1, maxval=50)


len22 = input.int(30, minval=1, title='DI Length')
up = ta.change(high)
down = -ta.change(low)
plusDM = na(up) ? na : up > down and up > 0 ? up : 0
minusDM = na(down) ? na : down > up and down > 0 ? down : 0
trur = ta.rma(ta.tr, len22)
plus = fixnan(100 * ta.rma(plusDM, len22) / trur)
minus = fixnan(100 * ta.rma(minusDM, len22) / trur)
sum = plus + minus
adx = 100 * ta.rma(math.abs(plus - minus) / (sum == 0 ? 1 : sum), lensig)

yuksek = na(ta.pivothigh(adx, 5, 1)) ? false : true


plotshape(yuksek == true and adx > 20 and minus > plus, size=size.tiny,
style=shape.labelup, title='DMI-AL', text='AL', location=location.belowbar,
color=color.new(color.blue, 15), textcolor=color.new(color.white, 0))
plotshape(yuksek == true and adx > 20 and plus > minus, size=size.tiny,
style=shape.labeldown, title='DMI-SAT', text='SAT', location=location.abovebar,
color=color.new(color.black, 55), textcolor=color.new(color.white, 0))

alertcondition(ta.crossover(plus, minus) or ta.crossover(minus, plus), title='Buy-


Sell Ye�il Ok-K�rm�z� Ok', message='Buy - Sell')
alertcondition(yuksek == true and adx > 20 and minus > plus, title='AL DMI',
message='Low - D��k')
alertcondition(yuksek == true and adx > 20 and plus > minus, title='SAT DMI',
message='High - Y�ksek')
alertcondition(ta.crossover(adx, 25) and minus > plus, title='Down Trend - D�en
Trend', message='Down Trend - D�en Trend')
alertcondition(ta.crossunder(adx, 25) and minus < plus, title='Up Trend - Y�kselen
Trend', message='Up Trend - Y�kselen Trend')
alertcondition(ta.crossover(minus, plus), title='Sell - K�rm�z� Ok', message='Sell
- K�rm�z� Ok')
alertcondition(ta.crossover(plus, minus), title='Buy - Ye�il Ok', message='Buy -
Ye�il Ok')

alertcondition(ta.crossover(MHULL, SHULL) and (current > -100 and previous<-100 ) ,


title='SAT- HULL/CCI', message='2li - D�en Trend')
alertcondition(ta.crossover(SHULL, MHULL) and (current < 100 and previous>100 ),
title='AL- HULL/CCI', message='2li Y�kselen Trend')

alertcondition(ta.crossover(MHULL, SHULL) or (current > -100 and previous<-100 ) ,


title='SAT- HULL/CCI--HERHANG� B�R�', message='2li - D�en Trend')
alertcondition(ta.crossover(SHULL, MHULL) or (current < 100 and previous>100 ) ,
title='AL- HULL/CCI-- HERHANG� B�R�', message='2li Y�kselen Trend')

//plot(100, style=area, transp=95, color=blue)


//plot(-100, style=area, transp=95, color=blue)
//plot(cci(close, length))

//////MACD KES���M///

fast_length = input(title = "MACD HIZLI UZUNLUK", defval = 12)


slow_length = input(title = "MACD YAVA� UZUNLUK", defval = 20)
src = input(title = "Source", defval = close)
signal_length = input.int(title = "Signal Smoothing", minval = 1, maxval = 50,
defval = 9, display = display.data_window)
sma_source = input.string(title = "Oscillator MA Type", defval = "EMA", options =
["SMA", "EMA"], display = display.data_window)
sma_signal = input.string(title = "Signal Line MA Type", defval = "EMA", options =
["SMA", "EMA"], display = display.data_window)
// Calculating
fast_ma = sma_source == "SMA" ? ta.sma(src, fast_length) : ta.ema(src, fast_length)
slow_ma = sma_source == "SMA" ? ta.sma(src, slow_length) : ta.ema(src, slow_length)
macd = fast_ma - slow_ma
macd2=slow_ma-fast_ma
signal = sma_signal == "SMA" ? ta.sma(macd, signal_length) : ta.ema(macd,
signal_length)
//hist = macd - signal

//alertcondition(hist[1] >= 0 and hist < 0, title = 'Rising to falling', message =


'The MACD histogram switched from a rising to falling state')
//alertcondition(hist[1] <= 0 and hist > 0, title = 'Falling to rising', message =
'The MACD histogram switched from a falling to rising state')

//hline(0, "Zero Line", color = color.new(#787B86, 50))


//plot(hist, title = "Histogram", style = plot.style_columns, color = (hist >= 0 ?
(hist[1] < hist ? #26A69A : #B2DFDB) : (hist[1] < hist ? #FFCDD2 : #FF5252)))
//plot(macd, title = "MACD", color = #2962FF)
//plot(signal, title = "Signal", color = #FF6D00)

//plot(ta.crossover(macd, signal) ? macd : na, style=plot.style_circles,


linewidth=4, color=color.new(#d40404, 0))

//plot(ta.crossunder(macd, signal) ? macd : na, style=plot.style_circles,


linewidth=4, color=color.new(#00f7ff, 0))

plotshape(ta.crossover(macd,signal), title="AL MACD", text="AL MACD",


location=location.belowbar, style=shape.circle, size=size.tiny, color=color.green,
textcolor=color.black)
plotshape(ta.crossunder(macd, signal), title="SAT MACD", text="SAT MACD",
location=location.abovebar, style=shape.diamond, size=size.tiny, color=color.red,
textcolor=color.black)

alertcondition(ta.crossover(macd,signal), title = 'MACD AL', message = 'MACD AL


NOKTASINDA')
alertcondition(ta.crossunder(macd,signal), title = 'MACD SAT', message = 'MACD SAT
NOKTASINDA')

You might also like