Warning: Undefined array key "HTTP_ACCEPT_LANGUAGE" in /var/www/vhosts/bilgigunlugum.net/httpdocs/index.php on line 43
Pine Script Programlama

SDL3 Oyun Programlama ve Godot Oyun Motoru sayfalarımız yayında...

Ana sayfa > Borsa > Pine Script Programlama > Pine Script stratejileri > pine_script_strateji_bgtrend USD/TRY: 38.2574

Pine Script stratejileri

BG Trend stratejisi

Bu strateji ile, long ve short işlemlerin her biri için 4 farklı seçenekle işlem yapabilir, backtest zaman aralığı seçebilir, long işlemden çıkış yöntemi için gösterge short koşulu ile iz süren stop arasından birini tercih edebilirsiniz.

Stratejide, alım işlemi koşulu için, RSI göstergesi, isteğe bağlı olarak, EMA 200 ile birlikte kullanılır.

Stratejinin en avantajlı tarafı, long ve short işlemler için, RSI çizgisinin üst bant, alt bant, orta çizgi ve RSI hareketli ortalama değerlerinden birini kesmesinin kullanılabilmesidir. Böylece, kullanıcı hangi değerin karlı yüzde ve net kar yüzdelerini artıracağını görebilmektedir.

  • calc_on_every_tick=true: Bar içinde gerçek zamanlı hesaplama
  • commission_value=0.04: Komisyon yüzdesi: 0.0004 (Onbinde dört)
  • initial_capital=10000: İlk sermaye: 10000
  • default_qty_type=strategy.cash: Sermaye türü: Peşin
  • default_qty_value=10000: İşlem yapılacak sermaye: 10000

Bu ayarlar, stratejinin "Ayarlar/Özellikler" sekmesinde değiştirilebilir.

Strateji dahilinde, RSI göstergesi ile stratejiye ait ön tanımlı değerler değiştirilebilir:

  • RSI uzunluğu (Ön tanımlı değer 14)
  • RSI hareketli ortalama uzunluk değeri (Ön tanımlı değer 50)
  • RSI üst bant değeri (Ön tanımlı değer 30)
  • RSI alt bant değeri (Ön tanımlı değer 70)
  • Long koşulu için 4 farklı yöntemden birisi
  • Short koşulu için 4 farklı yöntemden birisi
  • Long işlemden çıkış yöntemi (RSI short koşulu veya iz süren stop)
  • Zarar durdur ATR periyot ve çarpan değerleri (Ön tanımlı değerleri sırasıyla 14 ve 3)
  • Backtest periyodu

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Niteya
//@version=5
// Bu strateji şablonu sadece eğitim amaçlı olarak verilmiştir. Yatırım kararlarınızda kullanmayınız.
strategy('Strategy Niteya BG Trend', shorttitle='Niteya Strategy BG Trend', overlay=true, calc_on_every_tick=true, commission_type=strategy.commission.percent, commission_value=0.04, initial_capital=10000, default_qty_type=strategy.cash, default_qty_value=10000)

var string bg_trend = 'Gösterge değerleri'
ohcl4_length = input(20, 'Trend değerlendirme uzunluğu', group=bg_trend)
is_ema1_cross_ema2 = input.bool(true, title='EMA1 ve EMA2 kesişmesini kullan', group=bg_trend)
is_td =  input.bool(false, title='Trend yönünü kullan', inline='trend', group=bg_trend)
is_trend_line = input.bool(false, title='Trend çizgisi', inline='trend', group=bg_trend)
long_trail = input.bool(true, title='Alış işleminde iz süren koşulu', group=bg_trend)
bar_no = input(15, title='Bar geçerlilik sayısı', group=bg_trend)
is_ma_lines = input.bool(true, title='MA çizgileri', group=bg_trend)
is_level_labels = input.bool(false, title='Seviye işlem etiketleri', group=bg_trend)
is_labels = input.bool(false, title='İşlem etiketleri', group=bg_trend)

var string ema_group = 'EMA değerleri'
ema_length1 = input(20, 'EMA length1', group=ema_group)
ema_length2 = input(50, 'EMA length2', group=ema_group)
ema_length3 = input(200, 'EMA length3', group=ema_group)

