Untitled

 avatar
unknown
plain_text
a month ago
13 kB
5
Indexable
//@version=5
indicator("Rsn Banker Upd", overlay=false, dynamic_requests=true) // dynamic_requests=true ekleyin

// Function to calculate the Main Force and Life Line oscillators
calculate_life_line_oscillator(n, weight, close, high, low) =>
    smoothedPrice = ((2 * close + high + low) / 4)
    lowestLow = ta.lowest(low, n)
    highestHigh = ta.highest(high, n)
    mainForce = ta.alma(ta.ema(((smoothedPrice - lowestLow) / (highestHigh - lowestLow)) * 100, n) * weight,3,0.85,6)
    lifeLine = ta.ema((0.667 * mainForce[1] + 0.333 * mainForce), 2) * weight
    [mainForce, lifeLine]

// User-defined inputs
n = input.int(27, title="Period")
weight = input.float(1.0, title="Weight", minval=0.1)

// Visual Settings
bullColor = input.color(color.yellow, "Bullish Color", group="Visual Settings")
bearColor = input.color(color.fuchsia, "Bearish Color", group="Visual Settings")
entryColor = input.color(color.yellow, "Entry Signal Color", group="Visual Settings")
exitColor = input.color(color.fuchsia, "Exit Signal Color", group="Visual Settings")

// Calculate the oscillators
[mainForce, lifeLine] = calculate_life_line_oscillator(n, weight, close, high, low)

// Plot the oscillators
plot(mainForce, color=color.yellow, linewidth = 2, title="Main Force")
plot(lifeLine, color=color.fuchsia, linewidth = 2, title="Life Line")

// Detect crossovers and crossunders
crossoverCondition = ta.crossover(mainForce, lifeLine)
crossunderCondition = ta.crossunder(mainForce, lifeLine)

// Draw labels for crossovers and crossunders
if crossoverCondition
    label.new(x=bar_index, y=mainForce, text="B", style=label.style_label_up, color=color.new(color.yellow,50), textcolor=color.white, size=size.small)

if crossunderCondition
    label.new(x=bar_index, y=mainForce, text="S", style=label.style_label_down, color=color.new(color.fuchsia,50), textcolor=color.white, size=size.small)

//functions
xrf(values, length) =>
    r_val = float(na)
    if length >= 1
        for i = 0 to length by 1
            if na(r_val) or not na(values[i])
                r_val := values[i]
                r_val
    r_val

xsa(src, len, wei) =>
    sumf = 0.0
    ma = 0.0
    out = 0.0
    sumf := nz(sumf[1]) - nz(src[len]) + src
    ma := na(src[len]) ? na : sumf / len
    out := na(out[1]) ? ma : (src * wei + out[1] * (len - wei)) / len
    out

//set up a simple model of banker fund flow trend	
fundtrend = (3 * xsa((close - ta.lowest(low, 27)) / (ta.highest(high, 27) - ta.lowest(low, 27)) * 100, 5, 1) - 2 * xsa(xsa((close - ta.lowest(low, 27)) / (ta.highest(high, 27) - ta.lowest(low, 27)) * 100, 5, 1), 3, 1) - 50) * 1.032 + 50
//define typical price for banker fund
typ = (2 * close + high + low + open) / 5
//lowest low with mid term fib # 34
lol = ta.lowest(low, 34)
//highest high with mid term fib # 34
hoh = ta.highest(high, 34)
//define banker fund flow bull bear line
bullbearline = ta.ema((typ - lol) / (hoh - lol) * 100, 13)
//define banker entry signal
bankerentry = ta.crossover(fundtrend, bullbearline) and bullbearline < 41
bankerexit =  ta.crossunder(fundtrend, bullbearline) and bullbearline > 75

