T K ABHISHEK
T K ABHISHEK

Reputation: 1

How to get high & low price price of a specific candle for specific time in trading-view pine script

sir, I wants to convert my idea in pine script (strategy). For this I need some data which I am unable to fetch...

  1. previous day last 5 minute candle high & low. (market close at 15.30)
  2. current day first 5 minute candle high & low. (market pre-opens at 09.00, but trading starts at 09.15.)

plz suggest the pine script coding for getting this data.

Upvotes: 0

Views: 4973

Answers (1)

Bjorgum
Bjorgum

Reputation: 2310

I will assume that you will have extended data turned on as you are referencing premarket in your question. Please note this requires this to be the case or it requires different code.

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

var lastHigh    = 0.0
var lastLow     = 0.0
var newHigh     = 0.0
var newLow      = 0.0

if session.ismarket[1] and not session.ismarket
    lastHigh    := high[1]
    lastLow     := low[1]

if session.ismarket and not session.ismarket[1]
    newHigh     := high
    newLow      := low
    
plot(lastHigh, color=color.red)
plot(lastLow , color=color.red)
plot(newHigh , color=color.yellow)
plot(newLow  , color=color.yellow)

Cheers my friend and take care

Upvotes: 1

Related Questions