Leverage Liquidation Projection

vms_raccoon · study · 1023 行 · 点赞 27 · TradingView 原页

本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。

Pine Script

//@version=6
 
indicator("Leverage Liquidation Projection", overlay = true, max_lines_count = 30, max_labels_count = 30)
 
import PineCoders/VisibleChart/5 as PCvc
 
// =========================================================
// INPUTS
// =========================================================
 
groupCalc = "Calculation"
 
calcSource = input.string(
    "Wicks",
    "Calculation source",
    options = ["Wicks", "Body"],
    group = groupCalc)
 
showHighLevels = input.bool(
    true,
    "Long liquidation levels",
    group = groupCalc)
 
showLowLevels = input.bool(
    false,
    "Short liquidation levels",
    group = groupCalc)
 
groupLeverage = "Leverage"
 
show1x = input.bool(true, "1x", group = groupLeverage)
show2x = input.bool(true, "2x", group = groupLeverage)
show3x = input.bool(true, "3x", group = groupLeverage)
show5x = input.bool(true, "5x", group = groupLeverage)
show7x = input.bool(false, "7x", group = groupLeverage)
show10x = input.bool(false, "10x", group = groupLeverage)
show20x = input.bool(false, "20x", group = groupLeverage)
show25x = input.bool(false, "25x", group = groupLeverage)
show30x = input.bool(false, "30x", group = groupLeverage)
show50x = input.bool(false, "50x", group = groupLeverage)
show100x = input.bool(false, "100x", group = groupLeverage)
 
groupVisual = "Visuals"
 
showReference = input.bool(
    true,
    "Show reference level",
    group = groupVisual)
 
showLabels = input.bool(
    true,
    "Show labels",
    group = groupVisual)
 
minLineBars = input.int(
    30,
    "Minimum line length, bars",
    minval = 5,
    maxval = 500,
    group = groupVisual)
 
// =========================================================
// STYLE
// =========================================================
 
color longLevelColor = color.new(color.green, 25)
 
color shortLevelColor = color.new(color.red, 25)
 
color referenceColor = color.new(color.gray, 10)
 
color labelTextColor = color.white
 
// =========================================================
// VIEWPORT GEOMETRY
// =========================================================
 
float placementStartPct = 30.0
 
float placementEndPct = 70.0
 
float currentPricePosition = 105.0
 
int placementStartTime = PCvc.chartXTimePct(placementStartPct)
 
int placementEndTime = PCvc.chartXTimePct(placementEndPct)
 
int normalLevelEndTime = PCvc.chartXTimePct(85.0)
 
int currentPriceShiftTime = PCvc.chartXTimePct(currentPricePosition)
 
// =========================================================
// SOURCE
// =========================================================
 
float sourceHigh = calcSource == "Body" ? math.max(open, close) : high
 
float sourceLow = calcSource == "Body" ? math.min(open, close) : low
 
// =========================================================
// FIND VISIBLE EXTREMES
// =========================================================
 
// The calculation is performed only inside the currently
// visible chart range.
 
var float calcHigh = na
 
var float calcLow = na
 
var int calcHighBar = na
 
var int calcLowBar = na
 
bool visibleBar = PCvc.barIsVisible()
 
bool firstVisibleBar = PCvc.isFirstVisibleBar()
 
if visibleBar
 
    if firstVisibleBar
 
        calcHigh := sourceHigh
 
        calcHighBar := bar_index
 
        calcLow := sourceLow
 
        calcLowBar := bar_index
 
    else
 
        if na(calcHigh) or sourceHigh > calcHigh
 
            calcHigh := sourceHigh
 
            calcHighBar := bar_index
 
        if na(calcLow) or sourceLow < calcLow
 
            calcLow := sourceLow
 
            calcLowBar := bar_index
 
// =========================================================
// FIND PLACEMENT BOUNDARIES
// =========================================================
 
bool inPlacementWindow = time >= placementStartTime and time <= placementEndTime
 
bool enteringPlacementWindow = inPlacementWindow and not inPlacementWindow[1]
 
var int placementStartBar = na
 
var int placementEndBar = na
 
if enteringPlacementWindow
 
    placementStartBar := bar_index
 