var string buy_sell_group = 'ATR temelli alış ve satış seviye değerleri'
buy_method = input.string(title='Satın alma yöntemi', defval='Kaynak', options=['Kaynak', 'Kullanıcı tanımlı'], group=buy_sell_group)
buy_src = input(close, 'Satın alma kaynağı', group=buy_sell_group)
buy_val = input.float(defval=0.00, title='Alış fiyatı', group=buy_sell_group)
atr_period_buy = input.int(14, 'ATR periyodu', minval=1, step=1, group=buy_sell_group)
atr_mul_stop = input.float(1.50, title='ATR çarpanı (Stop loss)', group=buy_sell_group)
atr_mul_target = input.float(3.00, title='ATR çarpanı (Satış)', group=buy_sell_group)
is_buy_lines = input.bool(false, title='Satın alma, stop loss ve satış seviye çizgileri', group=buy_sell_group)

// Hesaplamalar
EMA1 = ta.ema(close, ema_length1)
EMA2 = ta.ema(close, ema_length2)
EMA3 = ta.ema(close, ema_length3)

plot(is_ma_lines ? EMA1 : na, title='MA src1', color=color.blue, linewidth=1)
plot(is_ma_lines ? EMA2 : na, title='MA src2', color=color.orange, linewidth=2)
plot(is_ma_lines ? EMA3 : na, title='MA src3', color=color.black, linewidth=2)

ohlc4_sma = ta.sma(ohlc4, ohcl4_length)
trend_direction = close>ohlc4_sma ? 1 : close<ohlc4_sma ? -1 : 0

plot(is_trend_line ? ohlc4_sma : na, color=trend_direction==1 ? color.green : trend_direction==-1 ? color.red : color.silver, title='BG Trend', linewidth=2)

var int long_level = 0
var int short_level = 0

var float high_long = 0.00
var float low_short = 0.00

var int index_long = 0
var int index_short = 0

// Close EMA200'den büyükse ve EMA50'yi yukarı doğru kesmişse ve EMA50'nin üzerinde kapatmışsa ve bar yeşil ise  
if long_level == 0 
    if (close>EMA3 and ta.crossover(close, EMA2) and close>EMA2 and close>open)
        long_level := 1
        high_long := high
        index_long := bar_index
        label.new(is_level_labels ? bar_index : na, low, text='1', yloc=yloc.belowbar, color=color.green, style=label.style_label_up, textcolor=color.white, textalign=text.align_left) 
   
// Close EMA50'yi aşağı doğru kesmişse ve EMA50'nin altında kapatmışsa ve bar kırmızı ise
if short_level == 0 
    if (ta.crossunder(close, EMA2) and close<EMA2 and close<open)
        short_level := 1
        low_short := low
        index_short := bar_index 
        label.new(is_level_labels ? bar_index : na, low, text='1', yloc=yloc.abovebar, color=color.red, style=label.style_label_down, textcolor=color.white, textalign=text.align_left) 

// İlk koşul gerçekleşmişse ve gerçekleştiğinden bu yana bar sayısı bar_no değişken değerinden küçükse, bar endeks değeri ilk koşulun gerçekleştiği endeks 
// değerinden büyük ise ve low değeri EMA50 altında veya eşit ise veya low değeri ilk koşulun gerçekleştiği barın kapanış değerinden büyük ise
if bar_index-index_long<bar_no
    if long_level == 1 and bar_index>index_long
        if low<=EMA2 or low>close[bar_index-index_long]
            long_level := 2
            index_long := bar_index
            label.new(is_level_labels ? bar_index : na, low, text='2', yloc=yloc.belowbar, color=color.green, style=label.style_label_up, textcolor=color.white, textalign=text.align_left) 
else 
    long_level := 0
    index_long := 0

// İlk koşul gerçekleşmişse ve gerçekleştiğinden bu yana bar sayısı bar_no değişken değerinden küçükse, bar endeks değeri ilk koşulun gerçekleştiği endeks 
// değerinden büyük ise ve high değeri EMA50 üzerinde veya eşit ise veya high değeri ilk koşulun gerçekleştiği barın kapanış değerinden küçük ise
if bar_index-index_short<bar_no
    if short_level == 1 and bar_index>index_short
        if high>=EMA2 or high<close[bar_index-index_short]
            short_level := 2
            index_short := bar_index
            label.new(is_level_labels ? bar_index : na, low, text='2', yloc=yloc.abovebar, color=color.red, style=label.style_label_down, textcolor=color.white, textalign=text.align_left) 
else 
    short_level := 0
    index_short := 0

