
These conditions are used to ensure the methods are not called needlessly. These two methods are called once on the last bar on the chart and subsequently every time a timer elapsed event occurs if the horizontal scaling has changed or the value of the horizontal line is greater than the maximum value or less than the minimum value displayed. Note: the chart range is actually increased by the minimum move amount to ensure that the horizontal lines are visible.

To change the fixed scaling values the program uses the. If the value of the line is between the highest and lowest prices on the screen it sets the range between the lowest and the highest prices.

If so, it changes the scale to include the value of the horizontal line and the highest price value. It also checks whether the horizontal line value is lower than the lowest price on the screen. If so, it changes the scale to include the lowest price and the value of the horizontal line. The values highlighted in yellow are modified by the programĪnother method: UpdateMinMax( ) checks whether the horizontal line value is higher than the highest price on the screen. To achieve this, the method counts backwards from the last bar on the chart and when it determines it is within the range of date time visible on the chart it determines the high and the low for the screen. The values change as you scroll backwards and forwards to different time frames. This method determines the highest and lowest prices visible on the screen. The program includes a method named: FindHiLoOnScreen( ). As I scroll backwards in time the price action moves away from the horizontal line, however, the tutorial program ensures that the horizontal line remains visible. In this specific example a horizontal line is drawn at the level of the highest high over a user input number of bars. _Tutorial 166 demonstrates a technique that ensures that a drawing object remains visible in the chart window, even if price activity is no longer in the region of the chart where the drawing object is positioned.

Without using a technique such as demonstrated in this tutorial would require manual scaling