if inPlacementWindow
 
    placementEndBar := bar_index
 
// =========================================================
// LEVEL START POSITION
// =========================================================
 
int longLevelStartBar = calcHighBar
 
int shortLevelStartBar = calcLowBar
 
if not na(calcHighBar) and not na(placementStartBar) and not na(placementEndBar)
 
    longLevelStartBar := math.min(
         math.max(calcHighBar, placementStartBar),
         placementEndBar)
 
if not na(calcLowBar) and not na(placementStartBar) and not na(placementEndBar)
 
    shortLevelStartBar := math.min(
         math.max(calcLowBar, placementStartBar),
         placementEndBar)
 
// =========================================================
// CURRENT PRICE VIEW
// =========================================================
 
int visibleRightBar = PCvc.rightBarIndex()
 
bool isAtCurrentPrice = visibleRightBar >= bar_index
 
// =========================================================
// LEVEL END POSITION
// =========================================================
 
int levelEndBar = na
 
if time >= normalLevelEndTime
 
    levelEndBar := bar_index
 
int safeLevelEndBar = not na(levelEndBar) ? levelEndBar : visibleRightBar
 
// =========================================================
// WHOLE INDICATOR SHIFT
// =========================================================
 
int indicatorShiftBars = 0
 
if isAtCurrentPrice and not na(time[1]) and time != time[1]
 
    indicatorShiftBars := int(math.round(
         (currentPriceShiftTime - normalLevelEndTime) /
         (time - time[1])))
 
// =========================================================
// SAFETY LIMIT
// =========================================================
 
int maxFutureBars = 400
 
if isAtCurrentPrice
 
    int maxBaseBar = math.max(
         safeLevelEndBar,
         math.max(
             nz(longLevelStartBar, bar_index),
             nz(shortLevelStartBar, bar_index)))
 
    int allowedShift =
         bar_index + maxFutureBars - maxBaseBar
 
    indicatorShiftBars :=
         math.min(indicatorShiftBars, allowedShift)
 
    indicatorShiftBars :=
         math.max(indicatorShiftBars, -400)
 
// =========================================================
// SHIFT LEVEL GEOMETRY
// =========================================================
 
int shiftedLongStartBar = nz(longLevelStartBar, bar_index) + indicatorShiftBars
 
int shiftedShortStartBar = nz(shortLevelStartBar, bar_index) + indicatorShiftBars
 
int shiftedLevelEndBar = safeLevelEndBar + indicatorShiftBars
 
int finalLongStartBar = isAtCurrentPrice ? shiftedLongStartBar : longLevelStartBar
 
int finalShortStartBar = isAtCurrentPrice ? shiftedShortStartBar : shortLevelStartBar
 
int finalLevelEndBar = isAtCurrentPrice ? shiftedLevelEndBar : safeLevelEndBar
 
// =========================================================
// FINAL SAFETY CLAMP
// =========================================================
 
int futureLimitBar = bar_index + maxFutureBars
 
finalLongStartBar := math.min(finalLongStartBar, futureLimitBar)
 
finalShortStartBar := math.min(finalShortStartBar, futureLimitBar)
 
finalLevelEndBar := math.min(finalLevelEndBar, futureLimitBar)
 
int longEndBar = math.min(
         math.max(
             finalLevelEndBar,
             finalLongStartBar + minLineBars),
         futureLimitBar)
 
int shortEndBar = math.min(
         math.max(
             finalLevelEndBar,
             finalShortStartBar + minLineBars),
         futureLimitBar)
 
// =========================================================
// EXTEND LEVELS LEFT
// =========================================================
 
float levelExtensionPct = 0.30
 
int longLevelWidth = longEndBar - finalLongStartBar
 
int shortLevelWidth = shortEndBar - finalShortStartBar
 
int extendedLongStartBar = finalLongStartBar - int(math.round(longLevelWidth * levelExtensionPct))
 
int extendedShortStartBar = finalShortStartBar - int(math.round(shortLevelWidth * levelExtensionPct))
 
// =========================================================
// LABEL POSITIONS
// =========================================================
 
int longLabelBar = extendedLongStartBar
 
int shortLabelBar = extendedShortStartBar
 
// =========================================================
// LEVERAGE
// =========================================================
 
float liq2 = 2.0
 
float liq3 = 3.0
 
float liq5 = 5.0
 
float liq7 = 7.0
 
float liq10 = 10.0
 
float liq20 = 20.0
 
float liq25 = 25.0
 
float liq30 = 30.0
 
float liq50 = 50.0
 
float liq100 = 100.0
 
// =========================================================
// LONG LIQUIDATION LEVELS
// =========================================================
 
float long2 = calcHigh * (1.0 - 1.0 / liq2)
 
float long3 = calcHigh * (1.0 - 1.0 / liq3)
 
float long5 = calcHigh * (1.0 - 1.0 / liq5)
 
float long7 = calcHigh * (1.0 - 1.0 / liq7)
 
float long10 = calcHigh * (1.0 - 1.0 / liq10)
 
float long20 = calcHigh * (1.0 - 1.0 / liq20)
 
float long25 = calcHigh * (1.0 - 1.0 / liq25)
 
float long30 = calcHigh * (1.0 - 1.0 / liq30)
 
float long50 = calcHigh * (1.0 - 1.0 / liq50)
 
float long100 = calcHigh * (1.0 - 1.0 / liq100)
 
// =========================================================
// SHORT LIQUIDATION LEVELS
// =========================================================
 
float short1 = calcLow * 2.0
 
float short2 = calcLow * (1.0 + 1.0 / liq2)
 
float short3 = calcLow * (1.0 + 1.0 / liq3)
 
float short5 = calcLow * (1.0 + 1.0 / liq5)
 
float short7 = calcLow * (1.0 + 1.0 / liq7)
 
float short10 = calcLow * (1.0 + 1.0 / liq10)
 
float short20 = calcLow * (1.0 + 1.0 / liq20)
 
float short25 = calcLow * (1.0 + 1.0 / liq25)
 
float short30 = calcLow * (1.0 + 1.0 / liq30)
 
float short50 = calcLow * (1.0 + 1.0 / liq50)
 
float short100 = calcLow * (1.0 + 1.0 / liq100)
 
// =========================================================
// LINES
// =========================================================
 
var line highReferenceLine = na
 
var line lowReferenceLine = na
 
var line longLine2 = na
 
var line longLine3 = na
 
var line longLine5 = na
 
var line longLine7 = na
 
var line longLine10 = na
 
var line longLine20 = na
 
var line longLine25 = na
 
var line longLine30 = na
 
var line longLine50 = na
 
var line longLine100 = na
 
var line shortLine1 = na
 
var line shortLine2 = na
 
var line shortLine3 = na
 
var line shortLine5 = na
 
var line shortLine7 = na
 
var line shortLine10 = na
 
var line shortLine20 = na
 
var line shortLine25 = na
 
var line shortLine30 = na
 
var line shortLine50 = na
 
var line shortLine100 = na
 
// =========================================================
// LABELS
// =========================================================
 
var label longLabel2 = na
 
var label longLabel3 = na
 
var label longLabel5 = na
 
var label longLabel7 = na
 
var label longLabel10 = na
 
var label longLabel20 = na
 
var label longLabel25 = na
 
var label longLabel30 = na
 
var label longLabel50 = na
 
var label longLabel100 = na
 
var label shortLabel1 = na
 
var label shortLabel2 = na
 
var label shortLabel3 = na
 
var label shortLabel5 = na
 
var label shortLabel7 = na
 
var label shortLabel10 = na
 
var label shortLabel20 = na
 
var label shortLabel25 = na
 
var label shortLabel30 = na
 
var label shortLabel50 = na
 
var label shortLabel100 = na
 
// =========================================================
// CREATE OBJECTS
// =========================================================
 