// 2. koşul gerçekleşmişse ve gerçekleştiğinden bu yana bar sayısı bar_no değişken değerinden küçükse, bar endeks değeri 2.koşulun gerçekleştiği endeks 
// değerinden büyük ise ve close değeri 1.koşulun gerçekleştiği bardaki high değerinden büyük ise, 3.koşul ve BUY koşulu sağlanmış olur.
// Close değeri bir önceki barın close değerinden küçük ise 1 ve 2. koşullar sıfırlanır.
if bar_index-index_long<bar_no
    if long_level == 2 and bar_index>index_long
        if close>high_long
            long_level := 3
        else if close<close[1] // 2.koşul gerçekleştikten sonra fiyat aşağı doğru giderse, mevcut koşulları sıfırla (Gelecek koşullar devreye girebilsin diye)
            long_level := 0
            index_long := 0
else 
    long_level := 0
    index_long := 0    

// 2. koşul gerçekleşmişse ve gerçekleştiğinden bu yana bar sayısı bar_no değişken değerinden küçükse, bar endeks değeri 2.koşulun gerçekleştiği endeks 
// değerinden büyük ise ve close değeri 1.koşulun gerçekleştiği bardaki low değerinden küçük ise, 3.koşul ve SELL koşulu sağlanmış olur.
// Close değeri bir önceki barın close değerinden büyük ise 1 ve 2. koşullar sıfırlanır.
if bar_index-index_short<bar_no
    if short_level == 2 and bar_index>index_short
        if close<low_short
            short_level := 3
        else if close>close[1] // 2.koşul gerçekleştikten sonra fiyat yukarı doğru giderse, mevcut koşulları sıfırla (Gelecek koşullar devreye girebilsin diye)
            short_level := 0
            index_short := 0            
else 
    short_level := 0
    index_short := 0  

var long_vals = 'Long işlem çıkış değerleri'
sl_method = input.string('Short', title='Çıkış yöntemi', options=['Stop loss', 'Short', 'Both'], group=long_vals)
// Zarar durdur için ATR giriş değerleri
atr_period = input.int(14, 'Zarar durdur ATR periyodu', minval=7, step=1, group=long_vals)
atr_multiplier = input.float(3, 'Zarar durdur ATR çarpanı', minval=1.5, step=0.1, group=long_vals)

// ATR hesaplama
atr_long = ta.atr(atr_period)

// İz süren stop hesaplama
stop_loss_atr = atr_multiplier * atr_long
Trail = 0.0
iff_1 = close > nz(Trail[1], 0) ? close - stop_loss_atr : close + stop_loss_atr
iff_2 = close < nz(Trail[1], 0) and close[1] < nz(Trail[1], 0) ? math.min(nz(Trail[1], 0), close + stop_loss_atr) : iff_1
Trail := close > nz(Trail[1], 0) and close[1] > nz(Trail[1], 0) ? math.max(nz(Trail[1], 0), close - stop_loss_atr) : iff_2

up_trend_1 = long_level == 3
up_trend_2 = ta.crossover(EMA1, EMA2) and close>EMA3
up_trend_cond = (is_ema1_cross_ema2 ? (up_trend_1 or up_trend_2) : up_trend_1) and (is_td ? trend_direction==1 : true) and (long_trail ? close>Trail : true)

down_trend_1 = short_level == 3
down_trend_2 = ta.crossunder(EMA1, EMA2)
down_trend_cond = (is_ema1_cross_ema2 ? (down_trend_1 or down_trend_2) : down_trend_1) and (is_td ? trend_direction==-1 : true)

bg_value = up_trend_cond ? 1 : down_trend_cond ? -1 : 0 

var bool long_ok = false
var bool short_ok = false

if bg_value==1
    if not long_ok
        label.new(is_labels ? bar_index : na, low, text=str.tostring('BUY'), yloc=yloc.belowbar, color=up_trend_1 ? color.green : color.rgb(70, 226, 23), style=label.style_label_up, textcolor=color.white, textalign=text.align_center) 
        long_ok := true
        short_ok := false
    long_level := 0
    index_long := 0
if bg_value==-1
    if not short_ok
        label.new(is_labels ? bar_index : na, low, text=str.tostring('SELL'), yloc=yloc.abovebar, color=down_trend_1 ? color.red : color.rgb(255, 121, 219), style=label.style_label_down, textcolor=color.white, textalign=text.align_center) 
        short_ok := true
        long_ok := false
    short_level := 0
    index_short := 0    

// Backtest periyodu
var backtest = 'Backtest periyodu'
StartDay = input(1, 'Başlangıç günü', group=backtest)
StartMonth = input(1, 'Başlangıç ayı', group=backtest)
StartYear = input(2021, 'Başlangıç yılı', group=backtest)
PeriodStart = timestamp(StartYear, StartMonth, StartDay, 0, 0)

