Login Page - Create Account

Support Board


Date/Time: Thu, 18 Apr 2024 01:06:35 +0000



Post From: How to find all values of an sc.Subgraph[] array that are above a given value?

[2021-04-09 17:02:45]
opmetal - Posts: 65
I have an array that I use to store support pivots. I can't figure out how to determine if a chart bar closed below more than one of these pivots. I use sc.GetIndexOfHighestValue(SupportPivot, sc.ArraySize) to get the highest value of the pivot array and test if price closes below this. But often there is a close below multiple support pivots in the same bar. Later in my code I will need to test if price is near one of these pivots and the logic won't work if price is already below them. I'm using AutoLoop and I'm not sure if I would need to loop manually to accomplish what I want. Basically I need to find all the values of SupportPivot that are above the closing price and remove them from my array.

Any help is appreciated!!


SCSubgraphRef SupportPivot = sc.Subgraph[0];

if (some conditions bla bla)
{
SupportPivot[sc.Index - 1] = InData[SC_OPEN][sc.Index - 1]; //store a value in the array
}

float HighestSupportPivot = sc.GetHighest(SupportPivot, sc.ArraySize); // get the highest pivot from the array
int HighestSupportPivotIndex = sc.GetIndexOfHighestValue(SupportPivot, sc.ArraySize); // get the highest pivot's sc.Index

if (sc.GetBarHasClosedStatus(sc.Index) == BHCS_BAR_HAS_CLOSED // check if a bar has closed
&& InData[SC_LAST][sc.Index] < HighestSupportPivot // then check if price closed below the highest pivot
)
{
SupportPivot[HighestSupportPivotIndex] = NULL; // clear the highest pivot from the array as I only need support pivots below the current price.
}