if barstate.isfirst
 
    highReferenceLine := line.new(
         na, na, na, na,
         xloc = xloc.bar_index,
         style = line.style_dashed,
         width = 1,
         color = longLevelColor)
 
    lowReferenceLine := line.new(
         na, na, na, na,
         xloc = xloc.bar_index,
         style = line.style_dashed,
         width = 1,
         color = shortLevelColor)
 
    longLine2 := line.new(na, na, na, na, xloc = xloc.bar_index, style = line.style_solid, width = 1, color = longLevelColor)
    longLine3 := line.new(na, na, na, na, xloc = xloc.bar_index, style = line.style_solid, width = 1, color = longLevelColor)
    longLine5 := line.new(na, na, na, na, xloc = xloc.bar_index, style = line.style_solid, width = 1, color = longLevelColor)
    longLine7 := line.new(na, na, na, na, xloc = xloc.bar_index, style = line.style_solid, width = 1, color = longLevelColor)
    longLine10 := line.new(na, na, na, na, xloc = xloc.bar_index, style = line.style_solid, width = 1, color = longLevelColor)
    longLine20 := line.new(na, na, na, na, xloc = xloc.bar_index, style = line.style_solid, width = 1, color = longLevelColor)
    longLine25 := line.new(na, na, na, na, xloc = xloc.bar_index, style = line.style_solid, width = 1, color = longLevelColor)
    longLine30 := line.new(na, na, na, na, xloc = xloc.bar_index, style = line.style_solid, width = 1, color = longLevelColor)
    longLine50 := line.new(na, na, na, na, xloc = xloc.bar_index, style = line.style_solid, width = 1, color = longLevelColor)
    longLine100 := line.new(na, na, na, na, xloc = xloc.bar_index, style = line.style_solid, width = 1, color = longLevelColor)
 
    shortLine1 := line.new(na, na, na, na, xloc = xloc.bar_index, style = line.style_solid, width = 1, color = shortLevelColor)
    shortLine2 := line.new(na, na, na, na, xloc = xloc.bar_index, style = line.style_solid, width = 1, color = shortLevelColor)
    shortLine3 := line.new(na, na, na, na, xloc = xloc.bar_index, style = line.style_solid, width = 1, color = shortLevelColor)
    shortLine5 := line.new(na, na, na, na, xloc = xloc.bar_index, style = line.style_solid, width = 1, color = shortLevelColor)
    shortLine7 := line.new(na, na, na, na, xloc = xloc.bar_index, style = line.style_solid, width = 1, color = shortLevelColor)
    shortLine10 := line.new(na, na, na, na, xloc = xloc.bar_index, style = line.style_solid, width = 1, color = shortLevelColor)
    shortLine20 := line.new(na, na, na, na, xloc = xloc.bar_index, style = line.style_solid, width = 1, color = shortLevelColor)
    shortLine25 := line.new(na, na, na, na, xloc = xloc.bar_index, style = line.style_solid, width = 1, color = shortLevelColor)
    shortLine30 := line.new(na, na, na, na, xloc = xloc.bar_index, style = line.style_solid, width = 1, color = shortLevelColor)
    shortLine50 := line.new(na, na, na, na, xloc = xloc.bar_index, style = line.style_solid, width = 1, color = shortLevelColor)
    shortLine100 := line.new(na, na, na, na, xloc = xloc.bar_index, style = line.style_solid, width = 1, color = shortLevelColor)
 
    longLabel2 := label.new(na, na, "", xloc = xloc.bar_index, style = label.style_label_left, size = size.small, color = longLevelColor, textcolor = labelTextColor)
    longLabel3 := label.new(na, na, "", xloc = xloc.bar_index, style = label.style_label_left, size = size.small, color = longLevelColor, textcolor = labelTextColor)
    longLabel5 := label.new(na, na, "", xloc = xloc.bar_index, style = label.style_label_left, size = size.small, color = longLevelColor, textcolor = labelTextColor)
    longLabel7 := label.new(na, na, "", xloc = xloc.bar_index, style = label.style_label_left, size = size.small, color = longLevelColor, textcolor = labelTextColor)
    longLabel10 := label.new(na, na, "", xloc = xloc.bar_index, style = label.style_label_left, size = size.small, color = longLevelColor, textcolor = labelTextColor)
    longLabel20 := label.new(na, na, "", xloc = xloc.bar_index, style = label.style_label_left, size = size.small, color = longLevelColor, textcolor = labelTextColor)
    longLabel25 := label.new(na, na, "", xloc = xloc.bar_index, style = label.style_label_left, size = size.small, color = longLevelColor, textcolor = labelTextColor)
    longLabel30 := label.new(na, na, "", xloc = xloc.bar_index, style = label.style_label_left, size = size.small, color = longLevelColor, textcolor = labelTextColor)
    longLabel50 := label.new(na, na, "", xloc = xloc.bar_index, style = label.style_label_left, size = size.small, color = longLevelColor, textcolor = labelTextColor)
    longLabel100 := label.new(na, na, "", xloc = xloc.bar_index, style = label.style_label_left, size = size.small, color = longLevelColor, textcolor = labelTextColor)
 
    shortLabel1 := label.new(na, na, "", xloc = xloc.bar_index, style = label.style_label_left, size = size.small, color = shortLevelColor, textcolor = labelTextColor)
    shortLabel2 := label.new(na, na, "", xloc = xloc.bar_index, style = label.style_label_left, size = size.small, color = shortLevelColor, textcolor = labelTextColor)
    shortLabel3 := label.new(na, na, "", xloc = xloc.bar_index, style = label.style_label_left, size = size.small, color = shortLevelColor, textcolor = labelTextColor)
    shortLabel5 := label.new(na, na, "", xloc = xloc.bar_index, style = label.style_label_left, size = size.small, color = shortLevelColor, textcolor = labelTextColor)
    shortLabel7 := label.new(na, na, "", xloc = xloc.bar_index, style = label.style_label_left, size = size.small, color = shortLevelColor, textcolor = labelTextColor)
    shortLabel10 := label.new(na, na, "", xloc = xloc.bar_index, style = label.style_label_left, size = size.small, color = shortLevelColor, textcolor = labelTextColor)
    shortLabel20 := label.new(na, na, "", xloc = xloc.bar_index, style = label.style_label_left, size = size.small, color = shortLevelColor, textcolor = labelTextColor)
    shortLabel25 := label.new(na, na, "", xloc = xloc.bar_index, style = label.style_label_left, size = size.small, color = shortLevelColor, textcolor = labelTextColor)
    shortLabel30 := label.new(na, na, "", xloc = xloc.bar_index, style = label.style_label_left, size = size.small, color = shortLevelColor, textcolor = labelTextColor)
    shortLabel50 := label.new(na, na, "", xloc = xloc.bar_index, style = label.style_label_left, size = size.small, color = shortLevelColor, textcolor = labelTextColor)
    shortLabel100 := label.new(na, na, "", xloc = xloc.bar_index, style = label.style_label_left, size = size.small, color = shortLevelColor, textcolor = labelTextColor)
 
