Pinescript lines – Problem with scale / chart reset

Sorry for my english, i just started to lern pine script I make an Indicator wir support and resistance lines with some help von AI.

It works good, but i have a Problem if i want to “Reset chart view”, it is very small to show all the lines.

//@version=5
indicator("Levels", overlay=true)

// Line color option
lineColor = input(color.new(color.blue, 30), title="Line Color")

// Settings for line display
showLines = input(true, title="Show Lines", group="Levels")

// Arrays to store line IDs and their corresponding support/resistance levels
var float[] supportLevels = array.new_float()
var line[] supportLines = array.new_line()
var float[] resistanceLevels = array.new_float()
var line[] resistanceLines = array.new_line()

// Function to identify bullish and bearish candles
isBullishCandle(open, close) =>
    close > open

isBearishCandle(open, close) =>
    close < open

// Function to check if a bearish candle follows a bullish candle
isBearishAfterBullish() =>
    isBullishCandle(open[1], close[1]) and isBearishCandle(open, close)

// Function to check if a bullish candle follows a bearish candle
isBullishAfterBearish() =>
    isBearishCandle(open[1], close[1]) and isBullishCandle(open, close)

// Variable to store the new support level
var float supportLevel = na

// Check for new support levels
if showLines and isBullishAfterBearish()
    supportLevel := low
    array.push(supportLevels, supportLevel)
    supportLineID = line.new(x1=bar_index, y1=supportLevel, x2=bar_index + 10, y2=supportLevel, color=lineColor, width=1, extend=extend.right)
    array.push(supportLines, supportLineID)

// Update existing support lines and delete if broken
i = array.size(supportLevels) - 1
while i >= 0
    supportLevel := array.get(supportLevels, i)
    supportLineID = array.get(supportLines, i)
    
    if (close < supportLevel)
        line.delete(supportLineID)
        array.remove(supportLevels, i)
        array.remove(supportLines, i)
    else
        line.set_x2(supportLineID, bar_index + 10)
    i := i - 1

// Variable to store the new resistance level
var float resistanceLevel = na

// Check for new resistance levels
if showLines and isBearishAfterBullish()
    resistanceLevel := high
    array.push(resistanceLevels, resistanceLevel)
    resistanceLineID = line.new(x1=bar_index, y1=resistanceLevel, x2=bar_index + 10, y2=resistanceLevel, color=lineColor, width=1, extend=extend.right)
    array.push(resistanceLines, resistanceLineID)

// Update existing resistance lines and delete if broken
j = array.size(resistanceLevels) - 1
while j >= 0
    resistanceLevel := array.get(resistanceLevels, j)
    resistanceLineID = array.get(resistanceLines, j)
    
    if (close > resistanceLevel)
        line.delete(resistanceLineID)
        array.remove(resistanceLevels, j)
        array.remove(resistanceLines, j)
    else
        line.set_x2(resistanceLineID, bar_index + 10)
    j := j - 1

I tried with scaling=scaling.none, but the lines don`t follow the price.

New contributor

Karol is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật