0 beğenilme 0 beğenilmeme
59 kez görüntülendi

tradingview için yazılmış olan aşşagıda ki kodun matriks IQ için uyarlanması mümkünmü 

 

//@version=5

strategy(title=' Alpha Trade V-13 ', overlay=true, commission_type=strategy.commission.percent, commission_value=0.025, default_qty_type=strategy.cash, default_qty_value=10000, initial_capital=10000, slippage=0)

 

// === INPUT BACKTEST RANGE ===

useDate = input(true, title='---------------- Use Date ----------------')

FromMonth = input.int(defval=7, title='From Hafta', minval=1, maxval=12)

FromDay = input.int(defval=25, title='From Gün', minval=1, maxval=31)

FromYear = input.int(defval=2019, title='From Yıl', minval=2017)

ToMonth = input.int(defval=1, title='To Ay', minval=1, maxval=12)

ToDay = input.int(defval=1, title='To Gün', minval=1, maxval=31)

ToYear = input.int(defval=9999, title='To Yıl', minval=2017)

start = timestamp(FromYear, FromMonth, FromDay, 00, 00)  // backtest start window

finish = timestamp(ToYear, ToMonth, ToDay, 23, 59)  // backtest finish window

window() =>  // create function "within window of time"

    time >= start and time <= finish ? true : false

// === INPUT BACKTEST RANGE ===

 

sources = input(defval=close, title='Kaynak')

isHA = input(false, 'Mum Kullanımı')

heikenashi_1 = ticker.heikinashi(syminfo.tickerid)

security_1 = request.security(heikenashi_1, timeframe.period, sources)

src = isHA ? security_1 : sources

// Sampling Period

// Settings for 5min chart, BTCUSDC. For Other coin, change the paremeters

 

per = input.int(defval=50, minval=1, title='Örnekleme periyodu')

 

// Alpha Trade V-13 Çarpan

 

mult = input.float(defval=3.0, minval=0.1, title='Alpha Trade V-13 Çarpan')

 

// Alpha Trade V-13

 

smoothrng(x, t, m) =>

    wper = t * 2 - 1

    avrng = ta.ema(math.abs(x - x[1]), t)

    smoothrng = ta.ema(avrng, wper) * m

    smoothrng

smrng = smoothrng(src, per, mult)

 

// Alpha Trade V-13

 

rngfilt(x, r) =>

    rngfilt = x

    rngfilt := x > nz(rngfilt[1]) ? x - r < nz(rngfilt[1]) ? nz(rngfilt[1]) : x - r : x + r > nz(rngfilt[1]) ? nz(rngfilt[1]) : x + r

    rngfilt

filt = rngfilt(src, smrng)

 

// Alpha Trade V-13

 

upward = 0.0

upward := filt > filt[1] ? nz(upward[1]) + 1 : filt < filt[1] ? 0 : nz(upward[1])

downward = 0.0

downward := filt < filt[1] ? nz(downward[1]) + 1 : filt > filt[1] ? 0 : nz(downward[1])

 

// Alpha Trade V-13

 

hband = filt + smrng

lband = filt - smrng

 

// Alpha Trade V-13

 

filtcolor = upward > 0 ? color.lime : downward > 0 ? color.red : color.orange

barcolor = src > filt and src > src[1] and upward > 0 ? color.lime : src > filt and src < src[1] and upward > 0 ? color.green : src < filt and src < src[1] and downward > 0 ? color.red : src < filt and src > src[1] and downward > 0 ? color.maroon : color.orange

 

filtplot = plot(filt, color=filtcolor, linewidth=3, title='Alpha Trade V-13')

 

// Alpha Trade V-13

 

hbandplot = plot(hband, color=color.new(color.aqua, 100), title='Yüksek Hedef')

lbandplot = plot(lband, color=color.new(color.fuchsia, 100), title='Düşük Hedef')

 

// Fills

 

fill(hbandplot, filtplot, color=color.new(color.aqua, 90), title='Yüksek Hedef Aralığı')

fill(lbandplot, filtplot, color=color.new(color.fuchsia, 90), title='Düşük Hedef Aralığı')

 

// Bar Renk

 

//barcolor(barcolor)

 

// Alpha Trade V-13

 

longCond = bool(na)

shortCond = bool(na)

longCond := src > filt and src > src[1] and upward > 0 or src > filt and src < src[1] and upward > 0

shortCond := src < filt and src < src[1] and downward > 0 or src < filt and src > src[1] and downward > 0

 

CondIni = 0

CondIni := longCond ? 1 : shortCond ? -1 : CondIni[1]

longCondition = longCond and CondIni[1] == -1

shortCondition = shortCond and CondIni[1] == 1

 

//Alpha Trade V-13

 

