It derives from the indicator at https://www.prorealcode.com/prorealtime-indicators/pivot-support-resistance-zones/, following a request from a user’s comment at that indicator.
It simply uses an MA (Ema by default) to build bands and a middle line based on those pivots segments, according to the chosen periods.
It’s quite self-explanatory.
In the attached screnshot there are 3 pics:
- Original indicator (left)
- Bands built on a 2-period Ema (upper right)
- Bands built on a 50-period Ema (lower right)
// Pivot Support & Resistance Bands
DEFPARAM CalculateOnLastBars = 1000
//p = 2 //2 periods
//Type = 1 //1 = Ema
p = max(1,min(999,p)) //range 1 - 999
Type = max(0,min(6,Type)) //range 0 - 6
PivotBAR = 2 //2 bars AFTER pivot
LookBack = 4 //4 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]
IF high[PivotBAR] > highest[LookBack](high)[BarLookBack] THEN
IF high[PivotBAR] = highest[BarLookBack](high) THEN
//MyResistance = BarIndex - PivotBAR
ResistancePrice = high[PivotBAR]//high[BarIndex - MyResistance]
EmaResistance = average[p,Type](ResistancePrice)
EmaSupport = average[p,Type](SupportPrice)
MidLine = EmaSupport + ((EmaResistance - EmaSupport) / 2)
RETURN EmaResistance COLOURED(255,0,0,255) AS "EmaResistance",EmaSupport COLOURED(0,128,0,255) AS "EmaSupport",MidLine coloured(0,0,0,32) AS "MidLine"
No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.ProRealTime ITF files and other attachments :
PRC is also on YouTube, subscribe to our channel for exclusive content and tutorials