VPC SupportResistance
- Indicatori
- Zhen Hao Wu
- Versione: 1.4
- Attivazioni: 20
This is a custom indicator for MetaTrader 5 named VPC_SupportResistance.mq5 . Here's a breakdown of what it does:
- Purpose: The indicator aims to automatically draw horizontal Support and Resistance (S/R) levels on the main chart window.
- Level Calculation Method:
- It looks back over a user-defined number of bars ( InpPeriod ).
- It identifies all the high prices and low prices within that period.
- It sorts these highs and lows.
- It then selects the highest unique high prices from the period as Resistance levels. The number of levels drawn is determined by InpNumLines .
- Similarly, it selects the lowest unique low prices from the period as Support levels, again drawing up to InpNumLines .
- Drawing Technique: Instead of using standard indicator buffers and plots ( #property indicator_buffers 0 , #property indicator_plots 0 ), this indicator uses graphical objects to draw directly on the chart:
- It uses OBJ_HLINE objects to draw the horizontal lines for support (Orange by default) and resistance (DodgerBlue by default). Line style and width are customizable.
- It manages these objects using a unique prefix ( obj_prefix ) based on the chart ID to avoid conflicts and ensure proper cleanup when the indicator is removed ( OnDeinit ) or parameters change.
- Percentage Display Feature:
- Optionally ( InpShowPercentage = true), it displays text labels next to each S/R line.
- Each label shows the price level of the line and the percentage difference between that level and the current closing price.
- It uses OBJ_LABEL objects for this text display.
- It includes a helper function ( PriceToY ) to calculate the correct vertical pixel position for the labels so they align with their corresponding horizontal lines, regardless of chart zoom or scale. The horizontal position is a fixed offset from the right edge.
- Customization: Users can adjust the lookback period, the number of S/R lines to display, the color, style, and width of the lines, and settings for the percentage text display (toggle, color, font size, horizontal position).
