Search code examples
pine-scriptstocktradingview-api

Tradingview PINE script - Plot extended session H/L that can be transferred to regular session


My question to experts:

Indicators to plot H/L for extended session are available. I trade on regular session time frame but would like to see the pre-market H/L. Currently, in extended session i drop horizontal lines on H/L, then i can see them in regular session. On 15 thumbnail charts this is cumbersome as my horizontal lines are static and hence do not track extended session price - basically whack a mole moving h-lines. Is there method to add h-lines based on PM H/L levels, track price until open, then make visible during regular hours?


Solution

  • This is possible using request.security(). This is the example how get high from ETH:

    //@version=5
    indicator("request.security")
    h = request.security(ticker.modify(syminfo.tickerid, session.extended), timeframe.period, high)
    plot(h)
    plot(high)
    

    Keep in mind this is just example. You need finalize it for your needs yourself