In the first IF statement, we used "Bid" price and stated to open a position when "Bid" goes below or equal to "C" and "isBuyPosition" is false. Why did we use "Bid" here? Suppose we use the Ask price, then there is a possibility that the previous buy position is closed, but the new sell position doesn't get opened. This is because we know that the buy opens at Ask and closes at Bid, leaving a possibility that the buy will be closed when Bid crosses or equals the C price level line from above.