I am currently coding an indicator that plots the swing highs and lows on the chart. The logic for a swing low is that when a low is forming it has to have two higher-lows on both sides of the bar.
What I am trying to do now is that I want to ignore any inside bars leading up to the swing low or after the forming swing low bar.
In the picture below you can see the inside bars that I don't want to count after the swing low bar labeled SL.
I currently have hard code the indexs to check for Swing lows:
if(lookingForSL)
{
if(lookForSL())
{
Draw.Text(this, "SL" + CurrentBar, "SL", 2, Low[2] - 0.05);
lookingForSH = true;
lookingForSL= false;
return;
}
}
private bool lookForSL()
{
return Low[1] > Low[2] &&
Low[1] <= Low[0] &&
Low[0] > Low[2] &&
Low[3] > Low[2] &&
Low[4] > Low[2];
}
Low[2] is the swing low on the chart
LookingForSL is a flag so that the loop resets and looks for a SH when a SL is found.
I would be so greatful for any ideas :-)
Cheers
//Stefan

Comment