plotcandle(0, 50, 0, 100, color = bankerentry ? entryColor : na, wickcolor = bankerentry ? #00000000 : na, bordercolor = bankerentry ? #00000000 : na)
plotcandle(0, 50, 0, 100, color = bankerexit ? exitColor : na, wickcolor = bankerexit ? #00000000 : na, bordercolor = bankerexit ? #00000000 : na)


// Kullanıcıdan tutar girdisi al
quantity = input.float(title="Yatırılacak Tutar (TL)", defval=10000, minval=1)

// Portföy alım-satım koşulu (örneğin, bir sinyal veya strateji koşulu)
portfoyBuysell = ta.crossover(mainForce, lifeLine)  // Örnek bir koşul

// Alım miktarını hesapla
var float defaultEntryQty = na
if quantity > 0 and portfoyBuysell and quantity > close
    defaultEntryQty := math.floor(quantity / close)

ADET = str.tostring(defaultEntryQty)
APIKEY = input.string(title="API Anahtarı", defval="", tooltip="Osmanlı Yatırım API anahtarınızı girin")

al =  ta.crossover(mainForce, lifeLine)
sat = ta.crossunder(mainForce, lifeLine)
Sinyal = al ? close : sat ? -1 * close : 0

// Sembol listesi
sembol1 = input.symbol(defval = "", title = "Symbol", group = "SCANNER",inline = "S1")
sembol2 = input.symbol(defval = "", title = "Symbol", group = "SCANNER",inline = "S2")
sembol3 = input.symbol(defval = "", title = "Symbol", group = "SCANNER",inline = "S3")
sembol4 = input.symbol(defval = "", title = "Symbol", group = "SCANNER",inline = "S4")
sembol5 = input.symbol(defval = "", title = "Symbol", group = "SCANNER",inline = "S5")
sembol6 = input.symbol(defval = "", title = "Symbol", group = "SCANNER",inline = "S6")
sembol7 = input.symbol(defval = "", title = "Symbol", group = "SCANNER",inline = "S7")
sembol8 = input.symbol(defval = "", title = "Symbol", group = "SCANNER",inline = "S8")
sembol9 = input.symbol(defval = "", title = "Symbol", group = "SCANNER",inline = "S9")
sembol10 = input.symbol(defval = "", title = "Symbol", group = "SCANNER",inline = "S10")
sembol11 = input.symbol(defval = "", title = "Symbol", group = "SCANNER",inline = "S11")
sembol12 = input.symbol(defval = "", title = "Symbol", group = "SCANNER",inline = "S12")
sembol13 = input.symbol(defval = "", title = "Symbol", group = "SCANNER",inline = "S13")
sembol14 = input.symbol(defval = "", title = "Symbol", group = "SCANNER",inline = "S14")
sembol15 = input.symbol(defval = "", title = "Symbol", group = "SCANNER",inline = "S15")
sembol16 = input.symbol(defval = "", title = "Symbol", group = "SCANNER",inline = "S16")
sembol17 = input.symbol(defval = "", title = "Symbol", group = "SCANNER",inline = "S17")
sembol18 = input.symbol(defval = "", title = "Symbol", group = "SCANNER",inline = "S18")
sembol19 = input.symbol(defval = "", title = "Symbol", group = "SCANNER",inline = "S19")
sembol20 = input.symbol(defval = "", title = "Symbol", group = "SCANNER",inline = "S20")
sembol21 = input.symbol(defval = "", title = "Symbol", group = "SCANNER",inline = "S21")
sembol22 = input.symbol(defval = "", title = "Symbol", group = "SCANNER",inline = "S22")
sembol23 = input.symbol(defval = "", title = "Symbol", group = "SCANNER",inline = "S23")
sembol24 = input.symbol(defval = "", title = "Symbol", group = "SCANNER",inline = "S24")
sembol25 = input.symbol(defval = "", title = "Symbol", group = "SCANNER",inline = "S25")
sembol26 = input.symbol(defval = "", title = "Symbol", group = "SCANNER",inline = "S26")
sembol27 = input.symbol(defval = "", title = "Symbol", group = "SCANNER",inline = "S27")
sembol28 = input.symbol(defval = "", title = "Symbol", group = "SCANNER",inline = "S28")
sembol29 = input.symbol(defval = "", title = "Symbol", group = "SCANNER",inline = "S29")
sembol30 = input.symbol(defval = "", title = "Symbol", group = "SCANNER",inline = "S30")
sembol31 = input.symbol(defval = "", title = "Symbol", group = "SCANNER",inline = "S31")
sembol32 = input.symbol(defval = "", title = "Symbol", group = "SCANNER",inline = "S32")
sembol33 = input.symbol(defval = "", title = "Symbol", group = "SCANNER",inline = "S33")
sembol34 = input.symbol(defval = "", title = "Symbol", group = "SCANNER",inline = "S34")
sembol35 = input.symbol(defval = "", title = "Symbol", group = "SCANNER",inline = "S35")
sembol36 = input.symbol(defval = "", title = "Symbol", group = "SCANNER",inline = "S36")
sembol37 = input.symbol(defval = "", title = "Symbol", group = "SCANNER",inline = "S37")
sembol38 = input.symbol(defval = "", title = "Symbol", group = "SCANNER",inline = "S38")
sembol39 = input.symbol(defval = "", title = "Symbol", group = "SCANNER",inline = "S39")
sembol40 = input.symbol(defval = "", title = "Symbol", group = "SCANNER",inline = "S40")

// Her sembol için fiyat bilgisini önceden hesapla
symbolPrice1 = request.security(sembol1, timeframe.period, close)
symbolPrice2 = request.security(sembol2, timeframe.period, close)
symbolPrice3 = request.security(sembol3, timeframe.period, close)
symbolPrice4 = request.security(sembol4, timeframe.period, close)
symbolPrice5 = request.security(sembol5, timeframe.period, close)
symbolPrice6 = request.security(sembol6, timeframe.period, close)
symbolPrice7 = request.security(sembol7, timeframe.period, close)
symbolPrice8 = request.security(sembol8, timeframe.period, close)
symbolPrice9 = request.security(sembol9, timeframe.period, close)
symbolPrice10 = request.security(sembol10, timeframe.period, close)
symbolPrice11 = request.security(sembol11, timeframe.period, close)
symbolPrice12 = request.security(sembol12, timeframe.period, close)
symbolPrice13 = request.security(sembol13, timeframe.period, close)
symbolPrice14 = request.security(sembol14, timeframe.period, close)
symbolPrice15 = request.security(sembol15, timeframe.period, close)
symbolPrice16 = request.security(sembol16, timeframe.period, close)
symbolPrice17 = request.security(sembol17, timeframe.period, close)
symbolPrice18 = request.security(sembol18, timeframe.period, close)
symbolPrice19 = request.security(sembol19, timeframe.period, close)
symbolPrice20 = request.security(sembol20, timeframe.period, close)
symbolPrice21 = request.security(sembol21, timeframe.period, close)
symbolPrice22 = request.security(sembol22, timeframe.period, close)
symbolPrice23 = request.security(sembol23, timeframe.period, close)
symbolPrice24 = request.security(sembol24, timeframe.period, close)
symbolPrice25 = request.security(sembol25, timeframe.period, close)
symbolPrice26 = request.security(sembol26, timeframe.period, close)
symbolPrice27 = request.security(sembol27, timeframe.period, close)
symbolPrice28 = request.security(sembol28, timeframe.period, close)
symbolPrice29 = request.security(sembol29, timeframe.period, close)
symbolPrice30 = request.security(sembol30, timeframe.period, close)
symbolPrice31 = request.security(sembol31, timeframe.period, close)
symbolPrice32 = request.security(sembol32, timeframe.period, close)
symbolPrice33 = request.security(sembol33, timeframe.period, close)
symbolPrice34 = request.security(sembol34, timeframe.period, close)
symbolPrice35 = request.security(sembol35, timeframe.period, close)
symbolPrice36 = request.security(sembol36, timeframe.period, close)


// Sinyali tetikleyen fonksiyon
alarmTetikle(sembol, sinyal, symbolPrice) =>
    durum = request.security(sembol, timeframe.period, sinyal)
    mesaj = durum > 0 ? "buy" : durum < 0 ? "sell" : ""  // Alım veya satım durumu
    if durum != 0 and str.length(sembol) > 1
        // Alım miktarını hesapla
        entryQty = math.floor(quantity / symbolPrice)
        // Osmanlı Yatırım için JSON formatında emir mesajı oluştur
        alarmMesajiJSON = '{"name": "osmanlı yatırım sinyali",' +
                          '"symbol": "' + syminfo.ticker(sembol) + '",' +
                          '"orderSide": "' + mesaj + '",' +
                          '"orderType": "mkt",' +
                          '"price": "0",' +
                          '"quantity": "' + str.tostring(entryQty) + '",' +
                          '"timeInForce": "ioc",' +
                          '"apiKey": "' + APIKEY + '",' +
                          '"goodInOffHours": "0"}'
        
        // Osmanlı Yatırım sistemine emir gönderme
        alert(message = alarmMesajiJSON, freq = alert.freq_once_per_bar_close)

// Her sembol için alarmTetikle fonksiyonunu çağır
alarmTetikle(sembol1, Sinyal, symbolPrice1)
alarmTetikle(sembol2, Sinyal, symbolPrice2)
alarmTetikle(sembol3, Sinyal, symbolPrice3)
alarmTetikle(sembol4, Sinyal, symbolPrice4)
alarmTetikle(sembol5, Sinyal, symbolPrice5)
alarmTetikle(sembol6, Sinyal, symbolPrice6)
alarmTetikle(sembol7, Sinyal, symbolPrice7)
alarmTetikle(sembol8, Sinyal, symbolPrice8)
alarmTetikle(sembol9, Sinyal, symbolPrice9)
alarmTetikle(sembol10, Sinyal, symbolPrice10)
alarmTetikle(sembol11, Sinyal, symbolPrice11)
alarmTetikle(sembol12, Sinyal, symbolPrice12)
alarmTetikle(sembol13, Sinyal, symbolPrice13)
alarmTetikle(sembol14, Sinyal, symbolPrice14)
alarmTetikle(sembol15, Sinyal, symbolPrice15)
alarmTetikle(sembol16, Sinyal, symbolPrice16)
alarmTetikle(sembol17, Sinyal, symbolPrice17)
alarmTetikle(sembol18, Sinyal, symbolPrice18)
alarmTetikle(sembol19, Sinyal, symbolPrice19)
alarmTetikle(sembol20, Sinyal, symbolPrice20)
alarmTetikle(sembol21, Sinyal, symbolPrice21)
alarmTetikle(sembol22, Sinyal, symbolPrice22)
alarmTetikle(sembol23, Sinyal, symbolPrice23)
alarmTetikle(sembol24, Sinyal, symbolPrice24)
alarmTetikle(sembol25, Sinyal, symbolPrice25)
alarmTetikle(sembol26, Sinyal, symbolPrice26)
alarmTetikle(sembol27, Sinyal, symbolPrice27)
alarmTetikle(sembol28, Sinyal, symbolPrice28)
alarmTetikle(sembol29, Sinyal, symbolPrice29)
alarmTetikle(sembol30, Sinyal, symbolPrice30)
alarmTetikle(sembol31, Sinyal, symbolPrice31)
alarmTetikle(sembol32, Sinyal, symbolPrice32)
alarmTetikle(sembol33, Sinyal, symbolPrice33)
alarmTetikle(sembol34, Sinyal, symbolPrice34)
alarmTetikle(sembol35, Sinyal, symbolPrice35)
alarmTetikle(sembol36, Sinyal, symbolPrice36)
Leave a Comment