Welcome to the BEST forum for traders

Did you know we're sharing tons of exclusive content here?
Our community is growing quickly. Take a look around and say "Hello".

Chart screener

Oct 20, 2020 - 5:57 PM

Viewed 538 times

https://best-trading-indicator.com/community/bti/forums/4180/topics/20805 COPY
  • Hello All,
    I'm fairly new to pine script programming. I can't get my head around he script below. What i want is a loop where in that loop there's a check if the tickers pass the custom function. Don't know if i say it correctly, maybe the code will help. Eventually there's a label on the chart that contains only those tickers that pass the customFuncW()

    ========================

    s20ema = ema(close, 20)
    s50sma = sma(close, 50)
    s200sma = sma(close, 200)

    scr_label = 'Screener: \n##########\n'

    ticker_s1 = 'ADAUSDT'
    ticker_s2 = 'ADXBTC'
    ticker_s3 = 'AEBTC'
    ticker_s4 = 'AGIBTC'
    ticker_s5 = 'AIONBTC'

    ha_period = W // Chart on which Master Direction is based
    ha_open = security(heikinashi(ticker_s1), ha_period, open)
    ha_close = security(heikinashi(ticker_s1), ha_period, close)
    //ha open and close should't use ticker_s1 but the ticker thats next in the loop...??

    customFuncW() => (s20ema > s50sma) and (s50sma > s200sma) and (ha_close < ha_open)

    s1 = security(ticker_s1, 'W', customFuncW())
    s2 = security('ADXBTC', 'W', customFuncW())
    s3 = security('AEBTC', 'W', customFuncW())
    s4 = security('AGIBTC', 'W', customFuncW())
    s5 = security('AIONBTC', 'W', customFuncW())

    s = 1
    for i = 0 to 5
    s := s + 1
    scr_label := s[i] ? scr_label + ticker_s[i] + '\n' : scr_label

    //this loop doesn't work

    lab_l = label.new(
    bar_index, -0.2, scr_label,
    color=color.gray,
    textcolor=color.black,
    style = label.style_labeldown,
    yloc = yloc.price)

    label.delete(lab_l[1])

    plot(0, transp = 100)

    =================

    Anyone an idea???

    1
  • Hi @lgoffert

    Which part of your script isn't working?

    The -0.2 below is weird. You say that you want to print the label at price value being -0.2 but it's not possible as they starts from 0

    [code]
    lab_l = label.new(bar_index, -0.2, scr_label, color=color.gray, textcolor=color.black, style = label.style_labeldown, yloc = yloc.price)
    [/code]

    Is your study set with overlay=true or overlay=false?

    0

    Dave - Helping traders becoming the best version of themselves
CONTENTS