Search code examples
pine-scriptpine-script-v5

Request.Security repainting the screener result when referring higher timeframe


I am trying to get the Previous Day High and Low using Request.Security. Here is my Code.

dh_func(sym) =>        
sema = ta.ema(close, ema_len)
//////////
/// Get Days High///

[h1,h2,l1,l2] = request.security(sym, 'D', [high[0],high[1],low[0],low[1]])    
//[h1,h2,l1,l2] = rp_security(sym, 'D')    
dh = (ta.cross(sema,math.max(h1,h2)) and isToday) or (ta.cross(close,math.max(h1,h2)) and isToday)
dl = (ta.cross(sema,math.min(l1,l2)) and isToday) or (ta.cross(close,math.min(l1,l2)) and isToday)
[dh,dl]

It is working fine, but when the candle closed in lower timeframe, the screener results are getting blank.

Please help me to solve the issue.

Note: I have also tried using f_security() it didn't work either.


Solution

  • Finally it is resolved, f_security() worked, issue was related to ta.cross() now I am checking only

    dh = close[1] > h1 and isToday
    

    it worked.