//@version=4 study("modified Pivot Zones", shorttitle="Pivot Zones", overlay=true) TimeFrame = "D" prevClose = security(syminfo.tickerid, TimeFrame, close[1], lookahead=true) prevOpen = security(syminfo.tickerid, TimeFrame, open[1], lookahead=true) prevHigh = security(syminfo.tickerid, TimeFrame, high[1], lookahead=true) prevLow = security(syminfo.tickerid, TimeFrame, low[1], lookahead=true) //CALCULATIONS CentralPivot = (prevHigh + prevLow + prevClose) / 3 ResistanceZone1 = (CentralPivot * 1.999) - prevLow ResistanceZone1a = (CentralPivot * 2.001) - prevLow ResistanceZone2 = CentralPivot + (prevHigh - prevLow)*.9 ResistanceZone2a = CentralPivot + (prevHigh - prevLow)*1.1 ResistanceZone3 = prevHigh + (1.9*(CentralPivot - prevLow)) ResistanceZone3a = prevHigh + (2.1*(CentralPivot - prevLow)) SupportZone1 = (CentralPivot * 1.999) - prevHigh SupportZone1a = (CentralPivot * 2.001) - prevHigh SupportZone2 = CentralPivot - (prevHigh - prevLow)*1.1 SupportZone2a = CentralPivot - (prevHigh - prevLow)*.9 SupportZone3 = prevLow - (2.1*(prevHigh - CentralPivot)) SupportZone3a = prevLow - (1.9*(prevHigh - CentralPivot)) //PLOTS plot(CentralPivot,color = color.red, title = "Central Pivot", style=plot.style_cross) RZ1 = plot(ResistanceZone1,color = color.blue, title = "Resistance Zone 1", style=plot.style_stepline) RZ1a = plot(ResistanceZone1a,color = color.blue, title = "Resistance Zone 1", style=plot.style_stepline) RZ2 = plot(ResistanceZone2,color = color.blue, title = "Resistance Zone 2", style=plot.style_stepline) RZ2a = plot(ResistanceZone2a,color = color.blue, title = "Resistance Zone 2", style=plot.style_stepline) RZ3 = plot(ResistanceZone3,color = color.blue, title = "Resistance Zone 3", style=plot.style_stepline) RZ3a = plot(ResistanceZone3a,color = color.blue, title = "Resistance Zone 3", style=plot.style_stepline) SZ1 = plot(SupportZone1,color = color.orange, title = "Support Zone 1", style=plot.style_stepline) SZ1a = plot(SupportZone1a,color = color.orange, title = "Support Zone 1", style=plot.style_stepline) SZ2 = plot(SupportZone2,color = color.orange, title = "Support Zone 2", style=plot.style_stepline) SZ2a = plot(SupportZone2a,color = color.orange, title = "Support Zone 2", style=plot.style_stepline) SZ3 = plot(SupportZone3,color = color.orange, title = "Support Zone 3", style=plot.style_stepline) SZ3a = plot(SupportZone3a,color = color.orange, title = "Support Zone 3", style=plot.style_stepline) //FILLS fill(RZ1, RZ1a, color=color.blue, title="Resistance Zone 1 Fill", transp=90) fill(RZ2, RZ2a, color=color.blue, title="Resistance Zone 2 Fill", transp=90) fill(RZ3, RZ3a, color=color.blue, title="Resistance Zone 3 Fill", transp=90) fill(SZ1, SZ1a, color=color.orange, title="Support Zone 1 Fill", transp=90) fill(SZ2, SZ2a, color=color.orange, title="Support Zone 2 Fill", transp=90) fill(SZ3, SZ3a, color=color.orange, title="Support Zone 3 Fill", transp=90) //LABELS if CentralPivot[1] != CentralPivot label.new(bar_index, ResistanceZone3, " R Zone 3", textcolor = color.gray, style=label.style_none) label.new(bar_index, ResistanceZone2, " R Zone 2", textcolor = color.gray, style=label.style_none) label.new(bar_index, ResistanceZone1, " R Zone 1", textcolor = color.gray, style=label.style_none) label.new(bar_index, CentralPivot, " Central Pivot", textcolor = color.white, style=label.style_none) label.new(bar_index, SupportZone1, " S Zone 1", textcolor = color.gray, style=label.style_none) label.new(bar_index, SupportZone2, " S Zone 2", textcolor = color.gray, style=label.style_none) label.new(bar_index, SupportZone3, " S Zone 3", textcolor = color.gray, style=label.style_none) //ALERTS PivotAlert = (cross(close,CentralPivot) or cross(close, SupportZone1) or cross(close, ResistanceZone1) or cross(close, ResistanceZone2) or cross(close,SupportZone2) ) alertcondition(PivotAlert, title='Pivot Alert', message='Pivot Alert')