ozgurhan

Trend ribbon indikatörü

BITFINEX:BTCUSD   بتكوين
Merhbalar "trend ribbon indikatörünü" nde bazı düzenlemeler yaparak pine script kodlarını aşağıda veriyorum.
İndikatörde buy ve sell kısımlarını birleştirdim ki, tek bir alarm ile hem buy hem de sell alarmı geldiği zaman tek bir alarm ile (alarm geldi) işinizi görebilirsiniz.
İndikatörü 4 saatlik grafikte kullanmanızı tavsiye ederim.
//@version=4
study(title = "Trend ribbon", overlay = true)

//Settings
needlong = input(true, defval = true, title = "Long")
needshort = input(true, defval = true, title = "Short")
type = input(defval = "VWMA", options = , title = "MA Type")
len = input(20, minval = 5, title = "MA Length (min. 5)")
src1 = input(ohlc4, title = "MA Source")
src2 = input(ohlc4, title = "Signal Source")
showrib = input(true, title = "Show ribbon")
showbg = input(true, title = "Show color")
fromyear = input(1900, defval = 1900, minval = 1900, maxval = 2100, title = "From Year")
toyear = input(2100, defval = 2100, minval = 1900, maxval = 2100, title = "To Year")
frommonth = input(01, defval = 01, minval = 01, maxval = 12, title = "From Month")
tomonth = input(12, defval = 12, minval = 01, maxval = 12, title = "To Month")
fromday = input(01, defval = 01, minval = 01, maxval = 31, title = "From day")
today = input(31, defval = 31, minval = 01, maxval = 31, title = "To day")

//MA
ma = type == "SMA" ? sma(src1, len) : type == "EMA" ? ema(src1, len) : type == "VWMA" ? vwma(src1, len) : rma(src1, len)
colorma = showrib ? color.black : na
pm = plot(ma, color = colorma, title = "MA")

//Price Channel
h = highest(ma, len)
l = lowest(ma, len)
colorpc = showrib ? color.blue : na
ph = plot(h, color = colorpc, title = "Upper line")
pl = plot(l, color = colorpc, title = "Lower Line")

//Trend
trend = 0
trend := src2 > h ? 1 : src2 < l ? -1 : trend

//BG
colorbg1 = showbg ? color.red : na
colorbg2 = showbg ? color.green : na
fill(ph, pm, color = colorbg1, transp = 50)
fill(pl, pm, color = colorbg2, transp = 50)

//Trading
truetime = time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 23, 59)


LongSignal = trend == 1 and trend == -1 and needlong and truetime
ShortSignal = trend == -1 and trend == 1 and needshort and truetime

alertcondition(LongSignal, "Long Signal", 'Long Signal')
alertcondition(ShortSignal, "Sell Signal", 'Long Signal')
alertcondition(LongSignal or ShortSignal, title="alarm bulundu", message="alarm bulundu")

plotshape(LongSignal, title="Long",style=shape.labelup, text="Buy",location=location.belowbar, size=size.large, color=color.lime, textcolor=color.black, transp=0)
plotshape(ShortSignal, title="Short",style=shape.labeldown, text="Sell", location=location.abovebar, size=size.large, color=color.red, textcolor=color.black, transp=0)

إخلاء المسؤولية

لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.