Attached is a picture of the $AUDUSD 60 minute chart showing what this looks like.
From this point, I have created a histogram in an attempt to calculate the distance between the swingHighs and swingLows. But this is where the problem begins.
Attached you will also see a picture of the chart with the histogram
Here is the code that is used for the above histogram. It is the full code found within the OnBarUpdate()
protected override void OnBarUpdate()
{
if (CurrentBar Low[2]
&& Low[1] > Low[2]
&& Low[3] > Low[2]
&& Low[4] > Low[2])
|| (SL1 == true
&& Low[0] > Low[2]
&& Low[1] == Low[2]
&& Low[3] > Low[2]
&& Low[4] > Low[2]))
{
SL2 = true;
SLValue2 = Low[3]; //This needs to be [3] because of how NT calculates - even though it is
//Print("SLValue2 = " + SLValue2);
}
The Problem
The above code calculates correctly as long as the swingHigh & swingLow alternate; but, as soon as there are 2 or more swingHighs in a row, it runs into an issue. It is subtracting every single swingHigh from the swingLow.
The Goal - Further Refined
When there are consecutive swingHighs, ultimately I would like to get the distance from the low to the highest high in the series of swingHighs. This is what I am not able to figure out.
What is Needed
Could somebody please help me work out how to calculate the distance between the highest swing high and the low rather than every single swing high and the low. I would imagine that a Math.Max() could help with the issue, but this requires parameters that are constants and this would dynamically change.
Granted, I know that the computer can only recognize the most current High and it will not know if it will be followed by an even higher high later on - therefore, initially, it must calculate every single high. But, I wonder if there is a way of "deleting" that calculation as soon as it recognizes that a higher high has posted.
Hopefully that all makes sense and thank you to anyone and everyone in advance for your help!!!