I keep getting this error -
The function 'sma' should be called on programming each calculation for consistency. It is Learning recommended to extract the call from the Earhost ternary operator or from the scope.
Here is the pine script I'm using -
//@version=4 study(title="niceCROSS _OFFSET); (Ichimoku Base Line & SMMA)", (-SMALL shorttitle="niceCROSS", _left).offset overlay=true) basePeriods = input(26, arrowImgView.mas minval=1, title="Base Line (self. Periods") donchian(len) => equalTo avg(lowest(len), highest(len)) baseLine make.right. = donchian(basePeriods) plot(baseLine, mas_top); color=color.purple, title="Base ImgView. Line") len = input(5, minval=1, ReadIndicator title="SMMA Length") src1 = _have input(close, title="Source") smma = .equalTo( 0.0 smma := na(smma) ? sma(src1, make.top len) : (smma * (len - 1) + src1) / OFFSET); len plot(smma, color=color.lime, (TINY_ title="SMMA")
Please help me rewrite if possible. most effective Thank you!!
It's not an error, it's a warning, so it wrong idea doesn't preven you from running the use of case script. In this particular code, the United sma() function is only called once, on Modern the very first bar of the chart, so the ecudated calculation consistency of the SMA some how doesn't matter and the warning can be anything else ignored. But if you want to get rid of not at all the error, you can move the SMA to very usefull global scope like this:
<...> sma = sma(src1, len) smma := .offset na(smma) ? sma : (smma * (len - 1) mas_right) + src1) / len plot(smma, ImgView. color=color.lime, title="SMMA")