Login Page - Create Account

Support Board


Date/Time: Sat, 11 Jan 2025 07:09:50 +0000



Post From: Trouble evaluating MACD values at previous closes

[2016-11-08 15:47:19]
AcquaLife - Posts: 33
The title says it all. I want to evaluate MACD difference value at prior 15min bar closes. I want to save those into variables such as MACDDIFF1 MACDDIFF2 MACDDIFF3. I have been working with this code block provided by SC:
sc.MACD(sc.BaseData[SC_LAST], sc.Subgraph[0], 5, 10, 10, MOVAVGTYPE_SIMPLE);

//Access the individual lines
float MACD = sc.Subgraph[0][sc.Index]; //Access the study value at the current index

float MACDMovingAverage = sc.Subgraph[0].Arrays[2][sc.Index];

float MACDDifference = sc.Subgraph[0].Arrays[3][sc.Index];

//Copy to Visible Subgraphs
sc.Subgraph[1][sc.Index] = MACDMovingAverage;
sc.Subgraph[2][sc.Index] = MACDDifference;

So, what I have tried to do to evaluate the previous values of the MACD difference at previous 15min closes is
float MACDDifference = sc.Subgraph[0].Arrays[3][sc.Index];
float MACDDifference1 = sc.Subgraph[0].Arrays[3][sc.Index-1];
float MACDDifference2 = sc.Subgraph[0].Arrays[3][sc.Index-2];
The sc.Index-1, sc.Index-2, ect. does not seem to work. I have tried using SC_LAST or sc.Close and someother things.
Please illuminate some light on what I am doing wrong.

Thank you so much.
On another note, I have to say thanks to SC for providing all of this functionality at such a low cost... wow, I have searched for a long time to find something like this, and got really lucky to stumble across SC!