OPEN-SOURCE SCRIPT

Mehmet Sert & investor_coin Combined

91
//version=5
indicator(title='Mehmet Sert & investor_coin Combined', shorttitle='Combined Indicator', overlay=true)

// Mehmet Sert's Original Code
src = input.source(close, title='Source', group='MA', inline='source')

matype = input.string('EMA', title='Type', group='MA', inline='Period1', options=['SMA', 'EMA', 'WMA'])
mafast = input.int(5, title='Fast', group='MA', inline='Period1')
maslow = input.int(10, title='Slow', group='MA', inline='Period1')

matypesafety = input.string('EMA', title='Safety', group='MA', inline='Period2', options=['SMA', 'EMA', 'WMA'])
masafety = input.int(55, title='Prd', group='MA', inline='Period2')

shw_crs = input.bool(true, title='Flags', group='MA', inline='flag')

matype_htf = input.string('SMA', title='HTF', group='MA', inline='Period3', options=['SMA', 'EMA', 'WMA'])
ma_htf = input.int(9, title='Prd', group='MA', inline='Period3')

avgma_fast = matype == 'SMA' ? ta.sma(src, mafast) : matype == 'EMA' ? ta.ema(src, mafast) : matype == 'WMA' ? ta.wma(src, mafast) : na
avgma_slow = matype == 'SMA' ? ta.sma(src, maslow) : matype == 'EMA' ? ta.ema(src, maslow) : matype == 'WMA' ? ta.wma(src, maslow) : na
avgma_safety = matypesafety == 'SMA' ? ta.sma(src, masafety) : matypesafety == 'EMA' ? ta.ema(src, masafety) : matype == 'WMA' ? ta.wma(src, masafety) : na

crs_buy = ta.crossover(avgma_fast, avgma_safety)
crs_sell = ta.crossunder(avgma_fast, avgma_safety)

res_htf = input.string('W', title="Fixed TF", options=['1', '3', '5', '15', '30', '45', '60', '120', '180', '240', 'D', 'W', '6M'], group='MA', inline="Period3 MTF")
mode_htf = input.string('Auto', title="Mode Level", options=['Auto', 'Current', 'User Defined'], group='MA', inline="Period3 MTF")

HTF = timeframe.period == '1' ? 'W' :
timeframe.period == '3' ? 'W' :
timeframe.period == '5' ? 'W' :
timeframe.period == '15' ? 'W' :
timeframe.period == '30' ? 'W' :
timeframe.period == '45' ? 'W' :
timeframe.period == '60' ? 'W' :
timeframe.period == '120' ? 'W' :
timeframe.period == '180' ? 'W' :
timeframe.period == '240' ? 'W' :
timeframe.period == 'D' ? 'W' :
timeframe.period == 'W' ? 'W' :
'6M'

vTF_htf = mode_htf == 'Auto' ? HTF : mode_htf == 'Current' ? timeframe.period : mode_htf == 'User Defined' ? res_htf : na

src_htf = request.security(syminfo.tickerid, vTF_htf, src, barmerge.gaps_off, barmerge.lookahead_on)

sma_htf = request.security(syminfo.tickerid, vTF_htf, ta.sma(src_htf, ma_htf), barmerge.gaps_off, barmerge.lookahead_off)
ema_htf = request.security(syminfo.tickerid, vTF_htf, ta.ema(src_htf, ma_htf), barmerge.gaps_off, barmerge.lookahead_off)
wma_htf = request.security(syminfo.tickerid, vTF_htf, ta.wma(src_htf, ma_htf), barmerge.gaps_off, barmerge.lookahead_off)

avgma_htf = matype_htf == 'SMA' ? sma_htf : matype_htf == 'EMA' ? ema_htf : matype_htf == 'WMA' ? wma_htf : na

plot(avgma_fast, title='Fast MA', style=plot.style_line, color=avgma_fast[0] > avgma_slow[1] ? color.lime : color.red, linewidth=1)
plot(avgma_slow, title='Slow MA', style=plot.style_line, color=avgma_slow[0] > avgma_safety[1] ? color.lime : color.red, linewidth=2)
plot(avgma_safety, title='Safety MA', style=plot.style_line, color=avgma_safety[0] < avgma_slow[1] ? color.blue : color.orange, linewidth=3)
plot(avgma_htf, title='HTF MA', style=plot.style_line, color=color.new(color.yellow, 0), linewidth=4)

var bool safety_zone = na
safety_zone := avgma_fast >= avgma_slow and avgma_slow >= avgma_safety

var bool blue_zone = na
blue_zone := avgma_fast >= avgma_slow

var bool unsafety_zone = na
unsafety_zone := avgma_fast <= avgma_slow and avgma_slow <= avgma_safety

var bool yellow_zone = na
yellow_zone := avgma_fast <= avgma_slow

bgcolor(safety_zone ? color.new(color.green, 85) : blue_zone ? color.new(color.blue, 85) : unsafety_zone ? color.new(color.red, 85) : yellow_zone ? color.new(color.yellow, 85) : color.new(color.orange, 75), title='(Un)Safety Zone')

