sey eeet
sey eeet

Reputation: 258

how to use request.security correctly for finding the lows in lower timeframes

I can find the lows based on

sec_peakLow = ta.pivotlow(1, 1)
plotshape(sec_peakLow,    style=shape.triangleup,   location=location.belowbar, color=color.new(color.red,50),   offset = -1 , size=size.auto)

now I am wondering if I can use the pivotlow(1, 1) in a way that it be fixed for 1D and show the results in 1D while I am in the lower timeframes. So I tried


string CustomTimeFrame = input.timeframe("1D")
sec_peakLow = request.security(syminfo.tickerid, CustomTimeFrame, ta.pivotlow(1, 1))
plotshape(sec_peakLow,    style=shape.triangleup,   location=location.belowbar, color=color.new(color.red,50),   offset = -1 , size=size.auto)

however this lead to very wrong results. I was wondering if someone can please help me to undertand what is the issue and how I can solve the problem?

enter image description here enter image description here

Upvotes: 0

Views: 601

Answers (1)

elod008
elod008

Reputation: 1362

Basically the way you used request.security() is correct, the result correctness may however depend on what exactly you want and expect. I think another approach could very well better fit your needs but it's up to you.

ll = request.security("", "1D", ta.pivotlow(1,1))
plot(ll)

By plotting your request you can see the results are valid (tested on 4h). Although they may look incorrect - depending on your expectations.
This setting gives you the pivot low with a 1 bar confirmation on 1D, which means it'll serve you delayed data and you're not getting the daily low real time if that's what you'd want. You can play with the gaps and lookahead parameters if you wish but that would not solve the problem you may have stated above. About those parameters you can find an excellent answer from @vitruvius here

If your goal is to get the daily low real time, you'll need to evaluate it within your current timeframe.

UPDATE Alternative solution suggestion after further clarification that may meet your needs:

//@version=5
indicator("My script", "t", true)

var float lastLowest = 0
lastLowestTmp = ta.lowest(low, timeframe.in_seconds('1D') / timeframe.in_seconds())
if ta.change(dayofmonth, 1)
    lastLowest := lastLowestTmp
plot(lastLowest)

This would give you the lowest low of the last day. That's only one approach. It really depends on what exactly you want to get.

Upvotes: 1

Related Questions