This ProBuilder script is designed to identify and draw support and resistance levels based on price pivots over a specified number of bars. It helps in visualizing key price levels which could act as barriers to price movements.
DEFPARAM CalculateOnLastBars = 1000
//DEFPARAM DrawOnLastBarOnly = true
PivotBAR = 2 //2 bars AFTER pivot
LookBack = 4 //3 bars BEFORE pivot
BarLookBack = PivotBAR + 1
IF low[PivotBAR] < lowest[LookBack](low)[BarLookBack] THEN
IF low[PivotBAR] = lowest[BarLookBack](low) THEN
MySupport = BarIndex - PivotBAR
SupportPrice = low[PivotBAR]
ENDIF
ENDIF
IF high[PivotBAR] > highest[LookBack](high)[BarLookBack] THEN
IF high[PivotBAR] = highest[BarLookBack](high) THEN
MyResistance = BarIndex - PivotBAR
ResistancePrice = high[PivotBAR]//high[BarIndex - MyResistance]
ENDIF
ENDIF
DRAWSEGMENT(MyResistance,ResistancePrice,BarIndex,ResistancePrice) COLOURED(255,0,0,255)
DRAWSEGMENT(MySupport,SupportPrice,BarIndex,SupportPrice) COLOURED(0,128,0,255)
RETURN
Explanation of the Code:
This script is useful for traders who need to visually identify and analyze key price levels that could influence future price movements.
Check out this related content for more information:
https://www.prorealcode.com/topic/support-resistance-for-all-timeframes/#post-86502
Visit Link