// =========================================================
// DRAW
// =========================================================
 
if barstate.islast
 
    bool validHigh =
         not na(calcHigh) and
         not na(calcHighBar) and
         not na(finalLongStartBar)
 
    bool validLow =
         not na(calcLow) and
         not na(calcLowBar) and
         not na(finalShortStartBar)
 
    // =====================================================
    // REFERENCE HIGH
    // =====================================================
 
    if showReference and showHighLevels and validHigh
 
        line.set_xy1(
             highReferenceLine,
             calcHighBar,
             calcHigh)
 
        line.set_xy2(
             highReferenceLine,
             longEndBar,
             calcHigh)
 
    else
 
        line.set_xy1(
             highReferenceLine,
             na,
             na)
 
        line.set_xy2(
             highReferenceLine,
             na,
             na)
 
    // =====================================================
    // REFERENCE LOW
    // =====================================================
 
    if showReference and showLowLevels and validLow
 
        line.set_xy1(
             lowReferenceLine,
             calcLowBar,
             calcLow)
 
        line.set_xy2(
             lowReferenceLine,
             shortEndBar,
             calcLow)
 
    else
 
        line.set_xy1(
             lowReferenceLine,
             na,
             na)
 
        line.set_xy2(
             lowReferenceLine,
             na,
             na)
 
    // =====================================================
    // LONG LEVELS
    // =====================================================
 
    if showHighLevels and show2x and validHigh
 
        line.set_xy1(longLine2, extendedLongStartBar, long2)
        line.set_xy2(longLine2, longEndBar, long2)
 
    else
 
        line.set_xy1(longLine2, na, na)
        line.set_xy2(longLine2, na, na)
 
    if showHighLevels and show3x and validHigh
 
        line.set_xy1(longLine3, extendedLongStartBar, long3)
        line.set_xy2(longLine3, longEndBar, long3)
 
    else
 
        line.set_xy1(longLine3, na, na)
        line.set_xy2(longLine3, na, na)
 
    if showHighLevels and show5x and validHigh
 
        line.set_xy1(longLine5, extendedLongStartBar, long5)
        line.set_xy2(longLine5, longEndBar, long5)
 
    else
 
        line.set_xy1(longLine5, na, na)
        line.set_xy2(longLine5, na, na)
 
    if showHighLevels and show7x and validHigh
 
        line.set_xy1(longLine7, extendedLongStartBar, long7)
        line.set_xy2(longLine7, longEndBar, long7)
 
    else
 
        line.set_xy1(longLine7, na, na)
        line.set_xy2(longLine7, na, na)
 
    if showHighLevels and show10x and validHigh
 
        line.set_xy1(longLine10, extendedLongStartBar, long10)
        line.set_xy2(longLine10, longEndBar, long10)
 
    else
 
        line.set_xy1(longLine10, na, na)
        line.set_xy2(longLine10, na, na)
 
    if showHighLevels and show20x and validHigh
 
        line.set_xy1(longLine20, extendedLongStartBar, long20)
        line.set_xy2(longLine20, longEndBar, long20)
 
    else
 
        line.set_xy1(longLine20, na, na)
        line.set_xy2(longLine20, na, na)
 
    if showHighLevels and show25x and validHigh
 
        line.set_xy1(longLine25, extendedLongStartBar, long25)
        line.set_xy2(longLine25, longEndBar, long25)
 
    else
 
        line.set_xy1(longLine25, na, na)
        line.set_xy2(longLine25, na, na)
 
    if showHighLevels and show30x and validHigh
 
        line.set_xy1(longLine30, extendedLongStartBar, long30)
        line.set_xy2(longLine30, longEndBar, long30)
 
    else
 
        line.set_xy1(longLine30, na, na)
        line.set_xy2(longLine30, na, na)
 
    if showHighLevels and show50x and validHigh
 
        line.set_xy1(longLine50, extendedLongStartBar, long50)
        line.set_xy2(longLine50, longEndBar, long50)
 
    else
 
        line.set_xy1(longLine50, na, na)
        line.set_xy2(longLine50, na, na)
 
    if showHighLevels and show100x and validHigh
 
        line.set_xy1(longLine100, extendedLongStartBar, long100)
        line.set_xy2(longLine100, longEndBar, long100)
 
    else
 
        line.set_xy1(longLine100, na, na)
        line.set_xy2(longLine100, na, na)
 
    // =====================================================
    // SHORT LEVELS
    // =====================================================
 
    if showLowLevels and show1x and validLow
 
        line.set_xy1(shortLine1, extendedShortStartBar, short1)
        line.set_xy2(shortLine1, shortEndBar, short1)
 
    else
 
        line.set_xy1(shortLine1, na, na)
        line.set_xy2(shortLine1, na, na)
 
    if showLowLevels and show2x and validLow
 
        line.set_xy1(shortLine2, extendedShortStartBar, short2)
        line.set_xy2(shortLine2, shortEndBar, short2)
 
    else
 
        line.set_xy1(shortLine2, na, na)
        line.set_xy2(shortLine2, na, na)
 
    if showLowLevels and show3x and validLow
 
        line.set_xy1(shortLine3, extendedShortStartBar, short3)
        line.set_xy2(shortLine3, shortEndBar, short3)
 
    else
 
        line.set_xy1(shortLine3, na, na)
        line.set_xy2(shortLine3, na, na)
 
    if showLowLevels and show5x and validLow
 
        line.set_xy1(shortLine5, extendedShortStartBar, short5)
        line.set_xy2(shortLine5, shortEndBar, short5)
 
    else
 
        line.set_xy1(shortLine5, na, na)
        line.set_xy2(shortLine5, na, na)
 
    if showLowLevels and show7x and validLow
 
        line.set_xy1(shortLine7, extendedShortStartBar, short7)
        line.set_xy2(shortLine7, shortEndBar, short7)
 
    else
 
        line.set_xy1(shortLine7, na, na)
        line.set_xy2(shortLine7, na, na)
 
    if showLowLevels and show10x and validLow
 
        line.set_xy1(shortLine10, extendedShortStartBar, short10)
        line.set_xy2(shortLine10, shortEndBar, short10)
 
    else
 
        line.set_xy1(shortLine10, na, na)
        line.set_xy2(shortLine10, na, na)
 
    if showLowLevels and show20x and validLow
 
        line.set_xy1(shortLine20, extendedShortStartBar, short20)
        line.set_xy2(shortLine20, shortEndBar, short20)
 
    else
 
        line.set_xy1(shortLine20, na, na)
        line.set_xy2(shortLine20, na, na)
 
    if showLowLevels and show25x and validLow
 
        line.set_xy1(shortLine25, extendedShortStartBar, short25)
        line.set_xy2(shortLine25, shortEndBar, short25)
 
    else
 
        line.set_xy1(shortLine25, na, na)
        line.set_xy2(shortLine25, na, na)
 
    if showLowLevels and show30x and validLow
 
        line.set_xy1(shortLine30, extendedShortStartBar, short30)
        line.set_xy2(shortLine30, shortEndBar, short30)
 
    else
 
        line.set_xy1(shortLine30, na, na)
        line.set_xy2(shortLine30, na, na)
 
    if showLowLevels and show50x and validLow
 
        line.set_xy1(shortLine50, extendedShortStartBar, short50)
        line.set_xy2(shortLine50, shortEndBar, short50)
 
    else
 
        line.set_xy1(shortLine50, na, na)
        line.set_xy2(shortLine50, na, na)
 
    if showLowLevels and show100x and validLow
 
        line.set_xy1(shortLine100, extendedShortStartBar, short100)
        line.set_xy2(shortLine100, shortEndBar, short100)
 
    else
 
        line.set_xy1(shortLine100, na, na)
        line.set_xy2(shortLine100, na, na)
 
    // =====================================================
    // LONG LABELS
    // =====================================================
 
    if showLabels and showHighLevels and show2x and validHigh
 
        label.set_xy(longLabel2, longLabelBar, long2)
        label.set_text(longLabel2, "2x  -50%  " + str.tostring(long2, format.mintick))
 
    else
 
        label.set_text(longLabel2, "")
 
    if showLabels and showHighLevels and show3x and validHigh
 
        label.set_xy(longLabel3, longLabelBar, long3)
        label.set_text(longLabel3, "3x  -33.3%  " + str.tostring(long3, format.mintick))
 
    else
 
        label.set_text(longLabel3, "")
 
    if showLabels and showHighLevels and show5x and validHigh
 
        label.set_xy(longLabel5, longLabelBar, long5)
        label.set_text(longLabel5, "5x  -20%  " + str.tostring(long5, format.mintick))
 
    else
 
        label.set_text(longLabel5, "")
 
    if showLabels and showHighLevels and show7x and validHigh
 
        label.set_xy(longLabel7, longLabelBar, long7)
        label.set_text(longLabel7, "7x  -14.3%  " + str.tostring(long7, format.mintick))
 
    else
 
        label.set_text(longLabel7, "")
 
    if showLabels and showHighLevels and show10x and validHigh
 
        label.set_xy(longLabel10, longLabelBar, long10)
        label.set_text(longLabel10, "10x  -10%  " + str.tostring(long10, format.mintick))
 
    else
 
        label.set_text(longLabel10, "")
 
    if showLabels and showHighLevels and show20x and validHigh
 
        label.set_xy(longLabel20, longLabelBar, long20)
        label.set_text(longLabel20, "20x  -5%  " + str.tostring(long20, format.mintick))
 
    else
 
        label.set_text(longLabel20, "")
 
    if showLabels and showHighLevels and show25x and validHigh
 
        label.set_xy(longLabel25, longLabelBar, long25)
        label.set_text(longLabel25, "25x  -4%  " + str.tostring(long25, format.mintick))
 
    else
 
        label.set_text(longLabel25, "")
 
    if showLabels and showHighLevels and show30x and validHigh
 
        label.set_xy(longLabel30, longLabelBar, long30)
        label.set_text(longLabel30, "30x  -3.3%  " + str.tostring(long30, format.mintick))
 
    else
 
        label.set_text(longLabel30, "")
 
    if showLabels and showHighLevels and show50x and validHigh
 
        label.set_xy(longLabel50, longLabelBar, long50)
        label.set_text(longLabel50, "50x  -2%  " + str.tostring(long50, format.mintick))
 
    else
 
        label.set_text(longLabel50, "")
 
    if showLabels and showHighLevels and show100x and validHigh
 
        label.set_xy(longLabel100, longLabelBar, long100)
        label.set_text(longLabel100, "100x  -1%  " + str.tostring(long100, format.mintick))
 
    else
 
        label.set_text(longLabel100, "")
 
    // =====================================================
    // SHORT LABELS
    // =====================================================
 
    if showLabels and showLowLevels and show1x and validLow
 
        label.set_xy(shortLabel1, shortLabelBar, short1)
        label.set_text(shortLabel1, "1x  +100%  " + str.tostring(short1, format.mintick))
 
    else
 
        label.set_text(shortLabel1, "")
 
    if showLabels and showLowLevels and show2x and validLow
 
        label.set_xy(shortLabel2, shortLabelBar, short2)
        label.set_text(shortLabel2, "2x  +50%  " + str.tostring(short2, format.mintick))
 
    else
 
        label.set_text(shortLabel2, "")
 
    if showLabels and showLowLevels and show3x and validLow
 
        label.set_xy(shortLabel3, shortLabelBar, short3)
        label.set_text(shortLabel3, "3x  +33.3%  " + str.tostring(short3, format.mintick))
 
    else
 
        label.set_text(shortLabel3, "")
 
    if showLabels and showLowLevels and show5x and validLow
 
        label.set_xy(shortLabel5, shortLabelBar, short5)
        label.set_text(shortLabel5, "5x  +20%  " + str.tostring(short5, format.mintick))
 
    else
 
        label.set_text(shortLabel5, "")
 
    if showLabels and showLowLevels and show7x and validLow
 
        label.set_xy(shortLabel7, shortLabelBar, short7)
        label.set_text(shortLabel7, "7x  +14.3%  " + str.tostring(short7, format.mintick))
 
    else
 
        label.set_text(shortLabel7, "")
 
    if showLabels and showLowLevels and show10x and validLow
 
        label.set_xy(shortLabel10, shortLabelBar, short10)
        label.set_text(shortLabel10, "10x  +10%  " + str.tostring(short10, format.mintick))
 
    else
 
        label.set_text(shortLabel10, "")
 
    if showLabels and showLowLevels and show20x and validLow
 
        label.set_xy(shortLabel20, shortLabelBar, short20)
        label.set_text(shortLabel20, "20x  +5%  " + str.tostring(short20, format.mintick))
 
    else
 
        label.set_text(shortLabel20, "")
 
    if showLabels and showLowLevels and show25x and validLow
 
        label.set_xy(shortLabel25, shortLabelBar, short25)
        label.set_text(shortLabel25, "25x  +4%  " + str.tostring(short25, format.mintick))
 
    else
 
        label.set_text(shortLabel25, "")
 
    if showLabels and showLowLevels and show30x and validLow
 
        label.set_xy(shortLabel30, shortLabelBar, short30)
        label.set_text(shortLabel30, "30x  +3.3%  " + str.tostring(short30, format.mintick))
 
    else
 
        label.set_text(shortLabel30, "")
 
    if showLabels and showLowLevels and show50x and validLow
 
        label.set_xy(shortLabel50, shortLabelBar, short50)
        label.set_text(shortLabel50, "50x  +2%  " + str.tostring(short50, format.mintick))
 
    else
 
        label.set_text(shortLabel50, "")
 
    if showLabels and showLowLevels and show100x and validLow
 
        label.set_xy(shortLabel100, shortLabelBar, short100)
        label.set_text(shortLabel100, "100x  +1%  " + str.tostring(short100, format.mintick))
 
    else
 
        label.set_text(shortLabel100, "")

← 返回列表