Login Page - Create Account

Support Board


Date/Time: Fri, 28 Feb 2025 09:40:00 +0000



[Programming Help] - Error when computing a simple moving average

View Count: 475

[2021-08-13 10:15:53]
BenjFlame - Posts: 335
sc.SimpleMovAvg(sc.BaseData[SC_HIGH] - sc.BaseData[SC_LOW], SubGraph_HLAverage, 2);

Won't compile:

MyStudies.cpp: In function 'void scsf_RangeProjection(SCStudyInterfaceRef)':
MyStudies.cpp:440:46: error: no match for 'operator-' (operand types are 'c_ArrayWrapper<float>' and 'c_ArrayWrapper<float>')
440 | sc.SimpleMovAvg(sc.BaseData[SC_HIGH] - sc.BaseData[SC_LOW], SubGraph_HLAverage, 2);
In file included from scstructures.h:101,
from sierrachart.h:22,
from MyStudies.cpp:2:
scdatetime.h:2393:19: note: candidate: 'SCDateTime operator-(const SCDateTime&, const SCDateTime&)'
2393 | inline SCDateTime operator - (const SCDateTime& DateTimeA, const SCDateTime& DateTimeB)
| ^~~~~~~~
scdatetime.h:2393:49: note: no known conversion for argument 1 from 'c_ArrayWrapper<float>' to 'const SCDateTime&'
2393 | inline SCDateTime operator - (const SCDateTime& DateTimeA, const SCDateTime& DateTimeB)
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~

-- End of Build -- 06:13:09

Why is that?
[2021-08-13 10:54:30]
Sierra Chart Engineering - Posts: 104368
You need to do this intermediate calculation through an extra Subgraph array first as explained here:
Using ACSIL Study Calculation Functions
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account