Cara Backtest Strategi Trading Menggunakan Indikator Ichimoku Cloud Di Tradingview

แชร์
ฝัง
  • เผยแพร่เมื่อ 27 ธ.ค. 2024

ความคิดเห็น • 1

  • @Permana_Backtest
    @Permana_Backtest  13 วันที่ผ่านมา +1

    Note:
    Jika bukan lewat PC, coba buka TH-camnnya di situs m.TH-cam.com dan pakai mode desktop untuk Salin semua code pinescript dibawah:
    // This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at mozilla.org/MPL/2.0/
    // © Permana_Backtest
    //@version=6
    strategy('Permana Backtest', overlay= true, pyramiding= 0, default_qty_type= strategy.percent_of_equity, default_qty_value= 100, initial_capital= 10000000)
    ///////////////////////////////////////////////////////////////
    // Aktivasi Mode //
    LONG = input.bool(true, "Aktivasi Mode LONG", group = "Aktivasi Mode Jual/Beli")
    SHORT = input.bool(false, "Aktivasi Mode SHORT", group = "Aktivasi Mode Jual/Beli")
    LOGIC_Mode = if LONG and SHORT
    10
    else if LONG
    20
    else if SHORT
    30
    else
    0
    // INDIKATOR SETUP //
    conversionPeriods = input.int(9, minval=1, title="Conversion Line Length/Tenkan-sen")
    basePeriods = input.int(26, minval=1, title="Base Line Length/Kijun-sen")
    laggingSpan2Periods = input.int(52, minval=1, title="Leading Span B Length/Senkou Span")
    displacement = input.int(26, minval=1, title="Lagging Span/Chikou Span")
    donchian(len) => math.avg(ta.lowest(len), ta.highest(len))
    conversionLine = donchian(conversionPeriods)
    baseLine = donchian(basePeriods)
    leadLine1 = math.avg(conversionLine, baseLine)
    leadLine2 = donchian(laggingSpan2Periods)
    plot(conversionLine, color=#2962FF, title="Conversion Line/Tenkan-sen")
    plot(baseLine, color=#B71C1C, title="Base Line/Kijun-sen")
    plot(close, offset = -displacement + 1, color=#43A047, title="Lagging Span/Chikou Span")
    p1 = plot(leadLine1, offset = displacement - 1, color=#A5D6A7,
    title="Leading Span A/Senkou Span A")
    p2 = plot(leadLine2, offset = displacement - 1, color=#EF9A9A,
    title="Leading Span B/Senkou Span B")
    plot(leadLine1 > leadLine2 ? leadLine1 : leadLine2, offset = displacement - 1, title = "Kumo Cloud Upper Line", display = display.none)
    plot(leadLine1 < leadLine2 ? leadLine1 : leadLine2, offset = displacement - 1, title = "Kumo Cloud Lower Line", display = display.none)
    fill(p1, p2, color = leadLine1 > leadLine2 ? color.rgb(67, 160, 71, 90) : color.rgb(244, 67, 54, 90))
    // SISTEM PLANNING //
    // Syarat beli LONG//
    b1_L = close > open
    b2_L = close < open
    b3_L = close > leadLine1[displacement - 1] and close > leadLine2[displacement - 1]
    b4_L = ta.crossover(conversionLine,baseLine)
    b5_L = close > close[(displacement - 1)]
    b6_L = leadLine1[displacement - 1] > leadLine2[displacement - 1]
    // Syarat jual LONG//
    s1_L = close < open
    s2_L = close > open
    s3_L = close open
    s2_S = close < open
    s3_S = close >= leadLine1[displacement - 1] and close >= leadLine2[displacement - 1]
    s4_S = ta.crossover(conversionLine,baseLine)
    s5_S = leadLine1[displacement - 1] > leadLine2[displacement - 1]
    // Signal beli atau jual SHORT //
    SHORTbuySignal_1 = b3_S and b4_S and b5_S and b6_S
    SHORTbuySignal_2 = b3_S and b4_S and b5_S and b6_S
    SHORTbuySignal_entry = SHORTbuySignal_1 or SHORTbuySignal_2
    SHORTsellSignal_1 = s3_S and s4_S and s5_S
    SHORTsellSignal_2 = s3_S and s4_S and s5_S
    SHORTsellSignal_close = SHORTsellSignal_1 or SHORTsellSignal_2
    // BACKTEST
    if LOGIC_Mode == 10 and LONGbuySignal_entry
    strategy.entry("ENTRY LONG", strategy.long, comment="ENTRY LONG")
    if LOGIC_Mode == 10 and LONGsellSignal_close
    strategy.close("ENTRY LONG", comment="EXIT LONG")

    if LOGIC_Mode == 10 and SHORTbuySignal_entry
    strategy.entry("ENTRY SHORT", strategy.short, comment="ENTRY SHORT")
    if LOGIC_Mode == 10 and SHORTsellSignal_close
    strategy.close("ENTRY SHORT", comment="EXIT SHORT")
    if LOGIC_Mode == 20 and LONGbuySignal_entry
    strategy.entry("LONG", strategy.long, comment = "BUY LONG")
    if LOGIC_Mode == 20 and LONGsellSignal_close
    strategy.close("LONG", comment = "SELL LONG")
    if LOGIC_Mode == 30 and SHORTbuySignal_entry
    strategy.entry("SHORT", strategy.short, comment = "BUY SHORT")
    if LOGIC_Mode == 30 and SHORTsellSignal_close
    strategy.close("SHORT", comment = "SELL SHORT")