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".

Can someone explain me what the below pinescript does

Jun 4, 2020 - 11:31 PM

Viewed 1057 times

https://best-trading-indicator.com/community/bti/forums/4180/topics/17243 COPY
  • Hi I got the below pinescript code from trading view. I want to convert it to trade script, so need to understand it.

    range = high - low

    // Daily line breaks
    sopen = security(tickerid, D, open)

    a=range[1]*0.382
    b=range[1]*0.618
    h=sopen+a
    h1=sopen+b
    l=sopen-a
    l1=sopen-b

    // Color
    hcolor=sopen != sopen[1] ? na : maroon
    hcolor1=sopen != sopen[1] ? na : red
    lcolor=sopen != sopen[1] ? na : green
    lcolor1=sopen != sopen[1] ? na : lime

    //Daily Range
    highrange1 = security(tickerid, 'D', h)
    highrange2 = security(tickerid, 'D', h1)
    lowrange1 = security(tickerid, 'D', l)
    lowrange2 = security(tickerid, 'D', l1)

    highrange3 = (highrange1 + highrange2) /2
    lowrange3 = (lowrange1 + lowrange2) /2

    offs_daily = 0
    //H1=plot(sr and highrange1 ? highrange1 : na, title=Daily High1,color=hcolor, linewidth=1)
    H1=plot(sr and highrange3 ? highrange3 : na, title=Daily High1,color=hcolor, linewidth=1)
    H2=plot(sr and highrange2 ? highrange2 : na, title=Daily Daily High2, color=hcolor1, linewidth=1)
    //L1=plot(sr and lowrange1 ? lowrange1 : na, title=Daily Low1,color=lcolor, linewidth=1)
    L1=plot(sr and lowrange3 ? lowrange3 : na, title=Daily Low1,color=lcolor, linewidth=1)
    L2=plot(sr and lowrange2 ? lowrange2 : na, title=Daily Daily Low2, color=lcolor1, linewidth=1)

    fill(H1,H2,color=maroon)
    fill(L1,L2,color=lime)

    0
  • Hi @papair

    Seems your script is plotting Daily repainting daily Fibonacci pivots

    I saw some issues in that script that must be fixed to remove the repainting side-effect

    0

    Dave - Helping traders becoming the best version of themselves
  • Hi @daveatt

    Thanks for your response. I was actually looking for a detailed description of what this script does. My trading system is based on tradescript, so i wanted to convert this code to that platform.
    But the problem is i am not so good with pinescript, so i am not able to understand how it is getting these values.

    For example:=

    What is :-

    range[1]
    highrange2 = security(tickerid, 'D', h1)

    0
  • You may want to read the documentation for that
    https://www.tradingview.com/pine-script-reference/v4/#fun_label%7Bdot%7Dnew
    and that one https://www.pinecoders.com/faq_and_code/

    range[1] means accessing the previous range variable value

    highrange2 = security(tickerid, 'D', h1) = means access the current daily h1 variable value

    0

    Dave - Helping traders becoming the best version of themselves
CONTENTS