Login Page - Create Account

Support Board


Date/Time: Thu, 02 May 2024 23:02:20 +0000



[Programming Help] - SimpleMovAvg returns 0

View Count: 503

[2020-06-19 18:06:38]
DonMattez - Posts: 8
Hello,

in some instances, this code


int InMALength = 8;
int InSubGraph = 2;

sc.SimpleMovAvg(sc.BaseDataIn[SC_LAST], sc.Subgraph[InSubGraph].Data, InMALength);
float FlTrendBefore = sc.Subgraph[InSubGraph].Data[sc.Index - 1];
float FlTrendActual = sc.Subgraph[InSubGraph].Data[sc.Index];

behaves differently than expected.

In this case, FlTrendBefore is 0 at the the index 121. But it should be a value more or less close to FlTrendActual , which contains the actual value at the index 122.

Do you have an explanation why it could be so?
[2020-06-20 21:23:05]
DonMattez - Posts: 8
I tried many diffferent attemps now. A strange thing I noticed is the following:

I placed a simple moving average at the begoinning of my code, just to see the results. And as i expected, the output-subgraph of the SMA never had 0 as a value.
Then I returned to the original state of the code - and while debugging I noticed that also I never had 0 as a value.

But the I opened up the chart studies windows, and as soon as I clicked on okay, without changing anything, the 0-values returned.

I noticed this because I am displaying my study, and the output changes from the correct expected result to a the wrong ones, caused by the 0 values in the output array of the SimpleMovAvg function.

Does anyone know why it would be like that?

Thank you.

Edit: I deleted every other study to explude any interferences, still the same...
Date Time Of Last Edit: 2020-06-20 21:30:05

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

Login

Login Page - Create Account