Untitled
unknown
plain_text
10 months ago
51 kB
13
Indexable
//@version=5
//@strategy_alert_message {{strategy.order.alert_message}}
strategy('Kule Dönence Str TP qty bar bekleme'
, shorttitle = 'Kule Dönence Str TP qty bar bekleme'
, overlay = true)
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Giriş miktarı seçim grubu
grGiris = "💰 Giriş Miktarı Ayarları 💰"
girisTipi = input.string(title="Giriş Tipi (Tutar veya Lot)", options=["Tutar", "Adet"], defval="Tutar", tooltip="İşleme giriş yöntemini seçin: Tutar (TL bazında) veya Adet (sabit lot sayısı)", group=grGiris)
// Dinamik tek input - giriş tipine göre değişen input
girisDegeri = input.float(title="Giriş Değeri (Tutar veya Lot Adet)", defval=10000, minval=1, tooltip="Seçilen giriş tipine göre değer girin", group=grGiris)
// Fiyat onaylama için bar sayısı parametresi eklendi
grOnay = "🔍 İşlem Onay Ayarları 🔍"
barKontrol = input.bool(title="Bar Onayı Aktif", defval=true, tooltip="İşleme girmeden önce fiyat onayı kontrolünü aktifleştirir", group=grOnay)
barSayisi = input.int(title="Onay İçin Bar Sayısı", defval=1, minval=1, maxval=3, tooltip="Kaç bar sonra kontrolleri yapacak (fiyat ve RSI)", group=grOnay)
var float islemLotu = na
var float sonGirisLotu = na
var int pozisyonDurumu = 0
// Lot hesaplama işlevi - giriş tipine göre hesaplama yapılır
lotHesapla() =>
if girisTipi == "Tutar"
math.floor(girisDegeri / close) // Tutar/fiyat ile lot hesaplanır
else
math.floor(girisDegeri) // Doğrudan adet değeri kullanılır (float'tan integer'a çevirme için math.floor)
APIKEY = input.string(title="API Key", defval="")
TOKEN = input.string(title="TOKEN", defval="")
// Date Input Parameters
startDate = input.time(timestamp("2024-08-01"), "Start Date")
endDate = input.time(timestamp("2025-12-31"), "End Date")
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// ---------------------------- Theme --------------------------------------- //
// Colors
red = color.red
green = color.rgb(21, 194, 122)
brightred = color.rgb(158, 43, 35)
brightgreen = color.rgb(21, 194, 122)
cautioncol = color.yellow
gray= color.gray
aqua = color.aqua
orange= color.orange
darkgreen = color.rgb(21, 194, 122)
darkred = color.rgb(165, 57, 66)
// Groups
grma = "📈 Moving Averages 📈"
grhts = "Trend Seviyeleri"
grt = "DCA"
grll = "🩸 Leverage Liquidations 🩸"
gla= "🔔 Alerts 🔔"
// Constants
dataType = "Custom"
instructions = "Off"
smaS = "Off"
constant = 1>0
rsi=ta.rsi(close,14)
// ------------------------- Trend State ------------------------------------ //
// Code Author: © Koalafied_3
showtrend = true
showbc = input(true, title='Bar Boyama Göster?',group=grhts)
ts1 = 66
ts2 = 37
ts1a = 61
ts2a = 39
// Trend State
var state = 0
if ta.crossover(rsi, ts1)
state := 1
state
if ta.crossunder(rsi, ts2)
state := 2
state
state := state
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
cbullu = brightgreen
cbulld = darkgreen
cbearu = brightred
cbeard = darkred
cbearc = brightgreen
cbullc = brightred
barcolor(state==1 and rsi>50?cbullu: state==1 and rsi<50?cbulld: state==2 and rsi<50 ?cbearu: state==2 and rsi>50 ?cbeard:color.new(color.from_gradient(rsi, ts2, ts1, cbearu, cbullu),0),title="Chart Bar Color", display = showbc ? display.all : display.none, editable=false)
// Define a bull/bear cross
bullcross= state==1 and state[1]==2
bearcross= state==2 and state[1]==1
// Detect what was last signal (long or short)
long_short = 0
long_last = bullcross and (nz(long_short[1]) == 0 or nz(long_short[1]) == -1)
// short_last = bearcross and (nz(long_short[1]) == 0 or nz(long_short[1]) == 1)
// long_short := long_last ? 1 : short_last ? -1 : long_short[1]
// Remove first bar for SL/TP (you can't enter a trade at bar close and THEN hit your SL on that same bar)
longBar1 = ta.barssince(long_last)
longBar2 = longBar1 >= 1 ? true : false
// ATR hesaplama yöntemi için seçenekler
atr_method = 'hl2'
// ATR kaynağı (srcATR) - Kullanıcının seçimine göre hesaplanır
var float srcATR = na
if atr_method == "close"
srcATR := close
else if atr_method == "hl2"
srcATR := (high + low) / 2
else if atr_method == "hlc3"
srcATR := (high + low + close) / 3
// ATR periyodu
atrPeriod = 9
per = atrPeriod
// ATR çarpanı
atrMultiplier = 3.7
// ATR hesaplama
atr_value = ta.atr(per)
// ATR çarpanı ile çarpılmış değer
atr_multiplied = atr_value * atrMultiplier
atr = ta.atr(atrPeriod)
ATRupper=srcATR + atr * atrMultiplier
ATRlower=srcATR - atr * atrMultiplier
ATRupper2=srcATR + atr * (atrMultiplier*6)
ATRlower2=srcATR - atr * (atrMultiplier*6)
ATRupper3=srcATR + atr * (atrMultiplier*4)
ATRlower3=srcATR - atr * (atrMultiplier*4)
ATRupper4=srcATR + atr * (atrMultiplier*2)
ATRlower4=srcATR - atr * (atrMultiplier*2)
bearse3=srcATR + atr * (atrMultiplier*0.5)
bullse3=srcATR - atr * (atrMultiplier*0.5)
ATRbulltp1=ta.valuewhen(bullcross,ATRupper,0)
ATRbeartp1=ta.valuewhen(bearcross,ATRlower,0)
ATRbulltp2=ta.valuewhen(bullcross,ATRupper2,0)
ATRbeartp2=ta.valuewhen(bearcross,ATRlower2,0)
ATRbulltp3=ta.valuewhen(bullcross,ATRupper3,0)
ATRbeartp3=ta.valuewhen(bearcross,ATRlower3,0)
ATRbulltp4=ta.valuewhen(bullcross,ATRupper4,0)
ATRbeartp4=ta.valuewhen(bearcross,ATRlower4,0)
vwbearse3=ta.valuewhen(bearcross,bearse3,0)
vwbullse3=ta.valuewhen(bullcross,bullse3,0)
bgrad = 80
tgrad = 95
exin = state==1 and long_short==1?ATRbulltp1:state==2 and long_short==-1?ATRbeartp1:na
excol = long_short == 1 and close<ATRbulltp1?green: long_short==-1 and close>ATRbeartp1?red:color.yellow
// exout = plot(exin, 'Kar AL', color=color.new(excol, 0), style=plot.style_circles, editable=false)
dca3in=state==1 and long_short==1?vwbullse3:state==2 and long_short==-1?vwbearse3:na
// dca3out=plot(dca3in, "Stop", color=color.new(color.red, 0), style=plot.style_circles, editable=false)
bgcol2 = state==1 and state[1]==2 ?color.green : state==2 and state[1]==1 ? color.red :na
// Candle Color Logic
var color candle_col = na
if bullcross
candle_col := brightgreen
if bearcross
candle_col := brightred
// Plot Candles
plotcandle(open, high, low, close, title = 'Title', color = candle_col, wickcolor = candle_col, bordercolor = candle_col)
// Plot Trend State
barcolor(state==1 and rsi>50?brightgreen: state==1 and rsi<50?darkgreen: state==2 and rsi<50 ?brightred: state==2 and rsi>50 ?darkred:color.new(color.from_gradient(rsi, ts2, ts1, brightred, brightgreen),0),title="Chart Bar Color", display = showbc ? display.all : display.none, editable=false)
// trend Alarm Koşulları
TrendAlarmal= state==1 and state[1]==2
TrendAlarmsat= state==2 and state[1]==1
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// IMBA Trend Line hesaplama ve plot etme kodu
// Yuvarlama fonksiyonu
RoundUp(number, decimals) =>
factor = math.pow(10, decimals)
math.ceil(number * factor) / factor
// Risk-reward hesaplama fonksiyonu
calc_rr(float entry_price, float sl_price, float take_price) =>
entry_price > sl_price ? (take_price - entry_price) / (entry_price - sl_price) : (entry_price - take_price) / (sl_price - entry_price)
// IMBA Trend Line oluşturma fonksiyonu
create_trend_line(float sensitivity, float fib) =>
high_line = ta.highest(high, int(sensitivity))
low_line = ta.lowest(low, int(sensitivity))
channel_range = high_line - low_line
high_line - channel_range * fib
// Ana hesaplama kodu
sensitivity = 100 // Fixed value (10 * 10)
// Fibonacci seviyeleri ve trend line hesaplamaları
high_line = ta.highest(high, int(sensitivity))
low_line = ta.lowest(low, int(sensitivity))
channel_range = high_line - low_line
fib_236 = high_line - channel_range * 0.236
fib_382 = high_line - channel_range * 0.382
fib_5 = high_line - channel_range * 0.5
fib_618 = high_line - channel_range * 0.618
fib_786 = high_line - channel_range * 0.786
imba_trend_line = fib_5
// Trend belirleme
var bool is_long_trend = false
var bool is_short_trend = false
var bool is_long_trend_started = false
var bool is_short_trend_started = false
var bool is_trend_change = false
// Değişken tanımlamaları (kodun başına ekleyin)
var bool can_long = false
var bool can_short = false
// Atama kısmında := kullanın (mevcut = yerine)
if time >= startDate
can_long := close >= imba_trend_line and close >= fib_236 and not is_long_trend
can_short := close <= imba_trend_line and close <= fib_786 and not is_short_trend
else
can_long := false
can_short := false
if can_long
is_long_trend := true
is_short_trend := false
is_long_trend_started := is_long_trend_started ? false : true
else if can_short
is_short_trend := true
is_long_trend := false
is_short_trend_started := is_short_trend_started ? false : true
else
is_trend_change := false
can_long := false
can_short := false
is_short_trend_started := false
is_long_trend_started := false
is_trend_change := is_short_trend_started or is_long_trend_started
// Plot işlemleri
// Trend line
plot(imba_trend_line, color = is_long_trend[1] ? color.green : color.red, linewidth = 2, title="Trend Çizgisi", display = display.none)
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Mevcut Barın Zamanı
currentTime = time
// Strateji sadece belirtilen tarih aralığında çalışacak
isInDateRange = (currentTime >= startDate and currentTime <= endDate)
var bool positionActive = false
var bool tp1Executed = false
var bool tp2Executed = false
var float tp1Lot = na
var float tp2Lot = na
var float tp3Lot = na
var float kalanLot = na
// Take Profit Seviyeleri (ATR Değerleri)
tp1Level = ta.valuewhen(bullcross, ATRupper4, 0) // ATRupper7 (0.236) TP1 için
tp2Level = ta.valuewhen(bullcross, ATRupper3, 0) // ATRupper4 (0.618) TP2 için
tp3Level = ta.valuewhen(bullcross, ATRupper2, 0) // ATRupper (1.0) TP3 için
tp1Hit = ta.crossover(high, tp1Level) and positionActive and not tp1Executed and longBar2
tp2Hit = ta.crossover(high, tp2Level) and positionActive and tp1Executed and not tp2Executed and longBar2
tp3Hit = ta.crossover(high, tp3Level) and positionActive and tp1Executed and tp2Executed and longBar2
// Define input parameters with default values
tp1Oran = input.float(0.40, title="TP1 Oranı", minval=0.0, maxval=1.0, step=0.01)
tp2Oran = input.float(0.30, title="TP2 Oranı", minval=0.0, maxval=1.0, step=0.01)
tp3Oran = 0.30
// // tp1Oran = 0.40
// // tp2Oran = 0.30
// // tp3Oran = 0.30
// // ema14_1h = request.security(syminfo.tickerid, "60", ta.ema(close, 14))
// // plot(ema14_1h, title="1D EMA", color=#000000, linewidth=2)
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Günlük yüzde değişim kontrolü için açma/kapama düğmesi ekle
enablePercentCheck = input.bool(true, "Günlük % Değişim Üstündekileri Alma Etkinleştir", group="Yüzde Değişim Kontrolü")
// Günlük yüzde değişimi hesapla - gerçek günlük değişim
// Günün başındaki değeri al (günlük time frame için)
dayStartPrice = request.security(syminfo.tickerid, "D", open[0], lookahead=barmerge.lookahead_on)
// Günlük yüzde değişimi hesapla
dailyPercentChange = ((close - dayStartPrice) / dayStartPrice) * 100
// Günlük yüzde değişim için parametre ekle
yuzdeLimit = input.float(8.0, "Maksimum Günlük % Değişim", minval=1.0, maxval=20.0, step=0.5, group="Yüzde Değişim Kontrolü")
// RSI Kontrolü için açma/kapama düğmesi ve seviye giriş ekle
enableRSICheck = true
rsiLevel = 66
rsiLength = 14
// RSI hesapla
rsiValue = ta.rsi(close, rsiLength)
// RSI 66 seviyesini yukarı kırma durumunu kontrol et
rsiCrossUp = ta.crossover(rsiValue, rsiLevel)
// RSI koşulu kontrolü
var rsiConditionMet = false
if (enableRSICheck)
rsiConditionMet := rsiCrossUp
else
rsiConditionMet := true // RSI kontrolü devre dışıysa, koşul karşılanmış kabul et
// Bar kontrolü için değişkenler
var bool isBarConfirmWaiting = false
var float entryBarPrice = na
var int confirmBarCounter = 0
// Fiyat ve RSI kontrolü fonksiyonu - belirtilen bar sayısı sonra kontrol yapar
isEntryConfirmed() =>
// Bar kontrolü aktif değilse true döndür
if not barKontrol
true
else
// Onay için gerekli bar sayısı tamamlanmışsa fiyat ve RSI kontrolü yap
confirmBarCounter >= barSayisi and close > entryBarPrice and (rsiValue >= ts1 or ta.crossover(rsiValue, ts1))
// İşlem girişi sinyal sinyali oluşma koşulu
entrySignal = isInDateRange and bullcross and rsiConditionMet and not positionActive and (not enablePercentCheck or dailyPercentChange <= yuzdeLimit) and barstate.isconfirmed
// Sinyal geldiğinde bar kontrolü için değerleri ayarla
if entrySignal and barKontrol and not isBarConfirmWaiting
isBarConfirmWaiting := true
entryBarPrice := close
confirmBarCounter := 0
// Bar sayacını artır
if isBarConfirmWaiting
confirmBarCounter := confirmBarCounter + 1
// İşlem girişinde lot hesaplama
if (entrySignal and not barKontrol) or (isBarConfirmWaiting and isEntryConfirmed())
sonGirisLotu := lotHesapla()
kalanLot := sonGirisLotu
tp1Lot := math.floor(sonGirisLotu * tp1Oran)
tp2Lot := math.floor(sonGirisLotu * tp2Oran)
tp3Lot := sonGirisLotu - tp1Lot - tp2Lot
strategy.entry("Long", strategy.long, qty=sonGirisLotu)
alert('{"name": "🚀' + "İşleme girdi" + '", "symbol": "' + syminfo.ticker + '", "orderSide": "buy", "orderType": "mktbest", "price": "' + str.tostring(close) + '", "quantity": "' + str.tostring(sonGirisLotu) + '", "timeInForce": "day", "apiKey": "' + APIKEY + '", "token": "' + TOKEN + '"}', alert.freq_once_per_bar_close)
positionActive := true
tp1Executed := false
tp2Executed := false
isBarConfirmWaiting := false // Kontrolü sıfırla
// Bar onayı beklerken bearcross olursa işlem iptali
if isBarConfirmWaiting and bearcross
isBarConfirmWaiting := false
if (isInDateRange and tp1Hit)
strategy.exit("TP1", "Long", qty=tp1Lot, limit=tp1Level, comment="TP1")
alert('{"name": "💸' + "TP1 - İlk Kısmi Çıkış" + '", "symbol": "' + syminfo.ticker + '", "orderSide": "sell", "orderType": "mktbest", "price": "' + str.tostring(tp1Level) + '", "quantity": "' + str.tostring(tp1Lot) + '", "timeInForce": "day", "apiKey": "' + APIKEY + '", "token": "' + TOKEN + '"}', alert.freq_once_per_bar_close)
kalanLot := kalanLot - tp1Lot
tp1Executed := true
if (isInDateRange and tp2Hit)
strategy.exit("TP2", "Long", qty=tp2Lot, limit=tp2Level, comment="TP2")
alert('{"name": "💸' + "TP2 - İkinci Kısmi Çıkış" + '", "symbol": "' + syminfo.ticker + '", "orderSide": "sell", "orderType": "mktbest", "price": "' + str.tostring(tp2Level) + '", "quantity": "' + str.tostring(tp2Lot) + '", "timeInForce": "day", "apiKey": "' + APIKEY + '", "token": "' + TOKEN + '"}', alert.freq_once_per_bar_close)
kalanLot := kalanLot - tp2Lot
tp2Executed := true
// TP3 koşulunu kaldırdık
if (isInDateRange and bearcross and positionActive)
strategy.close("Long", comment="Son Çıkış")
alert('{"name": "🔄' + "Trend Değişimi - Çıkış" + '", "symbol": "' + syminfo.ticker + '", "orderSide": "sell", "orderType": "mktbest", "price": "' + str.tostring(close) + '", "quantity": "' + str.tostring(kalanLot) + '", "timeInForce": "day", "apiKey": "' + APIKEY + '", "token": "' + TOKEN + '"}', alert.freq_once_per_bar_close)
kalanLot := 0
positionActive := false
tp1Executed := false
tp2Executed := false
p_tp1 = plot(positionActive ? tp1Level : na, "TP1 Seviyesi", color=color.new(color.green, 0), style=plot.style_line, linewidth=2,show_last = 21)
p_tp2 = plot(positionActive ? tp2Level : na, "TP2 Seviyesi", color=color.new(color.blue, 0), style=plot.style_line, linewidth=2,show_last = 21)
// Bar onay durumu işaretleme (debug için)
plotshape(isBarConfirmWaiting, title="Bar Onay Bekliyor", location=location.belowbar, color=color.yellow, style=shape.circle, size=size.small)
plotshape(entrySignal and not barKontrol or (isBarConfirmWaiting and isEntryConfirmed()), title="İşlem Sinyali", location=location.belowbar, color=color.green, style=shape.triangleup, size=size.small)
// p_tp3 = plot(positionActive ? tp3Level : na, "TP3 Seviyesi", color=color.new(color.purple, 0), style=plot.style_line, linewidth=2,show_last = 500)
// label.new(bar_index, tp3Level, "TP3 ", style=label.style_label_left, color=color.purple, textcolor=color.white)
// label.new(bar_index, tp3Level, "TP3 ", style=label.style_label_left, color=color.purple, textcolor=color.white)
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Copy below code to end of the desired strategy script
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// INTEGRATED PERFORMANCE TABLES //
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// COMMON TABLE SETTINGS (CONSOLIDATED)
show_performance = input.bool(true, 'Tüm Tabloları Göster?', group='PERFORMANCE SETTINGS')
// Individual table toggles
show_monthly_table = input.bool(true, 'Aylık Performance Tablosu Göster', group='TABLE TOGGLES')
show_metrics_table = input.bool(true, 'Metriks Performance Tablosu Göster', group='TABLE TOGGLES')
show_trend_table = input.bool(true, 'Multi-Timeframe Tablosu Göster', group='TABLE TOGGLES')
showTable = input.bool(true, title="Hacim Tablosu Göster", group='TABLE TOGGLES')
// Text and size settings for each table
monthly_text_size = input.session('Small', " Aylık Tablo Boyutu", options=["Tiny", "Small", "Normal", "Large"], group=' Tablo Ayarları', inline="monthly_size")
monthly_width = 14
monthly_height = 40
metrics_text_size = input.session('Small', "Metriks Tablo Boyutu", options=["Tiny", "Small", "Normal", "Large"], group=' Tablo Ayarları', inline="metrics_size")
metrics_width = 2
metrics_height = 10
trend_text_size = input.session('Small', " Trend Tablo Boyutu", options=["Tiny", "Small", "Normal", "Large"], group=' Tablo Ayarları', inline="trend_size")
trend_width = 6
trend_height = 2
// Location settings for each table
monthly_table_loc = input.session("Bottom Right", "Konum", options=["Top Right", "Bottom Right", "Top Left", "Bottom Left", "Middle Right", "Bottom Center", "Top Center"], group=' Tablo Ayarları', inline="monthly_size")
monthly_x_offset = 0
monthly_y_offset = 0
metrics_table_loc = input.session("Bottom Left", "Konum", options=["Top Right", "Bottom Right", "Top Left", "Bottom Left", "Middle Right", "Bottom Center", "Top Center"], group=' Tablo Ayarları', inline="metrics_size")
metrics_x_offset = 0
metrics_y_offset = 0
trend_table_loc = input.session("Top Center", "Konum", options=["Top Right", "Bottom Right", "Top Left", "Bottom Left", "Middle Right", "Bottom Center", "Top Center"], group=' Tablo Ayarları', inline="trend_size")
trend_x_offset = 0
trend_y_offset = 0
// Color settings - fixed values instead of inputs
bg_color = color.rgb(91, 91, 94, 38)
text_head_color = #ffffff
data_text_color = color.white
border_color = color.white
profit_color = color.rgb(0, 150, 0)
loss_color = color.rgb(150, 0, 0)
neutral_color = color.rgb(0, 0, 150)
// Determine text sizes for each table
var monthly_table_text_size = monthly_text_size == 'Tiny' ? size.tiny :
monthly_text_size == 'Small' ? size.small :
monthly_text_size == 'Normal' ? size.normal : size.large
var metrics_table_text_size = metrics_text_size == 'Tiny' ? size.tiny :
metrics_text_size == 'Small' ? size.small :
metrics_text_size == 'Normal' ? size.normal : size.large
var trend_table_text_size = trend_text_size == 'Tiny' ? size.tiny :
trend_text_size == 'Small' ? size.small :
trend_text_size == 'Normal' ? size.normal : size.large
// Determine table positions based on selections
var monthly_table_position = monthly_table_loc == 'Bottom Right' ? position.bottom_right :
monthly_table_loc == 'Bottom Left' ? position.bottom_left :
monthly_table_loc == 'Middle Right' ? position.middle_right :
monthly_table_loc == 'Bottom Center' ? position.bottom_center :
monthly_table_loc == 'Top Right' ? position.top_right :
monthly_table_loc == 'Top Center' ? position.top_center :
monthly_table_loc == 'Top Left' ? position.top_left : position.bottom_right
var metrics_table_position = metrics_table_loc == 'Bottom Right' ? position.bottom_right :
metrics_table_loc == 'Bottom Left' ? position.bottom_left :
metrics_table_loc == 'Middle Right' ? position.middle_right :
metrics_table_loc == 'Bottom Center' ? position.bottom_center :
metrics_table_loc == 'Top Right' ? position.top_right :
metrics_table_loc == 'Top Center' ? position.top_center :
metrics_table_loc == 'Top Left' ? position.top_left : position.bottom_left
var trend_table_position = trend_table_loc == 'Bottom Right' ? position.bottom_right :
trend_table_loc == 'Bottom Left' ? position.bottom_left :
trend_table_loc == 'Middle Right' ? position.middle_right :
trend_table_loc == 'Bottom Center' ? position.bottom_center :
trend_table_loc == 'Top Right' ? position.top_right :
trend_table_loc == 'Top Center' ? position.top_center :
trend_table_loc == 'Top Left' ? position.top_left : position.top_center
/////////////////////////////////////////////
// MONTHLY PNL PERFORMANCE LOGIC
/////////////////////////////////////////////
// var bool new_month = na
new_month = ta.change(month) //> 0 ? true : false
newest_month = new_month and strategy.closedtrades >= 1
// profit
only_profit = strategy.netprofit
initial_balance = strategy.initial_capital
// month number
var int month_number = na
month_number := (ta.valuewhen(newest_month, month(time), 0)) //and month(time) > 1 ? (ta.valuewhen(newest_month, month(time), 0) - 1) : 12 //1 to 12
//month_year
var int month_time = na
month_time := ta.valuewhen(newest_month, time, 0) - 2419200000
var int m_counter = 0
if newest_month
m_counter += 1
// current month values
var bool new_year = na
new_year := ta.change(year) ? true : false
curr_m_pnl = only_profit - nz(ta.valuewhen(newest_month, only_profit, 0), 0)
curr_m_number = newest_month ? ta.valuewhen(newest_month, month(time), 0) : month(time)
curr_y_pnl = (only_profit - nz(ta.valuewhen(new_year, only_profit, 0),0))
var float [] net_profit_array = array.new_float()
var int [] month_array = array.new_int()
var int [] month_time_array = array.new_int()
if newest_month
array.push(net_profit_array, only_profit)
array.push(month_array, month_number)
array.push(month_time_array, month_time)
var float [] y_pnl_array = array.new_float()
var int [] y_number_array = array.new_int()
var int [] y_time_array = array.new_int()
newest_year = new_year and strategy.closedtrades >= 1
get_yearly_pnl = nz(ta.valuewhen(newest_year, strategy.netprofit, 0) - nz(ta.valuewhen(newest_year, strategy.netprofit, 1), 0), 0)
get_m_year = ta.valuewhen(newest_year, year(time), 2)
get_y_time = ta.valuewhen(newest_year, time, 0)
if newest_year
array.push(y_pnl_array, get_yearly_pnl)
array.push(y_number_array, get_m_year)
array.push(y_time_array, get_y_time)
var float monthly_profit = na
var int column_month_number = na
var int row_month_time = na
var int row_y = na
// Create monthly performance table
var monthlyTable = table.new(position = monthly_table_position, columns = monthly_width, rows = monthly_height, bgcolor = bg_color, border_color = border_color, border_width = 1)
if barstate.islast
// Use just:
table.set_position(monthlyTable, monthly_table_position)
if barstate.islastconfirmedhistory and show_performance and show_monthly_table
table.cell(table_id = monthlyTable, column = 0, row = 0, text = "YIL", text_color = text_head_color, text_size=monthly_table_text_size)
table.cell(table_id = monthlyTable, column = 1, row = 0, text = "OCK", text_color = text_head_color, text_size=monthly_table_text_size)
table.cell(table_id = monthlyTable, column = 2, row = 0, text = "SBT", text_color = text_head_color, text_size=monthly_table_text_size)
table.cell(table_id = monthlyTable, column = 3, row = 0, text = "MAR", text_color = text_head_color, text_size=monthly_table_text_size)
table.cell(table_id = monthlyTable, column = 4, row = 0, text = "NİS", text_color = text_head_color, text_size=monthly_table_text_size)
table.cell(table_id = monthlyTable, column = 5, row = 0, text = "MAY", text_color = text_head_color, text_size=monthly_table_text_size)
table.cell(table_id = monthlyTable, column = 6, row = 0, text = "HAZ", text_color = text_head_color, text_size=monthly_table_text_size)
table.cell(table_id = monthlyTable, column = 7, row = 0, text = "TEM", text_color = text_head_color, text_size=monthly_table_text_size)
table.cell(table_id = monthlyTable, column = 8, row = 0, text = "AUG", text_color = text_head_color, text_size=monthly_table_text_size)
table.cell(table_id = monthlyTable, column = 9, row = 0, text = "EYL", text_color = text_head_color, text_size=monthly_table_text_size)
table.cell(table_id = monthlyTable, column = 10, row = 0, text = "EKM", text_color = text_head_color, text_size=monthly_table_text_size)
table.cell(table_id = monthlyTable, column = 11, row = 0, text = "KAS", text_color = text_head_color, text_size=monthly_table_text_size)
table.cell(table_id = monthlyTable, column = 12, row = 0, text = "ARL", text_color =text_head_color, text_size=monthly_table_text_size)
table.cell(table_id = monthlyTable, column = 13, row = 0, text = "YIL P/L", text_color = text_head_color, text_size=monthly_table_text_size)
for i = 0 to (array.size(y_number_array) == 0 ? na : array.size(y_number_array) - 1)
row_y := year(array.get(y_time_array, i)) - year(array.get(y_time_array, 0)) + 1
table.cell(table_id = monthlyTable, column = 13, row = row_y, text = str.tostring(array.get(y_pnl_array , i), "##.##") + '\n' + '(' + str.tostring(array.get(y_pnl_array , i)*100/initial_balance, "##.##") + ' %)', bgcolor = array.get(y_pnl_array , i) > 0 ? profit_color : array.get(y_pnl_array , i) < 0 ? loss_color : neutral_color, text_color = data_text_color, text_size=monthly_table_text_size)
curr_row_y = array.size(month_time_array) == 0 ? 1 : (year(array.get(month_time_array, array.size(month_time_array) - 1))) - (year(array.get(month_time_array, 0))) + 1
table.cell(table_id = monthlyTable, column = 13, row = row_y >= 0 ? row_y + 1 : 1, text = str.tostring(curr_y_pnl, "##.##") + '\n' + '(' + str.tostring(curr_y_pnl*100/initial_balance, "##.##") + ' %)', bgcolor = curr_y_pnl > 0 ? profit_color : curr_y_pnl < 0 ? loss_color : neutral_color, text_color = data_text_color, text_size=monthly_table_text_size)
for i = 0 to (array.size(net_profit_array) == 0 ? na : array.size(net_profit_array) - 1)
monthly_profit := i > 0 ? (array.get(net_profit_array, i) - array.get(net_profit_array, i - 1)) : array.get(net_profit_array, i)
column_month_number := month(array.get(month_time_array, i))
row_month_time :=((year(array.get(month_time_array, i))) - year(array.get(month_time_array, 0)) ) + 1
table.cell(table_id = monthlyTable, column = column_month_number, row = row_month_time, text = str.tostring(monthly_profit, "##.##") + '\n' + '(' + str.tostring(monthly_profit*100/initial_balance, "##.##") + ' %)', bgcolor = monthly_profit > 0 ? profit_color : monthly_profit < 0 ? loss_color : neutral_color, text_color = data_text_color, text_size=monthly_table_text_size)
table.cell(table_id = monthlyTable, column = 0, row =row_month_time, text = str.tostring(year(array.get(month_time_array, i)), "##.##"), text_color = text_head_color, text_size=monthly_table_text_size)
table.cell(table_id = monthlyTable, column = curr_m_number, row = nz(row_month_time) <= 0 ? 1 : row_month_time, text = str.tostring(curr_m_pnl, "##.##") + '\n' + '(' + str.tostring(curr_m_pnl*100/initial_balance, "##.##") + ' %)', bgcolor = curr_m_pnl > 0 ? profit_color : curr_m_pnl < 0 ? loss_color : neutral_color, text_color = data_text_color, text_size=monthly_table_text_size)
table.cell(table_id = monthlyTable, column = 0, row =nz(row_month_time) <= 0 ? 1 : row_month_time, text = str.tostring(year(time), "##.##"), text_color = text_head_color, text_size=monthly_table_text_size)
//============================================================================================================================================================================
// STRATEGY PERFORMANCE TABLE LOGIC
//============================================================================================================================================================================
// Değişken tanımlamaları
var float peakEquity = na
var float maxDrawdownValue = 0.0
var float maxDrawdownPercent = 0.0
var float firstTradePrice = na
// Create performance table
var tablePerformance = table.new(position=metrics_table_position, columns=metrics_width, rows=metrics_height, border_color=border_color, border_width=2, bgcolor=bg_color, frame_color=color.rgb(71, 71, 71), frame_width=1)
// 📌 Adjust table position based on user setting
if barstate.islast
table.set_position(tablePerformance, metrics_table_position)
// 📌 Metrikler Hesaplamaları
totalTrades = strategy.closedtrades
openTrades = strategy.opentrades
closedTrades = totalTrades - openTrades
winTrades = strategy.wintrades
loseTrades = strategy.losstrades
netProfit = strategy.netprofit
initialCapital = strategy.initial_capital
netProfitPercent = (netProfit / initialCapital) * 100
profitFactor = strategy.grossloss == 0 ? na : strategy.grossprofit / strategy.grossloss
percentProfitable = totalTrades == 0 ? na : (winTrades / totalTrades) * 100
// Drawdown hesaplamaları
peakEquity := na(peakEquity) ? strategy.equity : math.max(peakEquity, strategy.equity)
drawdown = peakEquity - strategy.equity
if drawdown > maxDrawdownValue
maxDrawdownValue := drawdown
maxDrawdownPercent := (maxDrawdownValue / peakEquity) * 100
// Buy & Hold hesaplamaları
if na(firstTradePrice) and strategy.position_size != 0
firstTradePrice := close
buyHoldReturnPercent = na(firstTradePrice) ? na : ((close - firstTradePrice) / firstTradePrice) * 100
buyHoldReturnAmount = na(firstTradePrice) ? na : ((close / firstTradePrice) * initialCapital) - initialCapital
// Fill performance table
if (barstate.islast) and show_performance and show_metrics_table
// Strateji İsmi ve Mevcut Pozisyon
table.cell(tablePerformance, 0, 0, "⚙️ STRATEJİ: Kule Dönence bar bekleme", bgcolor=color.rgb(27, 27, 27, 24), text_color=text_head_color, text_size=metrics_table_text_size)
if strategy.position_size > 0
float mevcutKar = ((close - strategy.position_avg_price) / strategy.position_avg_price) * 100
table.cell(tablePerformance, 1, 0, "LONG ▲ (" + str.tostring(mevcutKar, "#.##") + "%)",
bgcolor=mevcutKar > 0 ? profit_color : loss_color, text_color=data_text_color, text_size=metrics_table_text_size)
else
table.cell(tablePerformance, 1, 0, "POZİSYON YOK", bgcolor=color.rgb(27, 27, 27), text_color=data_text_color, text_size=metrics_table_text_size)
// Net Kâr + Yüzdesi
table.cell(tablePerformance, 0, 1, "NET KAZANÇ", bgcolor=color.rgb(27, 27, 27), text_color=text_head_color, text_size=metrics_table_text_size)
table.cell(tablePerformance, 1, 1, str.tostring(netProfit, "#.##") + " TRY (" + str.tostring(netProfitPercent, "#.##") + "%)",
bgcolor=netProfit > 0 ? profit_color : loss_color, text_color=data_text_color, text_size=metrics_table_text_size)
// Maksimum Kayıp + Yüzdesi
table.cell(tablePerformance, 0, 2, "MAKS. KAYIP", bgcolor=color.rgb(27, 27, 27), text_color=text_head_color, text_size=metrics_table_text_size)
table.cell(tablePerformance, 1, 2, str.tostring(maxDrawdownValue, "#.##") + " TRY (" + str.tostring(maxDrawdownPercent, "#.##") + "%)",
bgcolor=loss_color, text_color=data_text_color, text_size=metrics_table_text_size)
// Karlılık Oranı
table.cell(tablePerformance, 0, 3, "KARLI %", bgcolor=color.rgb(27, 27, 27), text_color=text_head_color, text_size=metrics_table_text_size)
table.cell(tablePerformance, 1, 3, str.tostring(percentProfitable, "#.##") + "%",
bgcolor=neutral_color, text_color=data_text_color, text_size=metrics_table_text_size)
// Al Tut
table.cell(tablePerformance, 0, 4, "AL TUT", bgcolor=color.rgb(27, 27, 27), text_color=text_head_color, text_size=metrics_table_text_size)
table.cell(tablePerformance, 1, 4, str.tostring(buyHoldReturnAmount, "#.##") + " TRY (" + str.tostring(buyHoldReturnPercent, "#.##") + "%)",
bgcolor=buyHoldReturnAmount > 0 ? profit_color : loss_color, text_color=data_text_color, text_size=metrics_table_text_size)
// Kazanç Katsayısı
table.cell(tablePerformance, 0, 5, "KAZANÇ KTS.", bgcolor=color.rgb(27, 27, 27), text_color=text_head_color, text_size=metrics_table_text_size)
table.cell(tablePerformance, 1, 5, str.tostring(profitFactor, "#.##"),
bgcolor=neutral_color, text_color=data_text_color, text_size=metrics_table_text_size)
// Açık Pozisyonlar
table.cell(tablePerformance, 0, 6, "AÇIK PZS.", bgcolor=color.rgb(27, 27, 27), text_color=text_head_color, text_size=metrics_table_text_size)
table.cell(tablePerformance, 1, 6, str.tostring(openTrades),
bgcolor=neutral_color, text_color=data_text_color, text_size=metrics_table_text_size)
// Kapanmış Pozisyonlar
table.cell(tablePerformance, 0, 7, "KAPANMIŞ PZS.", bgcolor=color.rgb(27, 27, 27), text_color=text_head_color, text_size=metrics_table_text_size)
table.cell(tablePerformance, 1, 7, str.tostring(closedTrades),
bgcolor=neutral_color, text_color=data_text_color, text_size=metrics_table_text_size)
// Kazançlı Pozisyonlar
table.cell(tablePerformance, 0, 8, "KARLI İŞL.", bgcolor=color.rgb(27, 27, 27), text_color=text_head_color, text_size=metrics_table_text_size)
table.cell(tablePerformance, 1, 8, str.tostring(winTrades),
bgcolor=profit_color, text_color=data_text_color, text_size=metrics_table_text_size)
// Kayıplı Pozisyonlar
table.cell(tablePerformance, 0, 9, "ZARARLI İŞL.", bgcolor=color.rgb(27, 27, 27), text_color=text_head_color, text_size=metrics_table_text_size)
table.cell(tablePerformance, 1, 9, str.tostring(loseTrades),
bgcolor=loss_color, text_color=data_text_color, text_size=metrics_table_text_size)
//============================================================================================================================================================================
// MULTI-TIMEFRAME TREND TABLE
//============================================================================================================================================================================
// Colors for trend table (can use common settings)
bullColor = profit_color
bearColor = loss_color
neutralColor = color.gray
// Function to get signals from other timeframes
getTrendSignal(timeframe) =>
rsiOther = request.security(syminfo.tickerid, timeframe, ta.rsi(close, 14), barmerge.gaps_off, barmerge.lookahead_off)
stateOther = request.security(syminfo.tickerid, timeframe, state, barmerge.gaps_off, barmerge.lookahead_off)
// For current state only (no crosses yet)
signalText = stateOther == 1 ? "LONG" : stateOther == 2 ? "SHORT" : "-"
signalColor = stateOther == 1 ? bullColor : stateOther == 2 ? bearColor : neutralColor
signal = stateOther
[signal, signalColor, signalText]
// Get signals for different timeframes
[signal2m, color2m, text2m] = getTrendSignal("2")
[signal15m, color15m, text15m] = getTrendSignal("15")
[signal30m, color30m, text30m] = getTrendSignal("30")
[signal1h, color1h, text1h] = getTrendSignal("60")
[signal4h, color4h, text4h] = getTrendSignal("240")
[signal1d, color1d, text1d] = getTrendSignal("D")
// Create the trend table with adjusted position and size
var trendTable = table.new(trend_table_position, trend_width, trend_height, border_width=1, border_color=border_color, bgcolor=bg_color)
// Update table position based on user setting
if barstate.islast
table.set_position(trendTable, trend_table_position)
// Update trend table on bar close
if barstate.islast and show_performance and show_trend_table
// Table headers
table.cell(trendTable, 0, 0, "2m", bgcolor=color.new(color.blue, 100), text_color=text_head_color, text_size=trend_table_text_size)
table.cell(trendTable, 1, 0, "15m", bgcolor=color.new(color.blue, 100), text_color=text_head_color, text_size=trend_table_text_size)
table.cell(trendTable, 2, 0, "30m", bgcolor=color.new(color.blue, 100), text_color=text_head_color, text_size=trend_table_text_size)
table.cell(trendTable, 3, 0, "1h", bgcolor=color.new(color.blue, 100), text_color=text_head_color, text_size=trend_table_text_size)
table.cell(trendTable, 4, 0, "4h", bgcolor=color.new(color.blue, 100), text_color=text_head_color, text_size=trend_table_text_size)
table.cell(trendTable, 5, 0, "D", bgcolor=color.new(color.blue, 100), text_color=text_head_color, text_size=trend_table_text_size)
// Signal cells
table.cell(trendTable, 0, 1, text2m, bgcolor=color.new(color2m, 100), text_color=color2m, text_size=trend_table_text_size)
table.cell(trendTable, 1, 1, text15m, bgcolor=color.new(color15m, 100), text_color=color15m, text_size=trend_table_text_size)
table.cell(trendTable, 2, 1, text30m, bgcolor=color.new(color30m, 100), text_color=color30m, text_size=trend_table_text_size)
table.cell(trendTable, 3, 1, text1h, bgcolor=color.new(color1h, 100), text_color=color1h, text_size=trend_table_text_size)
table.cell(trendTable, 4, 1, text4h, bgcolor=color.new(color4h, 100), text_color=color4h, text_size=trend_table_text_size)
table.cell(trendTable, 5, 1, text1d, bgcolor=color.new(color1d, 100), text_color=color1d, text_size=trend_table_text_size)
// Kullanıcıdan sembol girişleri
// Tabloyu göster/gizle düğmesi
string s01 = syminfo.ticker // Mevcut grafikteki sembol kullanılır
frame_color1 = #000000
frame_width1 = 2
// Parametreler
lookbackPeriod = input.int(23, title="Gün Sayısı(Coinler için 30 deneyin)", group="HACİM TABLOSU", inline="THC")
// Tablo boyutu için kullanıcı girişi
tableSize = input.string("normal", title=" Hacim Tablo Boyutu", options=["tiny", "small", "normal", "large"], group=' Tablo Ayarları', inline="THC")
// Tablo konumu için kullanıcı girişi
tablePosition1 = input.string("top_right", title="Konum", options=["top_left", "top_center", "top_right", "bottom_left", "bottom_center", "bottom_right"], group=' Tablo Ayarları', inline="THC")
// Tablo stil ayarları - sabit değerler
tableBgColor1 = #000000
tableBorderColor1 = color.orange
tableBorderWidth1 = 2
// Renk seçenekleri - sabit değerler
headerColor = color.new(color.black, 0)
buyColor = #4caf4f69
sellColor = #ff525279
resultBuyColor = #4caf4f70
resultSellColor = #ff525260
textColor = color.white
// Hücre boyutlarını belirleme fonksiyonu
getFontSize(size) =>
switch size
"tiny" => size.tiny
"small" => size.small
"normal" => size.normal
"large" => size.large
// Hacim hesaplama fonksiyonu
calculateVolumes(closeData, volumeData) =>
float upVolumeSum = 0.0
float downVolumeSum = 0.0
for i = 0 to lookbackPeriod - 1
upVolumeSum += (closeData[i] > closeData[i + 1] ? volumeData[i] : 0)
downVolumeSum += (closeData[i] < closeData[i + 1] ? volumeData[i] : 0)
totalVolume = upVolumeSum + downVolumeSum
result = upVolumeSum > downVolumeSum ? "Pozitif" : "Negatif"
[upVolumeSum, downVolumeSum, result]
// Mevcut sembol için hacim hesaplaması
[up1, down1, res1] = calculateVolumes(close, volume)
// Tablo oluştur
var table volumeTable = na
if showTable
if na(volumeTable)
volumeTable := table.new(position=tablePosition1, columns=4, rows=2, bgcolor=tableBgColor1, border_color=tableBorderColor1, border_width=tableBorderWidth1, frame_color=frame_color1, frame_width=frame_width1)
// Başlık satırı
if bar_index == 0
table.cell(volumeTable, 0, 0, "Hacim Analizi", bgcolor=headerColor, text_color=textColor, text_size=getFontSize(tableSize))
table.cell(volumeTable, 1, 0, "Alış Hacmi", bgcolor=headerColor, text_color=textColor, text_size=getFontSize(tableSize))
table.cell(volumeTable, 2, 0, "Satış Hacmi", bgcolor=headerColor, text_color=textColor, text_size=getFontSize(tableSize))
table.cell(volumeTable, 3, 0, "Sonuç", bgcolor=headerColor, text_color=textColor, text_size=getFontSize(tableSize))
// Mevcut sembol verilerini tabloya ekle
table.cell(volumeTable, 0, 1, s01, text_color=textColor, text_size=getFontSize(tableSize))
table.cell(volumeTable, 1, 1, str.tostring(up1, format.volume), bgcolor=buyColor, text_color=textColor, text_size=getFontSize(tableSize))
table.cell(volumeTable, 2, 1, str.tostring(down1, format.volume), bgcolor=sellColor, text_color=textColor, text_size=getFontSize(tableSize))
table.cell(volumeTable, 3, 1, res1, bgcolor=res1 == "Pozitif" ? resultBuyColor : resultSellColor, text_color=textColor, text_size=getFontSize(tableSize))
else
if not na(volumeTable)
table.delete(volumeTable)
volumeTable := na
// // ========== Trend Gücü Hesaplaması ==========
// // Trend yönü ve gücü için değişkenler
// var float trendStrength = 0.0
// var int trendDirection = 0 // 0: Nötr, 1: Yükseliş, -1: Düşüş
// var float entryPrice = na
// var float maxStrength = 100.0
// // Yeni trend başladığında güç seviyesini ve giriş fiyatını sıfırla
// if (bullcross)
// trendDirection := 1
// entryPrice := close
// trendStrength := 20.0 // Başlangıç değeri
// else if (bearcross)
// trendDirection := -1
// entryPrice := close
// trendStrength := 20.0 // Başlangıç değeri
// // Yükseliş trendi için güç hesaplaması
// if (trendDirection == 1)
// // RSI bazlı bileşen
// rsiComponent = math.max(0, rsi - 50) / 50 * 30 // RSI 50-100 arasında 0-30 puana katkıda bulunur
// // Fiyat ilerleme bazlı bileşen
// priceProgress = 0.0
// if (not na(entryPrice) and not na(ATRbulltp1))
// if (close < ATRbulltp1)
// // Giriş ile TP1 arasında
// priceProgress := (close - entryPrice) / (ATRbulltp1 - entryPrice) * 40
// else if (close < ATRbulltp2)
// // TP1 ile TP2 arasında
// priceProgress := 40 + (close - ATRbulltp1) / (ATRbulltp2 - ATRbulltp1) * 40
// else
// // TP2'nin üzerinde
// priceProgress := 80 + math.min(20, (close - ATRbulltp2) / ATRbulltp2 * 20)
// // Momentumu ölç (fiyatın son n bar'daki değişimi)
// momentumWindow = 5
// momentumComponent = math.max(-10, math.min(10, (close - close[momentumWindow]) / close[momentumWindow] * 100))
// // Final güç hesaplaması
// trendStrength := math.max(0, math.min(maxStrength, rsiComponent + priceProgress + momentumComponent))
// // Düşüş trendi güç hesaplaması (bu stratejide sadece uzun pozisyonlar kullanıldığı için basit tuttum)
// else if (trendDirection == -1)
// // RSI bazlı bileşen (düşüş trendinde düşük RSI daha güçlü trend gösterir)
// rsiComponent = math.max(0, 50 - rsi) / 50 * 30 // RSI 0-50 arasında 0-30 puana katkıda bulunur
// // Momentum bileşeni
// momentumWindow = 5
// momentumComponent = math.max(-10, math.min(10, (close[momentumWindow] - close) / close[momentumWindow] * 100))
// // Final güç hesaplaması
// trendStrength := math.max(0, math.min(maxStrength, rsiComponent + 30 + momentumComponent)) // Sabit 30 değeri trend geçişi için
// // ========== Görsel Gösterim ==========
// // Durum değişimlerini gösterme
// plotshape(bullcross, title="Yükseliş Trend Başlangıcı", location=location.belowbar, color=color.green, style=shape.triangleup, size=size.small)
// plotshape(bearcross, title="Düşüş Trend Başlangıcı", location=location.abovebar, color=color.red, style=shape.triangledown, size=size.small)
// // ========== Bilgi Paneli ==========
// var tbl = table.new(position.middle_right, 1, 4, bgcolor=color.rgb(0, 0, 0, 85), border_width=2, border_color=color.white)
// // Renk değişkenleri (daha koyu tonlar)
// var color bullColorDark = color.rgb(0, 100, 0) // Koyu yeşil
// var color bearColorDark = color.rgb(139, 0, 0) // Koyu kırmızı
// var color neutralColorDark = color.rgb(50, 50, 50) // Koyu gri
// var color bullTextColor = color.rgb(200, 255, 200) // Açık yeşil metin
// var color bearTextColor = color.rgb(255, 200, 200) // Açık kırmızı metin
// var color headerBgColor = color.rgb(25, 25, 50) // Koyu mavi arka plan
// // Tabloyu her bar için güncelle
// if (barstate.islast)
// // Trend durumu
// trendText = trendDirection == 1 ? "YÜKSELİŞ TRENDİ" : trendDirection == -1 ? "DÜŞÜŞ TRENDİ" : "TREND YOK"
// trendStatusColor = trendDirection == 1 ? bullColorDark :
// trendDirection == -1 ? bearColorDark : neutralColorDark
// trendTextColor = trendDirection == 1 ? bullTextColor :
// trendDirection == -1 ? bearTextColor : color.white
// // TP mesafesi bilgisi
// tpInfoText = ""
// if (trendDirection == 1 and not na(entryPrice))
// if (close < ATRbulltp1)
// // TP1'e olan ilerleme - daha basit hesaplama
// entryToTP1 = ATRbulltp1 - entryPrice
// currentProgress = close - entryPrice
// progressPercent = entryToTP1 > 0 ? (currentProgress / entryToTP1) * 100 : 0
// tpInfoText := "TP1: %" + str.tostring(math.round(progressPercent))
// else if (close < ATRbulltp2)
// // TP1 seviyesi zaten geçilmiş, TP2'ye ilerleme yüzdesi
// tp1ToTP2 = ATRbulltp2 - ATRbulltp1
// currentProgress = close - ATRbulltp1
// progressPercent = tp1ToTP2 > 0 ? (currentProgress / tp1ToTP2) * 100 : 0
// tpInfoText := "TP2: %" + str.tostring(math.round(progressPercent))
// else
// // TP2 seviyesi de geçilmiş
// excessPercent = ((close - ATRbulltp2) / ATRbulltp2) * 100
// tpInfoText := "TP2+: %" + str.tostring(math.round(excessPercent))
// // Trend gücü kategorisi
// strengthText = trendStrength < 20 ? "ÇOK ZAYIF" :
// trendStrength < 40 ? "ZAYIF" :
// trendStrength < 60 ? "ORTA" :
// trendStrength < 80 ? "GÜÇLÜ" : "ÇOK GÜÇLÜ"
// // Trend rengi
// trendColor = if (trendDirection == 1)
// if (trendStrength < 20)
// color.rgb(0, 80, 0) // Daha koyu yeşil (çok zayıf)
// else if (trendStrength < 40)
// color.rgb(0, 100, 0) // Koyu yeşil (zayıf)
// else if (trendStrength < 60)
// color.rgb(0, 120, 0) // Daha yoğun yeşil (orta)
// else if (trendStrength < 80)
// color.rgb(0, 140, 0) // Güçlü yeşil
// else
// color.rgb(0, 160, 0) // Çok güçlü yeşil
// else if (trendDirection == -1)
// if (trendStrength < 20)
// color.rgb(100, 0, 0) // Daha koyu kırmızı (çok zayıf)
// else if (trendStrength < 40)
// color.rgb(120, 0, 0) // Koyu kırmızı (zayıf)
// else if (trendStrength < 60)
// color.rgb(140, 0, 0) // Daha yoğun kırmızı (orta)
// else if (trendStrength < 80)
// color.rgb(160, 0, 0) // Güçlü kırmızı
// else
// color.rgb(180, 0, 0) // Çok güçlü kırmızı
// else
// neutralColorDark
// // Tablo hücrelerini güncelle
// table.cell(tbl, 0, 0, "TREND GÜCÜ ÖLÇER", text_color=color.white, bgcolor=headerBgColor, text_size=size.normal)
// table.cell(tbl, 0, 1, trendText, text_color=trendTextColor, bgcolor=trendStatusColor, text_size=size.normal)
// table.cell(tbl, 0, 2, "Güç: " + str.tostring(math.round(trendStrength)) + "/100 - " + strengthText,
// text_color=trendTextColor, bgcolor=trendColor, text_size=size.normal)
// table.cell(tbl, 0, 3, tpInfoText, text_color=color.white, bgcolor=color.rgb(40, 40, 0), text_size=size.normal)
//@strategy_alert_message {{strategy.order.alert_message}}Editor is loading...
Leave a Comment