blue_buy = ta.crossover(avgma_fast, avgma_slow)
green_buy = avgma_fast >= avgma_slow and ta.crossover(avgma_slow, avgma_safety)
blue_buy2 = ta.crossover(avgma_fast, avgma_slow) and avgma_slow >= avgma_safety
yellow_sell = ta.crossunder(avgma_fast, avgma_slow)
red_sell = avgma_fast <= avgma_slow and ta.crossunder(avgma_slow, avgma_safety)

plotshape(shw_crs ? crs_buy : na, title='Buy Flag', style=shape.triangleup, location=location.belowbar, color=color.new(color.lime, 0), text='YEŞİL ALAN', textcolor=color.new(color.lime, 0), size=size.tiny)
plotshape(shw_crs ? crs_sell : na, title='Sell kırmızı', style=shape.triangledown, location=location.abovebar, color=color.new(color.red, 0), text='KIRMIZI ALAN', textcolor=color.new(color.red, 0), size=size.tiny)
plotshape(shw_crs ? blue_buy : na, title='Buy mavi', style=shape.triangleup, location=location.belowbar, color=color.new(color.blue, 0), text='MAVİ ALAN', textcolor=color.new(color.blue, 0), size=size.tiny)
plotshape(shw_crs ? blue_buy2 : na, title='Buy yeşil', style=shape.triangleup, location=location.belowbar, color=color.new(color.green, 0), text='YEŞİL ALAN ', textcolor=color.new(color.blue, 0), size=size.tiny)
plotshape(shw_crs ? yellow_sell : na, title='Sell sarı', style=shape.triangledown, location=location.abovebar, color=color.new(color.red, 0), text='SARI ALAN', textcolor=color.new(color.red, 0), size=size.tiny)

alertcondition(blue_buy, title="Buy Blue", message="Buy %20")
alertcondition(green_buy, title="Buy Green", message="Buy %80")
alertcondition(blue_buy2, title="Buy Again", message="Buy %80 Again")
alertcondition(yellow_sell, title="Sell yellow", message="Sell %80")
alertcondition(red_sell, title="Close Position", message="Close Position")

// investor_coin's Code
MA_SMA = input(false, "========= MAs SMA ==========")
src_sma = input(title="Source SMA", defval=close)

length_sma1 = input(9, "MA 9")
plot(MA_SMA ? ta.sma(src_sma, length_sma1) : na, color=color.green, linewidth=1, transp=0, title="SMA9")

length_sma2 = input(20, "MA 20")
plot(MA_SMA ? ta.sma(src_sma, length_sma2) : na, color=color.orange, linewidth=2, transp=0, title="MA 20")

length_sma3 = input(50, "MA 50")
plot(MA_SMA ? ta.sma(src_sma, length_sma3) : na, color=color.purple, linewidth=3, transp=0, title="MA 50")

length_sma4 = input(100, "MA 100")
plot(MA_SMA ? ta.sma(src_sma, length_sma4) : na, color=color.red, linewidth=3, transp=0, title="MA 100")

length_sma5 = input(200, "MA 200")
plot(MA_SMA ? ta.sma(src_sma, length_sma5) : na, color=color.maroon, linewidth=4, transp=0, title="MA 200")

MA_EMA = input(false, "========= MAs EMA ==========")
src_ema = input(title="Source EMA", defval=close)

length_ema1 = input(5, "EMA 5")
plot(MA_EMA ? ta.ema(src_ema, length_ema1) : na, color=color.green, linewidth=1, title="EMA 5")

length_ema2 = input(10, "EMA 10")
plot(MA_EMA ? ta.ema(src_ema, length_ema2) : na, color=color.orange, linewidth=2, title="EMA 10")

length_ema3 = input(55, "EMA 55")
plot(MA_EMA ? ta.ema(src_ema, length_ema3) : na, color=color.purple, linewidth=3, title="EMA 55")

length_ema4 = input(100, "EMA 100")
plot(MA_EMA ? ta.ema(src_ema, length_ema4) : na, color=color.red, linewidth=4, title="EMA 100")

length_ema5 = input(200, "EMA 200")
plot(MA_EMA ? ta.ema(src_ema, length_ema5) : na, color=color.maroon, linewidth=5, title="EMA 200")

MA_WMA = input(false, "========= MAs WMA ==========")
src_wma = input(title="Source WMA", defval=close)

length_wma1 = input(5, "WMA 5")
plot(MA_WMA ? ta.wma(src_wma, length_wma1) : na, color=color.green, linewidth=1, title="WMA 5")

length_wma2 = input(22, "WMA 22")
plot(MA_WMA ? ta.wma(src_wma, length_wma2) : na, color=color.orange, linewidth=2, title="WMA 22")

length_wma3 = input(50, "WMA 50")
plot(MA_WMA ? ta.wma(src_wma, length_wma3) : na, color=color.purple, linewidth=3, title="WMA 50")

length_wma4 = input(100, "WMA 100")
plot(MA_WMA ? ta.wma(src_wma, length_wma4) : na, color=color.red, linewidth=4, title="WMA 100")

length_wma5 = input(200, "WMA 200")
plot(MA_WMA ? ta.wma(src_wma, length_wma5) : na, color=color.maroon, linewidth=5, title="WMA 200")

Declinazione di responsabilità

Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.