Pine Script Error: The function sma should be called on each calculation for consistency

Questions : Pine Script Error: The function sma should be called on each calculation for consistency

460

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[1]) ? sma(src1, make.top  len) : (smma[1] * (len - 1) + src1) / OFFSET);  len

plot(smma, color=color.lime, (TINY_  title="SMMA")

Please help me rewrite if possible. most effective Thank you!!

Total Answers 1
29

Answers 1 : of Pine Script Error: The function sma should be called on each calculation for consistency

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[1]) ? sma : (smma[1] * (len - 1) mas_right)  + src1) / len
plot(smma, ImgView.  color=color.lime, title="SMMA")

Top rated topics

Egg dropping puzzle

Create a Dynamic Number of New Columns in a Data Frame Based on the Levels in a Vector

Implementing sklearn PCA on limited number of variables in a pipeline

How can I display the results of a function in React?

Can't import qgis module to run python scripts external to QGIS

Difference between PRTG and Grafana

How to install pg gem for ruby 3.0

How to code this cli command such that the test pass?

Definition of terms used in APIs, such as Endpoints

Power and logarithm in Z3

How to include interaction variable in linear fixed effects model with lfe package in R?

How to extract performance information?

How to fix arguments for scale_x_date in R code (ggplot2)?

Build 32-bit fmt with msbuild

Unable to access firebase using w5500 ethernet module with arduino

"message": "Error: You do not have permission to perform this action. 'Traceback (most recent call last):\\n File \"/opt/dev-application/django-app

Aws managed redis taking around 300ms to send data

Pyspark - How to define MapType for when/otherwise

In python How to get rid of dist files when pip installing with --target --upgrade?

Dynamic named range including rows and columns

Excel VBA seperate data from cells into seperate columns

"TypeError: Cannot read properties of undefined (reading 'name')"

Using Thread or not?

C - How do I fill an array with certain numbers

Socket IO cannot connect using HTTPS

Mongo DB timeout : com.mongodb.MongoSocketOpenException: Exception opening socket

Change blob image width and height - reactjs

AutoLISP, How to export my selected polylines to a CSV with a name

Error: Unable to run code with xmlschema after build with pyinstaller

Join Tables based on start and end time in Power BI

Target another styled component on hover not working

Dropdown won't close on select (javascript)

How to get card to resize when screen size is changed

Regex for allowing alphanumeric,-,_ and space

Problems performing an update on Cassandra having a compound partitioning key

Removing Hyper link from an email text using google apps script

How to create a new objects of array by using object values in JavaScript

How to add parameters to a constructor of a class which implements an interface using inversify?

Which Postgresql index is most efficient for text column with queries based on similarity

Error after upgrading flutter from 2.5 to 2.8

How to exclude everything except some directories from PHP Code Sniffer inspections in .phpcs.xml?

Flutter Json Call

Caused by: org.gradle.api.resources.ResourceException: Could not get resource

Are Dijkstra's Algorithm and Bellman-Ford Algorithm the same besides iterations?

R - use apply to transfer one value from one data frame to another by match of two columns

Create optional-optional relationship in EF6 with PK instead of FK

Visual studio -asp.net cor mvc nuget

Python selenium - WebDriverException: target frame detached - for Login button

Combining dataframes based on condition

Cannot redirect to internal page with nginx and flask

Top