I’m writing a custom indicator script extending the “LuxAlgo – Predictive Ranges” indicator. However, I’ve noticed a strange thing.
If I plot the indicator on a 5-min chart (I’m using “BANKNIFTY” symbol) and configure indicator settings as:
Length: 50; Factor: 6; Timeframe: 5 minutes; Source: close
On the chart, everything looks good. But the problem arises when I add an alert based on the plotted levels. The levels plotted on the 5-min chart are way off than what I get in the alert even when the alert is based on the exact same settings. The alert instead returns levels I would get on a 15-min chart with (50 6 5 close) setting.
So to summarise my question:
Expected behaviour:
levels returned by alert with (50 6 5 close) setting on 5-min chart <- SHOULD MATCH WITH -> leveLs displayed on 5-min chart with (50 6 5 close) setting
Observed behaviour:
levels returned by alert with (50 6 5 close) setting on 5-min chart <- MATCH WITH -> levels displayed on 15-min chart with (50 6 5 close) setting
I tried several tweaks with request.security in the original LuxAlgo script and also tried to remove it keeping just the “pred_ranges” function call, but none worked.
ATR levels computation function that gives this strange behaviour:
pred_ranges(length, mult)=>
var avg = src
var hold_atr = 0.
atr = nz(ta.atr(length)) * mult
avg := src - avg > atr ? avg + atr :
avg - src > atr ? avg - atr :
avg
hold_atr := avg != avg[1] ? atr / 2 : hold_atr
[avg + hold_atr * 2, avg + hold_atr, avg, avg - hold_atr, avg - hold_atr * 2]
The call to the function:
[prR2, prR1, avg, prS1, prS2] = request.security(syminfo.tickerid, tf, pred_ranges(length, mult))
Any pointers would be greatly appreciated.