Untitled

 avatar
unknown
plain_text
a month ago
3.9 kB
39
Indexable
//@version=5
indicator("Kasa Yönetimi-RR", overlay=true)

// Kullanıcıdan giriş fiyatı belirleme (otomatik veya manuel)
useClosePrice = input.bool(true, title="Son Mum Fiyatını Kullan")
entryPrice = useClosePrice ? close : input.float(0, title="Giriş Fiyatı (Manuel Gir)")

// ATR çarpanına göre stop ve target hesaplama
atrMultiplier = input.float(2, title="ATR Çarpanı")
atrValue = ta.atr(14) * atrMultiplier

// Kasa büyüklüğü ve risk yüzdesi
accountSize = input(10000, title="Kasa Büyüklüğü ($)")
riskPercent = input.float(1, title="Risk Yüzdesi (%)") / 100
rewardPercent = 2 * riskPercent

// İşlem yönünü seç (Long veya Short)
tradeDirection = input.string("Long", title="İşlem Yönü", options=["Long", "Short"])

// ATR'ye göre stop ve hedef mesafesi
stopDistance = atrValue
targetDistance = atrValue * 2

// Risk miktarı
riskAmount = accountSize * riskPercent

// Long ve Short için ayrı ayrı TP ve Stop hesapla
stopPrice = tradeDirection == "Long" ? entryPrice - stopDistance : entryPrice + stopDistance
tpPrice = tradeDirection == "Long" ? entryPrice + targetDistance : entryPrice - targetDistance

// Kullanıcının belirleyebileceği marjin ve kaldıraç
leverage = input.int(10, title="Kaldıraç (X)")

// Marjin kullanımı hesapla
marginUsed = (riskAmount / stopDistance) * entryPrice / leverage

// Birim hesaplama: Kaldıraç * Marjin Kullanımı
unit = marginUsed * leverage

// Kullanıcıdan tablo konumunu seçme
tablePosition = input.string("Top Right", title="Tablo Konumu", options=["Top Right", "Top Left", "Bottom Left", "Bottom Right"])

// Kullanıcıdan tablo boyutunu ayarlama
tableRows = input.int(7, title="Tablo Satır Sayısı", minval=1, maxval=10)  // Satır sayısını 7 yaptık
tableColumns = input.int(2, title="Tablo Sütun Sayısı", minval=1, maxval=3)

// Kullanıcıdan renk seçme
headerColor = input.color(color.black, title="Başlık Yazı Rengi")
valueColor = input.color(color.black, title="Değer Yazı Rengi")
stopColor = input.color(color.red, title="Stop Fiyatı Yazı Rengi")
tpColor = input.color(color.green, title="TP Fiyatı Yazı Rengi")
marginColor = input.color(color.blue, title="Marjin Yazı Rengi")
unitColor = input.color(color.purple, title="Birim Yazı Rengi")  // Birim rengi
bgColor = input.color(color.gray, title="Tablo Arka Plan Rengi")

// Tablonun konumu
position = tablePosition == "Top Right" ? position.top_right :
           tablePosition == "Top Left" ? position.top_left :
           tablePosition == "Bottom Left" ? position.bottom_left :
           position.bottom_right

// Sabit yazı boyutu
textSize = 12  // Yazı boyutunu buradan sabitleyebilirsiniz

// Tabloyu oluştur
var table t = table.new(position=position, columns=tableColumns, rows=tableRows, bgcolor=bgColor)

// Tabloyu doldur
table.cell(t, 0, 0, "İşlem Yönü:", text_color=headerColor)
table.cell(t, 1, 0, tradeDirection, text_color=valueColor)

table.cell(t, 0, 1, "Giriş Fiyatı:", text_color=headerColor)
table.cell(t, 1, 1, str.tostring(entryPrice, format.mintick), text_color=valueColor)

table.cell(t, 0, 2, "ATR Çarpanı:", text_color=headerColor)
table.cell(t, 1, 2, str.tostring(atrMultiplier), text_color=valueColor)

table.cell(t, 0, 3, "Stop Fiyatı:", text_color=headerColor)
table.cell(t, 1, 3, str.tostring(stopPrice, format.mintick), text_color=stopColor)

table.cell(t, 0, 4, "TP Fiyatı:", text_color=headerColor)
table.cell(t, 1, 4, str.tostring(tpPrice, format.mintick), text_color=tpColor)

table.cell(t, 0, 5, "Marjin Kullanımı:", text_color=headerColor)
table.cell(t, 1, 5, str.tostring(marginUsed, format.mintick) + " $", text_color=marginColor)

table.cell(t, 0, 6, "Birim:", text_color=headerColor)  // Birim başlığı
table.cell(t, 1, 6, str.tostring(unit, format.mintick) + " $", text_color=unitColor)  // Birim değeri
Editor is loading...
Leave a Comment