0

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

sey eeet
  • 229
  • 2
  • 8

1 Answers1

1

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.

elod008
  • 1,227
  • 1
  • 5
  • 15
  • Thank you for your help @elod008. The issue is with plotting them I guess? when I plot the results I see more than one low in one day, which does not make sense to me, basically I was expecting to see one low during each day, and also in the plot I have `plotshape(sec_peakLow, style=shape.triangleup, location=location.belowbar, color=color.new(color.red,50), offset = -1 , size=size.auto)`, but I guess that `offset` should change in the `security` version, but not sure how – sey eeet Dec 18 '22 at 13:46
  • I think you probably should find a different approach. Offset does not do anything to your security call values, it just offsets your output by -1 bar on your current TF. I'm updating my answer with an alternative solution. – elod008 Dec 18 '22 at 14:23