StopDay = input(31, 'Bitiş günü', group=backtest)
StopMonth = input(12, 'Bitiş ayı', group=backtest)
StopYear = input(9999, 'Bitiş yılı', group=backtest)
PeriodStop = timestamp(StopYear, StopMonth, StopDay, 0, 0)

var float long_price = 0.00

var int long_no = 0
var int close_no = 0

entry_long = bg_value==1
entry_short = bg_value==-1
    
entry_price_long = ta.valuewhen(entry_long, close, 0)

stop_loss_long = Trail

exit_long = close<stop_loss_long

// Aktif periyot
var int PeriodS1 = 0
var int PeriodS2 = 0

if barstate.isfirst
    if time >= PeriodStart
        PeriodS1 := timestamp(year(time), month(time), dayofmonth(time), 0, 0)
    else
        PeriodS1 := timestamp(year(PeriodStart), month(PeriodStart), dayofmonth(PeriodStart), 0, 0)

    if last_bar_time <= PeriodStop
        PeriodS2 := timestamp(year(last_bar_time), month(last_bar_time), dayofmonth(last_bar_time), 0, 0)
    else
        PeriodS2 := timestamp(year(PeriodStop), month(PeriodStop), dayofmonth(PeriodStop), 0, 0)

// Hissenin periyot içindeki ilk ve son fiyatı
var float close_s = na
var float close_e = na

if time >= PeriodS1 and na(close_s[1])
    close_s := close
else
    close_s := close_s[1]

if time >= PeriodS2 and na(close_e[1])
    close_e := close
else
    close_e := close_e[1]

var int bar_number_period = 0
var int bar_number_long = 0

In_Period() =>
    time >= PeriodStart and time <= PeriodStop ? true : false

bar_index_o = (last_bar_index - bar_index)

if In_Period()
    if entry_long and strategy.opentrades==0 
        strategy.entry('long', strategy.long, comment='BUY' + '(' + str.tostring(bar_index_o+1) + ')')
        
        long_price := entry_price_long
        long_no += 1

    if strategy.opentrades>0 and (sl_method=='Both' ? exit_long or entry_short : (sl_method=='Stop loss' ? exit_long : entry_short))
        strategy.close('long', comment='SELL' + '(' + str.tostring(bar_index_o+1) + ')')
        
        close_no += 1
        long_price := 0.00

    bar_number_period += 1
    if long_price!=0.00
        bar_number_long += 1

plot_con = In_Period() and strategy.position_size > 0

plot(plot_con and not exit_long ? stop_loss_long : na, style=plot.style_linebr, color=color.new(color.red, 0), linewidth=1, title='Stop loss level')

price_src = buy_method=='Kaynak' ? buy_src : buy_val

tr_val_buy = na(high[1]) ? high-low : math.max(math.max(high - low, math.abs(high - close[1])), math.abs(low - close[1]))
atr_val_buy = ta.atr(atr_period_buy)

stop_price_decreased = atr_mul_stop * atr_val_buy
stop_price = price_src - stop_price_decreased
stop_rate = (100*stop_price_decreased)/price_src

target_price_increased = atr_mul_target * atr_val_buy
target_price = price_src + target_price_increased
target_rate = (100*target_price_increased)/price_src

GetWinRate(includeEvens = false) =>
	winTradeCount = strategy.wintrades + (includeEvens ? strategy.eventrades : 0)
	(winTradeCount / strategy.closedtrades) * 100

get_date(time_val) =>
    str.tostring(dayofmonth(time_val), '00') + '.' + str.tostring(month(time_val), '00') + '.' + str.tostring(year(time_val)) + ' (' + str.tostring(hour(time_val), '00') + ':' + str.tostring(minute(time_val), '00') + ':' +  str.tostring(second(time_val), '00') + ')'

cur_exchange = 'USDTRY'

bar_number = last_bar_index+1

[close_ticker_cur, close_ticker_high_cur] = request.security(syminfo.tickerid, 'D', [close[1], ta.highest(close[1], bar_number)], lookahead=barmerge.lookahead_on, currency=syminfo.currency)
[close_ticker_usd, close_ticker_high_usd] = request.security(syminfo.tickerid, 'D', [close[1], ta.highest(close[1], bar_number)], lookahead=barmerge.lookahead_on, currency='USD')

usd_cur = request.security(cur_exchange, 'D', close[1], lookahead=barmerge.lookahead_on) // Dollar exchange rate

