Forex_Strategy_Builder.Backtester.ArrangeBarsHighLow C# (CSharp) Method

ArrangeBarsHighLow() static private method

Arranges the order of hitting the bar's Top and Bottom.
static private ArrangeBarsHighLow ( int bar ) : void
bar int
return void
        static void ArrangeBarsHighLow(int bar)
        {
            double low  = Low[bar];
            double high = High[bar];
            bool isTopFirst   = false;
            bool isOrderFound = false;

            if (isScanning && IntraBarsPeriods[bar] != Period)
            {
                for (int b = 0; b < IntraBarBars[bar]; b++)
                {
                    if (IntraBarData[bar][b].High + micron > high)
                    {   // Top founded
                        isTopFirst   = true;
                        isOrderFound = true;
                    }

                    if (IntraBarData[bar][b].Low - micron < low)
                    {   // Bottom founded
                        if (isOrderFound)
                        {   // Top and Bottom into the same intrabar
                            isOrderFound = false;
                            break;
                        }
                        isTopFirst   = false;
                        isOrderFound = true;
                    }

                    if (isOrderFound)
                        break;
                }
            }

            if (!isScanning || !isOrderFound)
            {
                isTopFirst = Open[bar] > Close[bar];
            }

            if (isTopFirst)
            {
                session[bar].SetWayPoint(high, WayPointType.High);
                session[bar].SetWayPoint(low,  WayPointType.Low);
            }
            else
            {
                session[bar].SetWayPoint(low,  WayPointType.Low);
                session[bar].SetWayPoint(high, WayPointType.High);
            }

            return;
        }