Chia sẻ ae bộ code Tradingview : ichimoku - BB - Fibo - Ma - ICT trong 1 chỉ báo

Thảo luận trong 'Bàn luận về Amibroker, Metastock, Metatrader 4' bắt đầu bởi quocdn000, 5/11/24.

Lượt xem : 638

  1. quocdn000

    quocdn000 Well-Known Member

    Tham gia ngày:
    17/7/21
    Bài viết:
    61
    Đã được thích:
    104
    Giới tính:
    Nam
    // ©
    //@version=5
    indicator('Ichimoku QL', shorttitle='Ichi Tong Hop', overlay=true)
    Midpoint(len) =>
    math.avg(ta.highest(len), ta.lowest(len))
    Offset = input(26, title='Displacement')
    //-------------------------------------------------------------------------------------------------
    //Draw Tenkan line
    TK_lenghth = input.int(9, title='Tenkan leghth', minval=1)
    TK = Midpoint(TK_lenghth)
    plot(TK, title='Tenkan line', color=color.new(#002aff, 0), linewidth=1)
    //-------------------------------------------------------------------------------------------------
    //Draw Kijun line
    KJ_lenghth = input.int(26, title='Kijun leghth', minval=1)
    KJ = Midpoint(KJ_lenghth)
    plot(KJ, title='Kijun line', color=color.new(#ff4000, 0), linewidth=1)
    //-------------------------------------------------------------------------------------------------
    //Draw Tenkan2 line
    TK2_lenghth = input.int(65, title='Tenkan2 leghth', minval=1)
    TK2 = Midpoint(TK2_lenghth)
    plot(TK2, title='Tenkan2 line', color=color.new(#002aff, 0), linewidth=1)
    //-------------------------------------------------------------------------------------------------
    //Draw Kijun2 line
    KJ2_lenghth = input.int(129, title='Kijun2 leghth', minval=1)
    KJ2 = Midpoint(KJ2_lenghth)
    plot(KJ2, title='Kijun2 line', color=color.new(#ff4000, 0), linewidth=1)
    //-------------------------------------------------------------------------------------------------
    //Draw Dagger 65
    DG65_lenghth = input.int(65, title='Dagger 65 leghth', minval=1)
    DG65 = Midpoint(DG65_lenghth)
    plot(DG65, title='Dagger 65 line', color=color.new(#ffa200, 0), linewidth=2)
    //-------------------------------------------------------------------------------------------------
    //Draw Dagger 129
    DG129_lenghth = input.int(129, title='Dagger 129 leghth', minval=1)
    DG129 = Midpoint(DG129_lenghth)
    plot(DG129, title='Dagger 129 line', color=color.new(#6708c7, 0), linewidth=2)
    //-------------------------------------------------------------------------------------------------
    //Chikou
    CK = close
    plot(CK, title='Chikou line', color=color.new(#283b57, 0), linewidth=1, offset=-Offset)
    //-------------------------------------------------------------------------------------------------
    //Span A
    SpanA = math.avg(TK, KJ)
    //-------------------------------------------------------------------------------------------------
    //Span B
    SpanB_lenghth = input.int(52, title='Span B leghth', minval=1)
    SpanB = Midpoint(SpanB_lenghth)
    //-------------------------------------------------------------------------------------------------
    //Span A2
    SpanA2 = math.avg(TK2, KJ2)
    //-------------------------------------------------------------------------------------------------
    //Span B2
    SpanB2_lenghth = input.int(200, title='Span B2 leghth', minval=1)
    SpanB2 = Midpoint(SpanB2_lenghth)
    //-------------------------------------------------------------------------------------------------
    //Kumo Color
    Kumo_color = SpanA >= SpanB ? color.new(color.green, 50) : color.new(color.red, 50)
    Kumo_line_color = SpanA >= SpanB ? color.new(color.green, 50) : color.new(color.red, 50)
    s1 = plot(SpanA, title='Span A line', color=Kumo_line_color, linewidth=1, offset=Offset)
    s2 = plot(SpanB, title='Span B line', color=Kumo_line_color, linewidth=1, offset=Offset)
    fill(s1, s2, title='Kumo Cloud Color', color=Kumo_color, transp=90)
    //-------------------------------------------------------------------------------------------------
    //Kumo2 Color
    Kumo2_color = SpanA2 >= SpanB2 ? color.new(color.green, 50) : color.new(color.red, 50)
    Kumo2_line_color = SpanA2 >= SpanB2 ? color.new(color.green, 50) : color.new(color.red, 50)
    s1a = plot(SpanA2, title='Span A2 line', color=Kumo2_line_color, linewidth=1, offset=Offset)
    s2a = plot(SpanB2, title='Span B2 line', color=Kumo2_line_color, linewidth=1, offset=Offset)
    fill(s1, s2, title='Kumo2 Cloud Color', color=Kumo2_color, transp=90)
    //-------------------------------------------------------------------------------------------------

    // BB
    //@version=5

    length = input.int(20, minval=1)
    maType = input.string("SMA", "Basis MA Type", options = ["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"])
    src = input(close, title="Source")
    mult = input.float(2.0, minval=0.001, maxval=50, title="StdDev")

    ma(source, length, _type) =>
    switch _type
    "SMA" => ta.sma(source, length)
    "EMA" => ta.ema(source, length)
    "SMMA (RMA)" => ta.rma(source, length)
    "WMA" => ta.wma(source, length)
    "VWMA" => ta.vwma(source, length)

    basis = ma(src, length, maType)
    dev = mult * ta.stdev(src, length)
    upper = basis + dev
    lower = basis - dev
    offset = input.int(0, "Offset", minval = -500, maxval = 500, display = display.data_window)
    plot(basis, "Basis", color=#2962FF, offset = offset)
    p1a = plot(upper, "Upper", color=#F23645, offset = offset)
    p2a = plot(lower, "Lower", color=#089981, offset = offset)
    fill(p1a, p2a, title = "Background", color=color.rgb(33, 150, 243, 95))



    // Ichimoku Cloud parameters
    conversionPeriods = input.int(9, minval=1)
    basePeriods = input.int(26, minval=1)
    laggingSpan2Periods = input.int(52, minval=1)

    displacement = basePeriods

    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=color.new(color.red, 0), title='Conversion Line')
    plot(baseLine, color=color.new(color.blue, 0), title='Base Line')
    plot(close, offset=-displacement, color=color.new(color.green, 0), title='Lagging Span')

    p1 = plot(leadLine1, offset=displacement, color=color.new(color.green, 0), title='Lead 1')
    p2 = plot(leadLine2, offset=displacement, color=color.new(color.red, 0), title='Lead 2')



    // Thêm EMA
    emaLength1 = input.int(50, title='EMA Length 1', minval=1) // EMA 1 với độ dài 50 (bạn có thể thay đổi độ dài này)
    emaLength2 = input.int(200, title='EMA Length 2', minval=1) // EMA 2 với độ dài 200 (bạn có thể thay đổi độ dài này)

    ema1 = ta.ema(close, emaLength1) // Tính toán EMA 1
    ema2 = ta.ema(close, emaLength2) // Tính toán EMA 2

    // Vẽ EMA lên biểu đồ
    plot(ema1, color=color.new(color.purple, 0), linewidth=1, title='EMA 50')
    plot(ema2, color=color.new(color.orange, 0), linewidth=1, title='EMA 200')


    import LudoGH68/Drawings_public/1 as d

    getLineStyle(lineOption) =>
    lineOption == "┈" ? line.style_dotted : lineOption == "╌" ? line.style_dashed : line.style_solid

    get_structure_highest_bar(lookback) =>

    var int idx = 0
    maxBar = bar_index > lookback ? ta.highestbars(high, lookback) : ta.highestbars(high, bar_index + 1)

    for i = 0 to lookback - 1 by 1
    if high[i+1] > high[i+2] and high <= high[i+1] and ((i+1) * -1) >= maxBar
    idx := (i+1) * -1
    //break

    idx := idx == 0 ? maxBar : idx

    get_structure_lowest_bar(lookback) =>

    var int idx = 0
    minBar = bar_index > lookback ? ta.lowestbars(low, lookback) : ta.lowestbars(low, bar_index + 1)

    for i = 0 to lookback - 1 by 1
    if low[i+1] < low[i+2] and low >= low[i+1] and ((i+1) * -1) >= minBar
    idx := (i+1) * -1
    //break

    idx := idx == 0 ? minBar : idx

    is_structure_high_broken(_highStructBreakPrice, _structureHigh, _structureHighStartIndex, _structureDirection) =>
    var bool res = false

    if (_highStructBreakPrice > _structureHigh and bar_index[1] > _structureHighStartIndex) or (_structureDirection == 1 and _highStructBreakPrice > _structureHigh)
    res := true
    else
    res := false

    res

    // Fear Value Gap
    isFvgToShow = input(true, title='Display FVG', group="Fear Value Gap")
    bullishFvgColor = input(color.new(color.green, 50), 'Bullish FVG Color', group="Fear Value Gap")
    bearishFvgColor = input(color.new(color.red, 50), 'Bearish FVG Color', group="Fear Value Gap")
    mitigatedFvgColor = input(color.new(color.gray, 50), 'Mitigated FVG Color', group="Fear Value Gap")
    fvgHistoryNbr = input.int(5, 'Number of FVG to show', minval=1, maxval=50)
    isMitigatedFvgToReduce = input(false, title='Reduce mitigated FVG', group="Fear Value Gap")

    // Structures
    isStructBodyCandleBreak = input(true, title='Break with candle\'s body', group="Structures")
    isCurrentStructToShow = input(true, title='Display current structure', group="Structures")
    bullishBosColor = input(color.silver, 'Bullish BOS Color', group="Structures")
    bearishBosColor = input(color.silver, 'Bearish BOS Color', group="Structures")
    bosLineStyleOption = input.string("─", title="BOS Style", group="Structures", options=["─", "┈", "╌"])
    bosLineStyle = getLineStyle(bosLineStyleOption)
    bosLineWidth = input.int(1, title="BOS Width", group="Structures", minval=1, maxval=5)
    bullishChochColor = input(color.yellow, 'Bullish CHoCH Color', group="Structures")
    bearishChochColor = input(color.yellow, 'Bearish CHoCH Color', group="Structures")
    chochLineStyleOption = input.string("─", title="CHoCH Style", group="Structures", options=["─", "┈", "╌"])
    chochLineStyle = getLineStyle(chochLineStyleOption)
    chochLineWidth = input.int(1, title="MSB Width", group="Structures", minval=1, maxval=5)
    currentStructColor = input(color.blue, 'Current structure Color', group="Structures")
    currentStructLineStyleOption = input.string("─", title="Current structure Style", group="Structures", options=["─", "┈", "╌"])
    currentStructLineStyle = getLineStyle(currentStructLineStyleOption)
    currentStructLineWidth = input.int(1, title="Current structure Width", group="Structures", minval=1, maxval=5)
    structHistoryNbr = input.int(10, 'Number of break to show', minval=1, maxval=50)

    // Fibonacci 1
    isFibo1ToShow = input(true, title = "", group="Structure Fibonacci", inline = "Fibo1")
    fibo1Value = input.float(0.786, title = "", group="Structure Fibonacci", inline = "Fibo1")
    fibo1Color = input(#64b5f6, title = "", group="Structure Fibonacci", inline = "Fibo1")
    fibo1StyleOption = input.string("─", title = "", group="Structure Fibonacci", options=["─", "┈", "╌"], inline = "Fibo1")
    fibo1Style = getLineStyle(fibo1StyleOption)
    fibo1LineWidth = input.int(1, title = "", group="Structure Fibonacci", minval=1, maxval=5, inline = "Fibo1")

    // Fibonacci 2
    isFibo2ToShow = input(true, title = "", group="Structure Fibonacci", inline = "Fibo2")
    fibo2Value = input.float(0.705, title = "", group="Structure Fibonacci", inline = "Fibo2")
    fibo2Color = input(#f23645, title = "", group="Structure Fibonacci", inline = "Fibo2")
    fibo2StyleOption = input.string("─", title = "", group="Structure Fibonacci", options=["─", "┈", "╌"], inline = "Fibo2")
    fibo2Style = getLineStyle(fibo2StyleOption)
    fibo2LineWidth = input.int(1, title = "", group="Structure Fibonacci", minval=1, maxval=5, inline = "Fibo2")

    // Fibonacci 3
    isFibo3ToShow = input(true, title = "", group="Structure Fibonacci", inline = "Fibo3")
    fibo3Value = input.float(0.618, title = "", group="Structure Fibonacci", inline = "Fibo3")
    fibo3Color = input(#089981, title = "", group="Structure Fibonacci", inline = "Fibo3")
    fibo3StyleOption = input.string("─", title = "", group="Structure Fibonacci", options=["─", "┈", "╌"], inline = "Fibo3")
    fibo3Style = getLineStyle(fibo3StyleOption)
    fibo3LineWidth = input.int(1, title = "", group="Structure Fibonacci", minval=1, maxval=5, inline = "Fibo3")

    // Fibonacci 3
    isFibo4ToShow = input(true, title = "", group="Structure Fibonacci", inline = "Fibo4")
    fibo4Value = input.float(0.5, title = "", group="Structure Fibonacci", inline = "Fibo4")
    fibo4Color = input(#4caf50, title = "", group="Structure Fibonacci", inline = "Fibo4")
    fibo4StyleOption = input.string("─", title = "", group="Structure Fibonacci", options=["─", "┈", "╌"], inline = "Fibo4")
    fibo4Style = getLineStyle(fibo4StyleOption)
    fibo4LineWidth = input.int(1, title = "", group="Structure Fibonacci", minval=1, maxval=5, inline = "Fibo4")

    // Fibonacci 5
    isFibo5ToShow = input(true, title = "", group="Structure Fibonacci", inline = "Fibo5")
    fibo5Value = input.float(0.382, title = "", group="Structure Fibonacci", inline = "Fibo5")
    fibo5Color = input(#81c784, title = "", group="Structure Fibonacci", inline = "Fibo5")
    fibo5StyleOption = input.string("─", title = "", group="Structure Fibonacci", options=["─", "┈", "╌"], inline = "Fibo5")
    fibo5Style = getLineStyle(fibo5StyleOption)
    fibo5LineWidth = input.int(1, title = "", group="Structure Fibonacci", minval=1, maxval=5, inline = "Fibo5")

    // Draw FVG into graph
    FVGDraw(_boxes, _fvgTypes, _isFvgMitigated) =>

    // Loop into all values of the array
    for [index, value] in _boxes

    // Processing bullish FVG
    if(array.get(_fvgTypes, index))

    // Check if FVG has been totally mitigated
    if(low <= box.get_bottom(value))
    array.remove(_boxes, index)
    array.remove(_fvgTypes, index)
    array.remove(_isFvgMitigated, index)
    box.delete(value)
    else
    if(low < box.get_top((value)))
    box.set_bgcolor(value, mitigatedFvgColor)

    // Mitigated FVG Alert
    if(not(array.get(_isFvgMitigated, index)))
    alert("FVG has been mitigated", alert.freq_once_per_bar)
    array.set(_isFvgMitigated, index, true)

    // Reduce FVG if needed
    if(isMitigatedFvgToReduce)
    box.set_top(value, low)

    box.set_right(value, bar_index)

    // Processing bearish FVG
    else

    // Check if FVG has been mitigated
    if(high >= box.get_top(value))
    array.remove(_boxes, index)
    array.remove(_fvgTypes, index)
    array.remove(_isFvgMitigated, index)
    box.delete(value)
    else
    if(high > box.get_bottom((value)))
    box.set_bgcolor(value, mitigatedFvgColor)

    // Mitigated FVG Alert
    if(not(array.get(_isFvgMitigated, index)))
    alert("FVG has been mitigated", alert.freq_once_per_bar)
    array.set(_isFvgMitigated, index, true)

    // Reduce FVG if needed
    if(isMitigatedFvgToReduce)
    box.set_bottom(value, high)

    box.set_right(value, bar_index)

    // Arrays variable
    var array<line> structureLines = array.new_line(0)
    var array<label> structureLabels = array.new_label(0)
    var array<box> fvgBoxes = array.new_box(0)
    var array<bool> fvgTypes = array.new_bool(0)
    var array<bool> isFvgMitigated = array.new_bool(0)

    // Price variables
    var float structureHigh = 0.0
    var float structureLow = 0.0
    var float fibo1Price = 0.0
    var float fibo2Price = 0.0
    var float fibo3Price = 0.0
    var float fibo4Price = 0.0
    var float fibo5Price = 0.0

    // Index variable
    var int structureHighStartIndex = 0
    var int structureLowStartIndex = 0
    var int structureDirection = 0
    var int fibo1StartIndex = 0
    var int fibo2StartIndex = 0
    var int fibo3StartIndex = 0
    var int fibo4StartIndex = 0
    var int fibo5StartIndex = 0

    // Line variable
    var line structureHighLine = na
    var line structureLowLine = na
    var line fibo1Line = na
    var line fibo2Line = na
    var line fibo3Line = na
    var line fibo4Line = na
    var line fibo5Line = na

    // Label variable
    var label fibo1Label = na
    var label fibo2Label = na
    var label fibo3Label = na
    var label fibo4Label = na
    var label fibo5Label = na
    //
    //
    // ==========================================================================================
    // FAIR VALUE GAP FINDER PROCESSING
    // ==========================================================================================
    //
    //
    // Define FVG type
    isBullishFVG = high[3] < low[1]
    isBearishFVG = low[3] > high[1]

    // Bullish FVG process
    if(isBullishFVG and isFvgToShow)

    // Add FVG into FVG's array
    box _box = box.new(left=bar_index - 2, top=low[1], right=bar_index[1], bottom=high[3], border_style=line.style_solid, border_width=1, bgcolor=bullishFvgColor, border_color=color.new(color.green, 100))
    array.push(fvgBoxes, _box)
    array.push(fvgTypes, true)
    array.push(isFvgMitigated, false)

    // Check if FVG to show is upper than user parameter
    if(array.size(fvgBoxes) > fvgHistoryNbr + 1)

    // Delete the FVG and its index from arrays
    box.delete(array.get(fvgBoxes, 0))
    array.remove(fvgBoxes, 0)
    array.remove(fvgTypes, 0)
    array.remove(isFvgMitigated, 0)

    // Bearish FVG process
    if(isBearishFVG and isFvgToShow)

    // Add FVG into FVG's array
    box _box = box.new(left=bar_index - 2, top=low[3], right=bar_index[1], bottom=high[1], border_style=line.style_solid, border_width=1, bgcolor=bearishFvgColor, border_color=color.new(color.red, 100))
    array.push(fvgBoxes, _box)
    array.push(fvgTypes, false)
    array.push(isFvgMitigated, false)

    // Check if FVG to show is upper than user parameter
    if(array.size(fvgBoxes) > fvgHistoryNbr + 1)

    // Delete the FVG and its index from arrays
    box.delete(array.get(fvgBoxes, 0))
    array.remove(fvgBoxes, 0)
    array.remove(fvgTypes, 0)
    array.remove(isFvgMitigated, 0)

    // Draw FVG
    FVGDraw(fvgBoxes, fvgTypes, isFvgMitigated)
    //
    //
    // ==========================================================================================
    // STRUCTURES PROCESSING
    // ==========================================================================================
    //
    //
    // Initialize value for bar 0
    if(bar_index == 0)
    structureHighStartIndex := bar_index
    structureLowStartIndex := bar_index
    structureHigh := high
    structureLow := low

    highest = bar_index > 10 ? ta.highest(10) : ta.highest(bar_index + 1)
    highestBar = bar_index > 10 ? ta.highestbars(high, 10) : ta.highestbars(high, bar_index + 1)
    lowest = bar_index > 10 ? ta.lowest(10) : ta.lowest(bar_index + 1)
    lowestBar = bar_index > 10 ? ta.lowestbars(low, 10) : ta.lowestbars(low, bar_index + 1)
    structureMaxBar = bar_index + get_structure_highest_bar(10)
    structureMinBar = bar_index + get_structure_lowest_bar(10)
    lowStructBreakPrice = isStructBodyCandleBreak ? close : low
    highStructBreakPrice = isStructBodyCandleBreak ? close : high
    isStuctureLowBroken = (lowStructBreakPrice < structureLow and lowStructBreakPrice[1] >= structureLow and lowStructBreakPrice[2] >= structureLow and lowStructBreakPrice[3] >= structureLow and bar_index[1] > structureLowStartIndex and bar_index[2] > structureLowStartIndex and bar_index[3] > structureLowStartIndex) or (structureDirection == 2 and lowStructBreakPrice < structureLow)
    isStructureHighBroken = (highStructBreakPrice > structureHigh and highStructBreakPrice[1] <= structureHigh and highStructBreakPrice[2] <= structureHigh and highStructBreakPrice[3] <= structureHigh and bar_index[1] > structureHighStartIndex and bar_index[2] > structureHighStartIndex and bar_index[3] > structureHighStartIndex) or (structureDirection == 1 and highStructBreakPrice > structureHigh)


    //if((low < structureLow and low[1] >= structureLow and low[2] >= structureLow and low[3] >= structureLow and bar_index[1] > structureLowStartIndex and bar_index[2] > structureLowStartIndex and bar_index[3] > structureLowStartIndex) or (structureDirection == 2 and low < structureLow))
    if(isStuctureLowBroken)
    // Check if structures to show is upper than user parameter
    if(array.size(structureLines) >= structHistoryNbr)

    // Delete the line and its index from arrays
    d.delete_line(array.get(structureLines, 0), array.get(structureLabels, 0))
    array.remove(structureLabels, 0)
    array.remove(structureLines, 0)


    // Create BOS line
    if(structureDirection == 1)
    array.push(structureLines, line.new(structureLowStartIndex, structureLow, bar_index, structureLow, xloc=xloc.bar_index, extend=extend.none, color=bearishBosColor, style=bosLineStyle, width=bosLineWidth))
    array.push(structureLabels, label.new((bar_index + structureLowStartIndex) / 2, structureLow, text="BOS", style=label.style_none, textcolor=bearishBosColor))

    // Create CHoCH line
    else
    array.push(structureLines, line.new(structureLowStartIndex, structureLow, bar_index, structureLow, xloc=xloc.bar_index, extend=extend.none, color=bearishChochColor, style=chochLineStyle, width=chochLineWidth))
    array.push(structureLabels, label.new((bar_index + structureLowStartIndex) / 2, structureLow, text="CHoCH", style=label.style_none, textcolor=bearishChochColor))

    // Update values for new structure
    structureDirection := 1
    structureHighStartIndex := structureMaxBar
    structureLowStartIndex := bar_index
    structureHigh := high[bar_index - structureHighStartIndex] //highest
    structureLow := low

    // Check for breakout
    else if(isStructureHighBroken)

    // Check if structures to show is upper than user parameter
    if(array.size(structureLines) >= structHistoryNbr)

    // Delete the line and its index from arrays
    d.delete_line(array.get(structureLines, 0), array.get(structureLabels, 0))
    array.remove(structureLabels, 0)
    array.remove(structureLines, 0)

    // Create BOS line
    if(structureDirection == 2)
    array.push(structureLines, line.new(structureHighStartIndex, structureHigh, bar_index, structureHigh, xloc=xloc.bar_index, extend=extend.none, color=bullishBosColor, style=bosLineStyle, width=bosLineWidth))
    array.push(structureLabels, label.new((bar_index + structureHighStartIndex) / 2, structureHigh, text="BOS", style=label.style_none, textcolor=bullishBosColor))

    // Create CHoCH line
    else
    array.push(structureLines, line.new(structureHighStartIndex, structureHigh, bar_index, structureHigh, xloc=xloc.bar_index, extend=extend.none, color=bullishChochColor, style=chochLineStyle, width=chochLineWidth))
    array.push(structureLabels, label.new((bar_index + structureHighStartIndex) / 2, structureHigh, text="CHoCH", style=label.style_none, textcolor=bullishChochColor))

    // Update values for new structure
    structureDirection := 2
    structureHighStartIndex := bar_index
    structureLowStartIndex := structureMinBar
    structureHigh := high
    structureLow := low[bar_index - structureLowStartIndex] //lowest
    else
    if(high > structureHigh and (structureDirection == 0 or structureDirection == 2))
    if(not(isStructBodyCandleBreak) or not(isStructBodyCandleBreak and bar_index[1] > structureHighStartIndex and bar_index[2] > structureHighStartIndex and bar_index[3] > structureHighStartIndex))
    structureHigh := high
    structureHighStartIndex := bar_index
    else if(low < structureLow and (structureDirection == 0 or structureDirection == 1))
    if(not(isStructBodyCandleBreak) or not(isStructBodyCandleBreak and bar_index[1] > structureLowStartIndex and bar_index[2] > structureLowStartIndex and bar_index[3] > structureLowStartIndex))
    structureLow := low
    structureLowStartIndex := bar_index

    structureRange = math.abs(structureHigh - structureLow)

    // Affichage de la structure actuelle
    if(isCurrentStructToShow)
    d.delete_line(structureHighLine, na)
    d.delete_line(structureLowLine, na)
    structureHighLine := line.new(structureHighStartIndex, structureHigh, bar_index, structureHigh, xloc.bar_index, color=currentStructColor, style = currentStructLineStyle, width = currentStructLineWidth)
    structureLowLine := line.new(structureLowStartIndex, structureLow, bar_index, structureLow, xloc.bar_index, color=currentStructColor, style = currentStructLineStyle, width = currentStructLineWidth)

    // Affichage du Fibonnacci 1 de la structure actuelle
    if(isFibo1ToShow)
    d.delete_line(fibo1Line, fibo1Label)
    fibo1Price := structureDirection == 1 ? structureHigh - (structureRange - structureRange * fibo1Value) : structureLow + (structureRange - structureRange * fibo1Value)
    fibo1StartIndex := structureDirection == 1 ? structureHighStartIndex : structureLowStartIndex
    fibo1Line := line.new(fibo1StartIndex, fibo1Price, bar_index, fibo1Price, xloc.bar_index, color = fibo1Color, style = fibo1Style, width = fibo1LineWidth)
    fibo1Label := label.new(bar_index + 20, fibo1Price, text = str.tostring(fibo1Value) + "(" + str.tostring(fibo1Price) + ")", style = label.style_none, textcolor = fibo1Color)

    // Affichage du Fibonnacci 2 de la structure actuelle
    if(isFibo2ToShow)
    d.delete_line(fibo2Line, fibo2Label)
    fibo2Price := structureDirection == 1 ? structureHigh - (structureRange - structureRange * fibo2Value) : structureLow + (structureRange - structureRange * fibo2Value)
    fibo2StartIndex := structureDirection == 1 ? structureHighStartIndex : structureLowStartIndex
    fibo2Line := line.new(fibo2StartIndex, fibo2Price, bar_index, fibo2Price, xloc.bar_index, color = fibo2Color, style = fibo2Style, width = fibo2LineWidth)
    fibo2Label := label.new(bar_index + 20, fibo2Price, text = str.tostring(fibo2Value) + "(" + str.tostring(fibo2Price) + ")", style = label.style_none, textcolor = fibo2Color)

    // Affichage du Fibonnacci 3 de la structure actuelle
    if(isFibo3ToShow)
    d.delete_line(fibo3Line, fibo3Label)
    fibo3Price := structureDirection == 1 ? structureHigh - (structureRange - structureRange * fibo3Value) : structureLow + (structureRange - structureRange * fibo3Value)
    fibo3StartIndex := structureDirection == 1 ? structureHighStartIndex : structureLowStartIndex
    fibo3Line := line.new(fibo3StartIndex, fibo3Price, bar_index, fibo3Price, xloc.bar_index, color = fibo3Color, style = fibo3Style, width = fibo3LineWidth)
    fibo3Label := label.new(bar_index + 20, fibo3Price, text = str.tostring(fibo3Value) + "(" + str.tostring(fibo3Price) + ")", style = label.style_none, textcolor = fibo3Color)

    // Affichage du Fibonnacci 1 de la structure actuelle
    if(isFibo4ToShow)
    d.delete_line(fibo4Line, fibo4Label)
    fibo4Price := structureDirection == 1 ? structureHigh - (structureRange - structureRange * fibo4Value) : structureLow + (structureRange - structureRange * fibo4Value)
    fibo4StartIndex := structureDirection == 1 ? structureHighStartIndex : structureLowStartIndex
    fibo4Line := line.new(fibo4StartIndex, fibo4Price, bar_index, fibo4Price, xloc.bar_index, color = fibo4Color, style = fibo4Style, width = fibo4LineWidth)
    fibo4Label := label.new(bar_index + 20, fibo4Price, text = str.tostring(fibo4Value) + "(" + str.tostring(fibo4Price) + ")", style = label.style_none, textcolor = fibo4Color)

    // Affichage du Fibonnacci 1 de la structure actuelle
    if(isFibo5ToShow)
    d.delete_line(fibo5Line, fibo5Label)
    fibo5Price := structureDirection == 1 ? structureHigh - (structureRange - structureRange * fibo5Value) : structureLow + (structureRange - structureRange * fibo5Value)
    fibo5StartIndex := structureDirection == 1 ? structureHighStartIndex : structureLowStartIndex
    fibo5Line := line.new(fibo5StartIndex, fibo5Price, bar_index, fibo5Price, xloc.bar_index, color = fibo5Color, style = fibo5Style, width = fibo5LineWidth)
    fibo5Label := label.new(bar_index + 20, fibo5Price, text = str.tostring(fibo5Value) + "(" + str.tostring(fibo5Price) + ")", style = label.style_none, textcolor = fibo5Color)

    plot(na)
     

    Các file đính kèm:

    • vni.JPG
      vni.JPG
      Kích thước:
      183 KB
      Đọc:
      2,480
  2. Đang tải...

    Bài viết tương tự Diễn đàn Date
    Chia sẻ code Hull MA - chỉ báo xu hướng óng mượt hơn MA thường Bàn luận về Amibroker, Metastock, Metatrader 4 10/5/24
    Chia sẻ code thông tin cổ phiếu Bàn luận về Amibroker, Metastock, Metatrader 4 6/4/24
    CHIA SẺ CODE BẮT ĐÁY BÁN ĐỈNH DÒNG TIỀN TẠO LẬP MCDX X2 SỨC MẠNH Bàn luận về Amibroker, Metastock, Metatrader 4 25/11/23
    Chia sẻ chỉ báo ImPulse MACD nấng cấp sức mạnh MACD X4 lần :)))) Bàn luận về Amibroker, Metastock, Metatrader 4 21/11/23
    CHIA SẺ BẢNG VOLUME THEO DÕI MUA/BÁN CHỦ ĐỘNG, KÈM BỘ LỌC BIẾN ĐỘNG GIÁ, KHỐI LƯỢNG BÙNG NỔ Bàn luận về Amibroker, Metastock, Metatrader 4 14/11/23

  3. Nam

    Nam Member

    Tham gia ngày:
    10/7/21
    Bài viết:
    23
    Đã được thích:
    5
    Giới tính:
    Nam
    Bạn cho xin tên chỉ báo trên Tradingview dễ hơn
     
  4. quocdn000

    quocdn000 Well-Known Member

    Tham gia ngày:
    17/7/21
    Bài viết:
    61
    Đã được thích:
    104
    Giới tính:
    Nam
    cái này mình tự code , nên ko có chia sẻ public trên đó . Bạn chọn 1 code bất kỳ , dán đoạn code trên vào rồi lưu lại 1 name mới là sài thôi
     
    Chỉnh sửa cuối: 8/11/24
  5. quocdn000

    quocdn000 Well-Known Member

    Tham gia ngày:
    17/7/21
    Bài viết:
    61
    Đã được thích:
    104
    Giới tính:
    Nam
    Ae Hãy đặc biệt chú ý Đường Chikou ( đường trễ ) ichimoku khi nó giao cắt với đường 65 , 129 và Bollinger Band ( gồm band trên - dưới , đường MA20) đó là những điểm mua hoặc bán tiềm năng.
     
  6. Nam

    Nam Member

    Tham gia ngày:
    10/7/21
    Bài viết:
    23
    Đã được thích:
    5
    Giới tính:
    Nam
    Mình biết cách mà, nhưng bị lỗi bạn à, nên mình mới xin tên gốc của chỉ báo để copy cho chuẩn
     

Lượt bình luận : 4

Tags:

Chia sẻ trang này