var bool is_lines = false
var label label_ma1 = na
var label label_ma2 = na
var label label_ma3 = na

if barstate.islast
    string time_str = ''
    period = timeframe.period
    gwr = GetWinRate()       
    text_color_wr = gwr > 0 ? color.green : gwr < 0 ? color.red : color.gray 
    text_color_np = strategy.netprofit > 0 ? color.green : strategy.netprofit < 0 ? color.red : color.gray 
    text_color_single = close_e-close_s > 0 ? color.green : close_e-close_s < 0 ? color.red : color.gray 

    if is_buy_lines and not is_lines
        bar_past = bar_index[40]
        bar_past_label = bar_index[20]

        var line target_line = line.new(bar_index, target_price, bar_past, target_price, extend=extend.none, color=color.green, width=1)
        var line buy_line = line.new(bar_index, price_src, bar_past, price_src, extend=extend.none, color=color.blue, width=1)
        var line stop_line = line.new(bar_index, stop_price, bar_past, stop_price, extend=extend.none, color=color.red, width=1)

        var line atr_line_top = line.new(bar_index, price_src + atr_val_buy, bar_past, price_src + atr_val_buy, extend=extend.none, color=color.orange, width=1)
        var line atr_line_bottom = line.new(bar_index, price_src - atr_val_buy, bar_past, price_src - atr_val_buy, extend=extend.none, color=color.orange, width=1)

        linefill.new(target_line, buy_line, color=color.new(#59d68f, 50)) 
        linefill.new(buy_line, stop_line, color=color.new(#fd9292, 50)) 

        label_target = label.new(bar_past_label, target_price, text='Target: ' + str.tostring(target_price, '0.000') + ' (%' + str.tostring(target_rate, '0.000')  + ')', color=color.new(color.green, 0), style=label.style_label_center, textcolor=color.white, size=size.normal)        
        label_src = label.new(bar_past_label, price_src, text='Buy: ' + str.tostring(price_src, '0.000') + ' - Risk/Reward ratio: ' + str.tostring(target_rate/stop_rate, '0.00'), color=color.new(color.blue, 0), style=label.style_label_center, textcolor=color.white, size=size.normal)
        label_stop = label.new(bar_past_label, stop_price, text='Stop: ' + str.tostring(stop_price, '0.000') + ' (%' + str.tostring(stop_rate, '0.000')  + ')', color=color.new(color.red, 0), style=label.style_label_center, textcolor=color.white, size= size.normal)

        label_atr_top = label.new(bar_past_label, price_src + atr_val_buy, text='Top: ' + str.tostring(price_src + atr_val_buy, '0.000'), color=color.new(color.orange, 0), style=label.style_label_center, textcolor=color.white, size= size.normal)
        label_atr_bottom = label.new(bar_past_label, price_src - atr_val_buy, text='Bottom: ' + str.tostring(price_src - atr_val_buy, '0.000'), color=color.new(color.orange, 0), style=label.style_label_center, textcolor=color.white, size= size.normal)

        is_lines := true    

    tr = syminfo.currency=='TRY'
    
    switch 
        period=='1' => time_str := '1 dakika'
        period=='3' => time_str := '3 dakika'
        period=='5' => time_str := '5 dakika'
        period=='15' => time_str := '15 dakika'
        period=='30' => time_str := '30 dakika'
        period=='45' => time_str := '45 dakika'
        period=='60' => time_str := '1 saat'
        period=='120' => time_str := '2 saat'
        period=='180' => time_str := '3 saat'
        period=='240' => time_str := '4 saat'
        str.pos(period, 'D')>=0 => time_str := '1 gün'
        str.pos(period, 'W')>=0 => time_str := '1 hafta'
        str.pos(period, 'M')>=0 => time_str := '1 ay'

    var table m_table = table.new(position.middle_left, columns=5, rows=13, bgcolor=color.rgb(212, 212, 212), border_width=1, border_color=color.white)
    
    table.merge_cells(m_table, 0, 0, 4, 0)

    table.merge_cells(m_table, 3, 1, 4, 1)
    table.merge_cells(m_table, 3, 2, 4, 2)
    table.merge_cells(m_table, 3, 3, 4, 3)
    table.merge_cells(m_table, 3, 4, 4, 4)

    table.merge_cells(m_table, 3, 6, 4, 6)
    table.merge_cells(m_table, 3, 7, 4, 7)
    table.merge_cells(m_table, 3, 12, 4, 12)
    
    last_time = StopYear==9999 ? time : PeriodStop
    
    table.cell(m_table, 0, 0, 'BG Trend (' + str.tostring(dayofmonth(PeriodStart), '00') + '.' + str.tostring(month(PeriodStart), '00') + '.' + str.tostring(year(PeriodStart)) + '-' +
     str.tostring(dayofmonth(last_time), '00') + '.' + str.tostring(month(last_time), '00') + '.' + str.tostring(year(last_time)) + ')' + ' - ' + str.tostring(time_str), text_color=color.white, text_halign=text.align_center, text_size=size.normal, bgcolor=color.new(#31153a, 0))
    
    table.cell(m_table, 0, 1, 'Karlı yüzde (%)', text_color=color.rgb(244, 244, 244), text_halign=text.align_left, text_size=size.normal, bgcolor=color.orange)
    table.cell(m_table, 0, 2, 'Net kar (%)', text_color=color.rgb(244, 244, 244), text_halign=text.align_left, text_size=size.normal, bgcolor=color.orange)
    table.cell(m_table, 0, 3, 'Açılan işlemler', text_color=color.rgb(244, 244, 244), text_halign=text.align_left, text_size=size.normal, bgcolor=color.orange)
    table.cell(m_table, 0, 4, 'Kapanan işlemler', text_color=color.rgb(244, 244, 244), text_halign=text.align_left, text_size=size.normal, bgcolor=color.orange)
    table.cell(m_table, 0, 5, 'Başlangıç tarihi', text_color=color.rgb(244, 244, 244), text_halign=text.align_left, text_size=size.normal, bgcolor=color.orange)
    table.cell(m_table, 0, 6, 'Bitiş tarihi', text_color=color.rgb(244, 244, 244), text_halign=text.align_left, text_size=size.normal, bgcolor=color.orange)
    table.cell(m_table, 0, 7, 'Long/Toplam bar sayısı', text_color=color.rgb(244, 244, 244), text_halign=text.align_left, text_size=size.normal, bgcolor=color.orange)

    table.cell(m_table, 0, 8, 'İlk fiyat (Dönem başı)', text_color=color.rgb(244, 244, 244), text_halign=text.align_left, text_size=size.normal, bgcolor=color.rgb(103, 74, 31))
    table.cell(m_table, 0, 9, 'Son fiyat (Dönem sonu)', text_color=color.rgb(244, 244, 244), text_halign=text.align_left, text_size=size.normal, bgcolor=color.rgb(103, 74, 31))
    table.cell(m_table, 0, 10, 'Net kar (%)', text_color=color.rgb(244, 244, 244), text_halign=text.align_left, text_size=size.normal, bgcolor=color.rgb(103, 74, 31))
    table.cell(m_table, 0, 11, 'Net kar', text_color=color.rgb(244, 244, 244), text_halign=text.align_left, text_size=size.normal, bgcolor=color.rgb(103, 74, 31))
    table.cell(m_table, 0, 12, 'Fiyat', text_color=color.rgb(244, 244, 244), text_halign=text.align_left, text_size=size.normal, bgcolor=color.rgb(148, 107, 44))
    
    if not na(gwr)
        table.cell(m_table, 1, 1, str.tostring(gwr, '0.00'), text_color=text_color_wr, text_halign=text.align_right, text_size=size.normal, bgcolor=color.rgb(212, 212, 212))
        table.cell(m_table, 1, 2, str.tostring((100*strategy.netprofit)/strategy.initial_capital, '0.00'), text_color=text_color_np, text_halign=text.align_right, text_size=size.normal, bgcolor=color.rgb(212, 212, 212))
        table.cell(m_table, 1, 3, str.tostring(long_no), text_color=#505050, text_halign=text.align_right, text_size=size.normal, bgcolor=color.rgb(212, 212, 212))
        table.cell(m_table, 1, 4, str.tostring(strategy.closedtrades), text_color=#505050, text_halign=text.align_right, text_size=size.normal, bgcolor=color.rgb(212, 212, 212))

    table.cell(m_table, 1, 5, str.tostring(dayofmonth(PeriodS1), '00') + '.' + str.tostring(month(PeriodS1), '00') + '.' + str.tostring(year(PeriodS1)), text_color=#505050, text_halign=text.align_right, text_size=size.normal, bgcolor=color.rgb(212, 212, 212))
    table.cell(m_table, 1, 6, str.tostring(dayofmonth(PeriodS2), '00') + '.' + str.tostring(month(PeriodS2), '00') + '.' + str.tostring(year(PeriodS2)), text_color=#505050, text_halign=text.align_right, text_size=size.normal, bgcolor=color.rgb(212, 212, 212))

    table.cell(m_table, 1, 7, str.tostring(bar_number_long) + '/' + str.tostring(bar_number_period), text_color=#505050, text_halign=text.align_right, text_size=size.normal, bgcolor=color.rgb(212, 212, 212))

    np = (close_e-close_s)*(strategy.initial_capital/close_s)
    
    table.cell(m_table, 1, 8, str.tostring(close_s, '0.00'), text_color=#505050, text_halign=text.align_right, text_size=size.normal, bgcolor=color.rgb(212, 212, 212))
    table.cell(m_table, 1, 9, str.tostring(close_e, '0.00'), text_color=#505050, text_halign=text.align_right, text_size=size.normal, bgcolor=color.rgb(212, 212, 212), tooltip=str.tostring(close_e, '0.00') + ' - ' + str.tostring(volume, '0')) // volume*close
    table.cell(m_table, 1, 10, str.tostring((100*np)/strategy.initial_capital, '0.00'), text_color=text_color_single, text_halign=text.align_right, text_size=size.normal, bgcolor=color.rgb(212, 212, 212))
    table.cell(m_table, 1, 11, str.tostring(np, '0.00'), text_color=text_color_single, text_halign=text.align_right, text_size=size.normal, bgcolor=color.rgb(212, 212, 212))
    table.cell(m_table, 1, 12, str.tostring(close, '0.00'), text_color=text_color_single, text_halign=text.align_right, text_size=size.normal, bgcolor=color.rgb(212, 212, 212))

    // TL ve USD fiyat bazında fiyat tahmin tablosu
    table.cell(m_table, 2, 1, 'GEYF (TL)', text_color=color.rgb(244, 244, 244), text_halign=text.align_left, text_size=size.normal, bgcolor=color.rgb(195, 192, 13), tooltip='Geçmiş en yüksek fiyat (TL)')
    table.cell(m_table, 2, 2, 'GEYF (USD)', text_color=color.rgb(244, 244, 244), text_halign=text.align_left, text_size=size.normal, bgcolor=color.rgb(195, 192, 13), tooltip='Geçmiş en yüksek fiyat (USD)')
    table.cell(m_table, 2, 3, 'TF (TL)', text_color=color.rgb(244, 244, 244), text_halign=text.align_left, text_size=size.normal, bgcolor=color.rgb(195, 192, 13), tooltip='Tahmini fiyat (TL)')
    table.cell(m_table, 2, 4, 'Artış (%)', text_color=color.rgb(244, 244, 244), text_halign=text.align_left, text_size=size.normal, bgcolor=color.rgb(195, 192, 13))

    table.cell(m_table, 3, 1, str.tostring(close_ticker_high_cur, '0.000'), text_color=color.black, text_halign=text.align_right)
    table.cell(m_table, 3, 2, str.tostring(close_ticker_high_usd, '0.000'), text_color=color.green, text_halign=text.align_right)
    table.cell(m_table, 3, 3, str.tostring(close_ticker_high_usd * usd_cur, '0.000'), text_color=color.rgb(3, 57, 204), text_halign=text.align_right)
    table.cell(m_table, 3, 4, str.tostring(((100*close_ticker_high_usd*usd_cur)/close_ticker_cur)-100, '0.000'), text_color=color.orange, text_halign=text.align_right)

    // ATR and Buy position values
    table.cell(m_table, 2, 5, 'Seviye', text_color=color.rgb(244, 244, 244), text_halign=text.align_left, text_size=size.normal, bgcolor=color.rgb(134, 132, 8))    
    table.cell(m_table, 3, 5, 'Stop', text_color=color.rgb(244, 244, 244), text_halign=text.align_center, bgcolor=color.red)
    table.cell(m_table, 4, 5, 'Hedef', text_color=color.rgb(244, 244, 244), text_halign=text.align_center, bgcolor=color.green)    

    table.cell(m_table, 2, 6, 'ATR', text_color=color.rgb(244, 244, 244), text_halign=text.align_left, text_size=size.normal, bgcolor=color.rgb(134, 132, 8))    
    table.cell(m_table, 2, 7, 'Alış fiyatı', text_color=color.rgb(244, 244, 244), text_halign=text.align_left, bgcolor=color.rgb(134, 132, 8))
    table.cell(m_table, 2, 8, 'ATR çarpanı', text_color=color.rgb(244, 244, 244), text_halign=text.align_left, bgcolor=color.rgb(134, 132, 8))
    table.cell(m_table, 2, 9, 'Miktar', text_color=color.rgb(244, 244, 244), text_halign=text.align_left, bgcolor=color.rgb(134, 132, 8), tooltip='Stop loss fiyat hesaplaması için alış fiyatından çıkartılan veya hedef fiyat hesaplaması için alış fiyatına eklenen miktar')
    table.cell(m_table, 2, 10, 'Fiyat', text_color=color.rgb(244, 244, 244), text_halign=text.align_left, bgcolor=color.rgb(134, 132, 8), tooltip='Stop loss veya hedef fiyatı')
    table.cell(m_table, 2, 11, 'Oran (%)', text_color=color.rgb(244, 244, 244), text_halign=text.align_left, bgcolor=color.rgb(134, 132, 8), tooltip='Stop loss fiyat hesaplaması için alış fiyatından çıkartılan veya hedef fiyat hesaplaması için alış fiyatına eklenen oran')
    table.cell(m_table, 2, 12, 'Risk/Ödül oranı', text_color=color.rgb(244, 244, 244), text_halign=text.align_left, bgcolor=color.rgb(134, 132, 8))

    table.cell(m_table, 3, 6, str.tostring(atr_val_buy, '0.000'), text_halign=text.align_center)    
    table.cell(m_table, 3, 7, str.tostring(price_src, '0.000'), text_halign=text.align_center, bgcolor=color.rgb(255, 181, 237))

    table.cell(m_table, 3, 8, str.tostring(atr_mul_stop, '0.000'), text_halign=text.align_center)
    table.cell(m_table, 3, 9, str.tostring(stop_price_decreased, '0.000'), text_halign=text.align_right, tooltip=str.tostring(atr_mul_stop, '0.000') + ' * ' + str.tostring(atr_val_buy, '0.000'))
    table.cell(m_table, 3, 10, str.tostring(stop_price, '0.000'), text_halign=text.align_right, tooltip=str.tostring(price_src, '0.000') + ' - ' + str.tostring(stop_price_decreased, '0.000'))
    table.cell(m_table, 3, 11, str.tostring(stop_rate, '0.000'), text_halign=text.align_right, bgcolor=color.rgb(255, 181, 237), tooltip='(100 * ' + str.tostring(stop_price_decreased, '0.000') + ') / ' + str.tostring(price_src, '0.000'))

    table.cell(m_table, 4, 8, str.tostring(atr_mul_target, '0.000'), text_halign=text.align_right)
    table.cell(m_table, 4, 9, str.tostring(target_price_increased, '0.000'), text_halign=text.align_right, tooltip=str.tostring(atr_mul_target, '0.000') + ' * ' + str.tostring(atr_val_buy, '0.000'))
    table.cell(m_table, 4, 10, str.tostring(target_price, '0.000'), text_halign=text.align_right, tooltip=str.tostring(price_src, '0.000') + ' + ' + str.tostring(target_price_increased, '0.000'))
    table.cell(m_table, 4, 11, str.tostring(target_rate, '0.000'), text_halign=text.align_right, bgcolor=color.rgb(255, 181, 237), tooltip='(100 * ' + str.tostring(target_price_increased, '0.000') + ') / '+ str.tostring(price_src, '0.000'))

    table.cell(m_table, 3, 12, str.tostring(target_rate/stop_rate, '0.00'), text_halign=text.align_center, tooltip=str.tostring(target_rate, '0.00') + ' / ' + str.tostring(stop_rate, '0.00'))

    if is_ma_lines

        label.delete(label_ma1) 
        label.delete(label_ma2) 
        label.delete(label_ma3) 
 
        label_ma1 := label.new(x=bar_index+2, y=EMA1, text=str.tostring(ema_length1), color=color.blue, style=label.style_label_center, textcolor=color.white, size=size.small)         
        label_ma2 := label.new(x=bar_index+2, y=EMA2, text=str.tostring(ema_length2), color=color.orange, style=label.style_label_center, textcolor=color.white, size=size.small)         
        label_ma3 := label.new(x=bar_index+2, y=EMA3, text=str.tostring(ema_length3), color=color.black, style=label.style_label_center, textcolor=color.white, size=size.small) 

Yukarıdaki strateji ile ilgili bir uygulama aşağıdaki grafikte gösterilmektedir. Long işlem için, RSI değerinin hareketli ortalama değerini yukarı doğru kesmesi, short işlem RSI değerinin üst bant değerini (70) yukarı doğru kesmesi esas alınmıştır.