Untitled
unknown
plain_text
2 months ago
31 kB
3
Indexable
//@version=5 //@strategy_alert_message {{strategy.order.alert_message}} strategy('Kule Dönence Str TP' , shorttitle = 'Kule Dönence Str TP' , overlay = true) // , initial_capital = 10000 // , default_qty_type = strategy.fixed // , default_qty_value = 500 // , pyramiding = 0 // , commission_value = 0.03 // , commission_type = strategy.commission.percent) tutar = input.float(title="Tutar (TL)", defval=10000, minval=1) var float islemLotu = na var float sonGirisLotu = na var int pozisyonDurumu = 0 lotHesapla() => math.floor(tutar / close) 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) fastLength = 12 slowLength = 26 signalLength = 9 [macdLine, signalLine, _] = ta.macd(close, fastLength, slowLength, signalLength) macdAboveZero = macdLine > signalLine // ------------------------- 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 //-----------------3 State RSI Gradient Bar Color on Chart--------------------// 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) // RSI 50 Line // @ LazyBear obLevelM = 50 src = close length = 14 ep = 2 * length - 1 auc = ta.ema(math.max(src - src[1], 0), ep) adc = ta.ema(math.max(src[1] - src, 0), ep) x7 = (length - 1) * (adc * obLevelM / (100 - obLevelM) - auc) ub4 = x7 >= 0 ? src + x7 : src + x7 * (100 - obLevelM) / obLevelM // plot(ub4, title='Rsn Mov', color=color.new(ub4>ub4[1]?color.green:ub4<ub4[1]?color.red:color.white, 25), linewidth=3,display = display.none) // ---------------------------- Trade Setup --------------------------------- // // Inspired by @ KioseffTrading lot_size = 1 dcaorstop = "DCA 3" // Number of Decimals for Labels pricedecimals= 2 truncateprice(number, pricedecimals) => factor = math.pow(10, pricedecimals) int(number * factor) / factor // 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 shortBar1 = ta.barssince(short_last) shortBar2 = shortBar1 >= 1 ? true : false // Wen entry, sir? bullentry = ta.valuewhen(bullcross, close, 0) bearentry = ta.valuewhen(bearcross, close, 0) entin= state==1 and long_short==1?bullentry:state==2 and long_short==-1?bearentry:na // entout=plot(entin, 'Giriş', color=color.new(color.green, 0), style=plot.style_circles, editable=false) // Targets // ATR TP & SL // 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 = 55 per = atrPeriod // ATR çarpanı atrMultiplier = 3.5 // 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) ATRupper5=srcATR + atr * (atrMultiplier*0.5) ATRlower5=srcATR - atr * (atrMultiplier*0.5) ATRupper6=srcATR + atr * (atrMultiplier*0.382) ATRlower6=srcATR - atr * (atrMultiplier*0.382) ATRupper7=srcATR + atr * (atrMultiplier*0.236) ATRlower7=srcATR - atr * (atrMultiplier*0.236) ATRupper8=srcATR + atr * (atrMultiplier*0.146) ATRlower8=srcATR - atr * (atrMultiplier*0.146) bearse=srcATR + atr * (atrMultiplier*0.146) bullse=srcATR - atr * (atrMultiplier*0.146) bearse2=srcATR + atr * (atrMultiplier*0.236) bullse2=srcATR - atr * (atrMultiplier*0.236) 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) ATRbulltp5=ta.valuewhen(bullcross,ATRupper5,0) ATRbeartp5=ta.valuewhen(bearcross,ATRlower5,0) ATRbulltp6=ta.valuewhen(bullcross,ATRupper6,0) ATRbeartp6=ta.valuewhen(bearcross,ATRlower6,0) ATRbulltp7=ta.valuewhen(bullcross,ATRupper7,0) ATRbeartp7=ta.valuewhen(bearcross,ATRlower7,0) ATRbulltp8=ta.valuewhen(bullcross,ATRupper8,0) ATRbeartp8=ta.valuewhen(bearcross,ATRlower8,0) vwbearse=ta.valuewhen(bearcross,bearse,0) vwbullse=ta.valuewhen(bullcross,bullse,0) vwbearse2=ta.valuewhen(bearcross,bearse2,0) vwbullse2=ta.valuewhen(bullcross,bullse2,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) // Trade Setup Labels // Profit bullt1profit=(((ATRbulltp1/bullentry)- 1)*100) beart1profit=((1-(bearentry/ATRbeartp1))*-100) bullt2profit=(((ATRbulltp2/bullentry)- 1)*100) beart2profit=((1-(bearentry/ATRbeartp2))*-100) bullt3profit=(((ATRbulltp3/bullentry)- 1)*100) beart3profit=((1-(bearentry/ATRbeartp3))*-100) bullt4profit=(((ATRbulltp4/bullentry)- 1)*100) beart4profit=((1-(bearentry/ATRbeartp4))*-100) bullt5profit=(((ATRbulltp5/bullentry)- 1)*100) beart5profit=((1-(bearentry/ATRbeartp5))*-100) bullt6profit=(((ATRbulltp6/bullentry)- 1)*100) beart6profit=((1-(bearentry/ATRbeartp6))*-100) bullt7profit=(((ATRbulltp7/bullentry)- 1)*100) beart7profit=((1-(bearentry/ATRbeartp7))*-100) bullt8profit=(((ATRbulltp8/bullentry)- 1)*100) beart8profit=((1-(bearentry/ATRbeartp8))*-100) bullstopp = ((vwbullse3 - bullentry)/bullentry)*100 bearstopp = ((bearentry - vwbearse3)/bearentry)*100 bulltpp = ((ATRbulltp1 - bullentry)/bullentry)*100 beartpp = ((bearentry - ATRbeartp1)/bearentry)*100 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 = input.float(title = 'Sensitive', step = 0.1, defval = 10) * 10 start_date = input.time(defval = timestamp("1 June 2023"), title = "Start calculating date") // 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 >= start_date 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 = 3, title="IMBA Trend Line", display = display.none) ///////////////////////////////////////////////////// // Mevcut Barın Zamanı currentTime = time // Strateji sadece belirtilen tarih aralığında çalışacak isInDateRange = (currentTime >= startDate and currentTime <= endDate) ////////////////////////////////////////////////////////////////// TİMUR İNCİ ////////////////////////////////////////////////////////////////////////////////////// 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 stopLevel = ta.valuewhen(bullcross, vwbullse2, 0) // Stop için vwbullse3 (ATR 0.5) 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 stopHit = ta.crossunder(low, stopLevel) and positionActive and longBar2 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) if (isInDateRange and bullcross and not positionActive) and barstate.isconfirmed 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 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 = 500) // p_tp2 = plot(positionActive ? tp2Level : na, "TP2 Seviyesi", color=color.new(color.blue, 0), style=plot.style_line, linewidth=2,show_last = 500) // p_tp3 = plot(positionActive ? tp3Level : na, "TP3 Seviyesi", color=color.new(color.purple, 0), style=plot.style_line, linewidth=2,show_last = 500) if (barstate.islast) label.new(bar_index, tp1Level, "TP1 ", style=label.style_label_left, color=color.green, textcolor=color.white) label.new(bar_index, tp2Level, "TP2 ", style=label.style_label_left, color=color.blue, textcolor=color.white) // label.new(bar_index, tp3Level, "TP3 ", style=label.style_label_left, color=color.purple, textcolor=color.white) ////////////////////////////////////////////////////////////////// TİMUR İNCİ ////////////////////////////////////////////////////////////////////////////////////// // Copy below code to end of the desired strategy script /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // monthly pnl performance by Dr. Maurya @MAURYA_ALGO_TRADER // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// show_performance = input.bool(true, 'AYLIK PERFORMANS TABLOSU ?', group='AYLIK Performance') dash_loc_mp = input.session("Bottom Right","Location" ,options=["Top Right","Bottom Right","Top Left","Bottom Left", "Middle Right","Bottom Center"] ,group='AYLIK Performance', inline = "performance") text_size_mp = input.session('Small',"Size" ,options=["Tiny","Small","Normal","Large"] ,group='AYLIK Performance', inline = "performance") bg_c = input.color( color.rgb(91, 91, 94, 38), "Background Color", group='AYLIK Performance') text_head_color = input.color( #ffffff, "Month/Year Heading Color", group='AYLIK Performance') tab_month_c = input.color( color.white, "Month PnL Data Color", group='AYLIK Performance') tab_year_c = input.color( color.rgb(0,0,0), "Year PnL Data Color", group='AYLIK Performance') border_c = input.color( color.white, "Table Border Color", group='AYLIK Performance') var table_position_mp = dash_loc_mp == 'Bottom Left' ? position.bottom_left : dash_loc_mp == 'Bottom Left' ? position.bottom_left : dash_loc_mp == 'Middle Right' ? position.middle_right : dash_loc_mp == 'Bottom Center' ? position.bottom_center : dash_loc_mp == 'Top Right' ? position.top_right : position.bottom_right var table_text_size_mp = text_size_mp == 'Tiny' ? size.tiny : text_size_mp == 'Small' ? size.small : text_size_mp == 'Normal' ? size.normal : size.large ///////////////// ///////////////////////////////////////////// // 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 var testTable = table.new(position = table_position_mp, columns = 14, rows = 40, bgcolor = bg_c, border_color = border_c, border_width = 1) if barstate.islastconfirmedhistory and show_performance table.cell(table_id = testTable, column = 0, row = 0, text = "YIL", text_color = text_head_color, text_size=table_text_size_mp) table.cell(table_id = testTable, column = 1, row = 0, text = "OCK", text_color = text_head_color, text_size=table_text_size_mp) table.cell(table_id = testTable, column = 2, row = 0, text = "SBT", text_color = text_head_color, text_size=table_text_size_mp) table.cell(table_id = testTable, column = 3, row = 0, text = "MAR", text_color = text_head_color, text_size=table_text_size_mp) table.cell(table_id = testTable, column = 4, row = 0, text = "NİS", text_color = text_head_color, text_size=table_text_size_mp) table.cell(table_id = testTable, column = 5, row = 0, text = "MAY", text_color = text_head_color, text_size=table_text_size_mp) table.cell(table_id = testTable, column = 6, row = 0, text = "HAZ", text_color = text_head_color, text_size=table_text_size_mp) table.cell(table_id = testTable, column = 7, row = 0, text = "TEM", text_color = text_head_color, text_size=table_text_size_mp) table.cell(table_id = testTable, column = 8, row = 0, text = "AUG", text_color = text_head_color, text_size=table_text_size_mp) table.cell(table_id = testTable, column = 9, row = 0, text = "EYL", text_color = text_head_color, text_size=table_text_size_mp) table.cell(table_id = testTable, column = 10, row = 0, text = "EKM", text_color = text_head_color, text_size=table_text_size_mp) table.cell(table_id = testTable, column = 11, row = 0, text = "KAS", text_color = text_head_color, text_size=table_text_size_mp) table.cell(table_id = testTable, column = 12, row = 0, text = "ARL", text_color =text_head_color, text_size=table_text_size_mp) table.cell(table_id = testTable, column = 13, row = 0, text = "YIL P/L", text_color = text_head_color, text_size=table_text_size_mp) 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 = testTable, 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 ? color.green : array.get(y_pnl_array , i) < 0 ? color.red : color.gray, text_color = tab_year_c, text_size=table_text_size_mp) 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 = testTable, 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 ? color.green : curr_y_pnl < 0 ? color.red : color.gray, text_color = tab_year_c, text_size=table_text_size_mp) 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 = testTable, 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 ? color.green : monthly_profit < 0 ? color.red : color.gray, text_color = tab_month_c, text_size=table_text_size_mp) table.cell(table_id = testTable, column = 0, row =row_month_time, text = str.tostring(year(array.get(month_time_array, i)), "##.##"), text_color = text_head_color, text_size=table_text_size_mp) // curr_row_m = 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 = testTable, 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 ? color.green : curr_m_pnl < 0 ? color.red : color.gray, text_color = tab_month_c, text_size=table_text_size_mp) table.cell(table_id = testTable, column = 0, row =nz(row_month_time) <= 0 ? 1 : row_month_time, text = str.tostring(year(time), "##.##"), text_color = text_head_color, text_size=table_text_size_mp) //============================================================================================================================================================================ // Kullanıcı Ayarı - Tabloyu Göster/Gizle show_table = input.bool(defval=true, title="Tabloyu Göster") // Değişken tanımlamaları var float peakEquity = na var float maxDrawdownValue = 0.0 var float maxDrawdownPercent = 0.0 var float firstTradePrice = na var table tablePerformance = table.new(position=position.bottom_right, columns=2, rows=10, border_color=color.gray, border_width=2, bgcolor=color.rgb(0, 0, 0), frame_color=color.rgb(71, 71, 71), frame_width=1) // 📌 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 : math.abs(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 := (drawdown / 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 // Eğer yeni bir maksimum kayıp oluşursa güncelle if drawdown > maxDrawdownValue maxDrawdownValue := drawdown maxDrawdownPercent := (maxDrawdownValue / peakEquity) * 100 // Yüzde olarak hesapla // 🔹 **Buy & Hold Getirisi (Tutar ve Yüzde)** if na(firstTradePrice) and strategy.position_size != 0 firstTradePrice := close // İlk işlem anındaki kapanış fiyatını al // Tabloya Ekleme if (bar_index % 5 == 0) and show_table // Strateji İsmi table.cell(tablePerformance, 0, 0, "⚙️ STRATEJİ: Kule 2TP ORJ", bgcolor=color.rgb(27, 27, 27), text_color=color.white) // Net Kâr + Yüzdesi table.cell(tablePerformance, 0, 1, "NET KAZANÇ", bgcolor=color.rgb(27, 27, 27), text_color=color.white) table.cell(tablePerformance, 1, 1, str.tostring(netProfit, "#.##") + " TRY (" + str.tostring(netProfitPercent, "#.##") + "%)", bgcolor=netProfit > 0 ? color.rgb(0, 150, 0) : color.rgb(150, 0, 0), text_color=color.white) // Maksimum Kayıp + Yüzdesi table.cell(tablePerformance, 0, 2, "MAKS. KAYIP", bgcolor=color.rgb(27, 27, 27), text_color=color.white) table.cell(tablePerformance, 1, 2, str.tostring(maxDrawdownValue, "#.##") + " TRY (" + str.tostring(maxDrawdownPercent, "#.##") + "%)", bgcolor=color.rgb(150, 0, 0), text_color=color.white) // Karlılık Oranı table.cell(tablePerformance, 0, 3, "KARLI %", bgcolor=color.rgb(27, 27, 27), text_color=color.white) table.cell(tablePerformance, 1, 3, str.tostring(percentProfitable, "#.##") + "%", bgcolor=color.rgb(0, 0, 150), text_color=color.white) // Al Tut table.cell(tablePerformance, 0, 4, "AL TUT", bgcolor=color.rgb(27, 27, 27), text_color=color.white) table.cell(tablePerformance, 1, 4, str.tostring(buyHoldReturnAmount, "#.##") + " TRY (" + str.tostring(buyHoldReturnPercent, "#.##") + "%)", bgcolor=buyHoldReturnAmount > 0 ? color.rgb(0, 150, 0) : color.rgb(150, 0, 0), text_color=color.white) // Kazanç Katsayısı table.cell(tablePerformance, 0, 5, "KAZANÇ KTS.", bgcolor=color.rgb(27, 27, 27), text_color=color.white) table.cell(tablePerformance, 1, 5, str.tostring(profitFactor, "#.##"), bgcolor=color.rgb(0, 0, 150), text_color=color.white) // Açık Pozisyonlar table.cell(tablePerformance, 0, 6, "AÇIK PZS.", bgcolor=color.rgb(27, 27, 27), text_color=color.white) table.cell(tablePerformance, 1, 6, str.tostring(openTrades), bgcolor=color.rgb(0, 0, 150), text_color=color.white) // Kapanmış Pozisyonlar table.cell(tablePerformance, 0, 7, "KAPANMIŞ PZS.", bgcolor=color.rgb(27, 27, 27), text_color=color.white) table.cell(tablePerformance, 1, 7, str.tostring(closedTrades), bgcolor=color.rgb(0, 0, 150), text_color=color.white) // Kazançlı Pozisyonlar table.cell(tablePerformance, 0, 8, "KARLI İŞL.", bgcolor=color.rgb(27, 27, 27), text_color=color.white) table.cell(tablePerformance, 1, 8, str.tostring(winTrades), bgcolor=color.rgb(0, 150, 0), text_color=color.white) // Kayıplı Pozisyonlar table.cell(tablePerformance, 0, 9, "ZARARLI İŞL.", bgcolor=color.rgb(27, 27, 27), text_color=color.white) table.cell(tablePerformance, 1, 9, str.tostring(loseTrades), bgcolor=color.rgb(150, 0, 0), text_color=color.white) //@strategy_alert_message {{strategy.order.alert_message}}
Editor is loading...
Leave a Comment