Here are my inputs:
BandBars = input(14, "Count of Bars for Band")
Deviation = input(1.5, "Deviation")
Here is the function
Trend_Risk(close_tf, low_tf, high_tf) =>
float SmoothPrice = na
SmoothPrice := na(SmoothPrice[1]) ? close_tf : (SmoothPrice[1] * (BandBars - 1) + close_tf) / BandBars
float SmoothRange = na
SmoothRange := na(SmoothRange[1]) ? high_tf - low_tf : (SmoothRange[1] * (BandBars - 1) + high_tf - low_tf) / BandBars
Top = SmoothPrice + SmoothRange * Deviation
Bottom = SmoothPrice - SmoothRange * Deviation
[Top, Bottom]
// Indicator calculations for trade signal
Ema_5m = security(syminfo.tickerid, tf2, ema(close, len_ema))
f() => [close, low, high]
[close_5m, low_5m, high_5m] = security(syminfo.tickerid, tf2, f())
[Top_5m, Bottom_5m] = Trend_Risk(close_tf = close_5m, low_tf = low_5m, high_tf = high_5m)
//. 1 H time frame for confirmation of trend
Ema_1h = security(syminfo.tickerid, tf1, ema(close, len_ema))
[close_1h, low_1h, high_1h] = security(syminfo.tickerid, tf1, f())
[Top_1h, Bottom_1h] = Trend_Risk(close_tf = close_1h, low_tf = low_1h, high_tf = high_1h)
// below this are entry exit rules which uses top and bottom and price comparison and plots.
plot(Top_chart, "Top", #EF5350)
plot(Bottom_chart, "Bottom", #26A69A)
plot(Ema_chart, "EMA", color.blue)
Here is the Error:
./TVScriptAnalyzer.g: node from line undefined:-1 Mismatched input 'BandBars' expecting <UP>.
Any help would be much appreciated as if you have encountered this error before, what would be the cases when this error shows up or if I am doing something that is out of the scope of pine script, please ask questions for clarification if required.
question from:
https://stackoverflow.com/questions/66064241/input-variables-not-accessible-inside-function 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…