plotshape(longCondition, title='Golden Cross', text='Golden Cross', textcolor=color.new(color.black, 0), style=shape.labelup, size=size.large, location=location.belowbar, color=color.new(#cd10e6, 0))

plotshape(shortCondition, title='Death Cross', text='Death Cross', textcolor=color.new(color.black, 0), style=shape.labeldown, size=size.large, location=location.abovebar, color=color.new(#94eee2, 0))

 

//strategy.entry("Long", strategy.long, stop = hband, when = window() , comment="Long")

//strategy.entry("Short", strategy.short, stop = lband, when = window() , comment="Short")

 

strategy.entry('Long', strategy.long, when=longCondition and window(), comment='Long')

strategy.entry('Short', strategy.short, when=shortCondition and window(), comment='Short')


 

// === Stop LOSS ===

useStopLoss = input(false, title='----- Stop Loss / Kar Al -----')

sl_inp = input.float(100, title='Stop Noktası %', step=0.25) / 100

tp_inp = input.float(1.5, title='Kar Al %', step=0.25) / 100

stop_level = strategy.position_avg_price * (1 - sl_inp)

take_level = strategy.position_avg_price * (1 + tp_inp)

stop_level_short = strategy.position_avg_price * (1 + sl_inp)

take_level_short = strategy.position_avg_price * (1 - tp_inp)

// === Stop LOSS ===

 

if useStopLoss

    strategy.exit('Stop Loss/Kısa Kar Al', 'Long', stop=stop_level, limit=take_level)

    strategy.exit('Stop Loss/Kısa Kar Al', 'Short', stop=stop_level_short, limit=take_level_short)


 

////


 

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/

// © LonesomeTheBlue

 

//@version=5

//indicator('Alpha Trade V-13', 'Alpha Trade V-13', overlay=true)

prd = input.int(defval=10, title='Pivot Ayarları', minval=4, maxval=30, group='Kurulum')

ppsrc = input.string(defval='Yüksek/Düşük', title='Arama', options=['Yüksek/Düşük', 'Close/Open'], group='Kurulum')

maxnumpp = input.int(defval=20, title=' Pivotların Maksimum Sayısı', minval=5, maxval=100, group='Kurulum')

ChannelW = input.int(defval=10, title='Maksimum Kanal Genişliği %', minval=1, group='Kurulum')

maxnumsr = input.int(defval=5, title=' Maksimum Sayı S/R', minval=1, maxval=10, group='Kurulum')

min_strength = input.int(defval=2, title=' Minimum Güç', minval=1, maxval=10, group='Kurulum')

labelloc = input.int(defval=20, title='Etiket Konumu', group='Renk', tooltip='Pozitif sayılar gelecekteki çubukları, negatif sayılar ise geçmiş çubukları ifade eder')

linestyle = input.string(defval='Kesik kesik', title='Çizgi Stili', options=['Sağlam', 'Noktalı', 'Kesik kesik'], group='Renk')

linewidth = input.int(defval=2, title='Çizgi Genişliği', minval=1, maxval=4, group='Renk')

resistancecolor = input.color(defval=color.red, title='Resistance Color', group='Renk')

supportcolor = input.color(defval=color.lime, title='Destek Rengi', group='Renk')

showpp = input(false, title='Puan Puanlarını Göster')

 

float src1 = ppsrc == 'Yüksek/Düşük' ? high : math.max(close, open)

float src2 = ppsrc == 'Yüksek/Düşük' ? low : math.min(close, open)

float ph = ta.pivothigh(src1, prd, prd)

float pl = ta.pivotlow(src2, prd, prd)

 

plotshape(ph and showpp, text='H', style=shape.labeldown, color=na, textcolor=color.new(color.red, 0), location=location.abovebar, offset=-prd)

plotshape(pl and showpp, text='L', style=shape.labelup, color=na, textcolor=color.new(color.lime, 0), location=location.belowbar, offset=-prd)

 

Lstyle = linestyle == 'Kesik' ? line.style_dashed : linestyle == 'Sağlam' ? line.style_solid : line.style_dotted

 

//calculate maximum S/R channel zone width

prdhighest = ta.highest(300)

prdlowest = ta.lowest(300)

cwidth = (prdhighest - prdlowest) * ChannelW / 100

 

var pivotvals = array.new_float(0)

 

if ph or pl

    array.unshift(pivotvals, ph ? ph : pl)

    if array.size(pivotvals) > maxnumpp  // limit the array size

        array.pop(pivotvals)

 

get_sr_vals(ind) =>

    float lo = array.get(pivotvals, ind)

    float hi = lo

    int numpp = 0

    for y = 0 to array.size(pivotvals) - 1 by 1

        float cpp = array.get(pivotvals, y)

        float wdth = cpp <= lo ? hi - cpp : cpp - lo

        if wdth <= cwidth  // fits the max channel width?

            if cpp <= hi

                lo := math.min(lo, cpp)

            else

                hi := math.max(hi, cpp)

 

            numpp += 1

            numpp

    [hi, lo, numpp]

 

var sr_up_level = array.new_float(0)

var sr_dn_level = array.new_float(0)

sr_strength = array.new_float(0)

 

find_loc(strength) =>

    ret = array.size(sr_strength)

    for i = ret > 0 ? array.size(sr_strength) - 1 : na to 0 by 1

        if strength <= array.get(sr_strength, i)

            break

        ret := i

        ret

    ret

 

check_sr(hi, lo, strength) =>

    ret = true

    for i = 0 to array.size(sr_up_level) > 0 ? array.size(sr_up_level) - 1 : na by 1

        //included?

        if array.get(sr_up_level, i) >= lo and array.get(sr_up_level, i) <= hi or array.get(sr_dn_level, i) >= lo and array.get(sr_dn_level, i) <= hi

            if strength >= array.get(sr_strength, i)

                array.remove(sr_strength, i)

                array.remove(sr_up_level, i)

                array.remove(sr_dn_level, i)

                ret

            else

                ret

Algoritmik Trading kategorisinde (12 puan) tarafından | 59 kez görüntülendi

Bu soruya cevap vermek için lütfen giriş yapınız veya kayıt olunuz.

8,966 soru
8,919 cevap
4,966 yorum
23,255 kullanıcı