l00 = input(24,'Lookback'),l01 = l00*3,l02 = l00*6,l03 = l00*9,l04 = l00*12 //----Step Function step(nd) => step = nd >0 and nd <0.25 ? 0 : nd > 0.25 and nd < 0.5 ? 0.25 : nd > 0.5 and nd <0.75 ? 0.5 : nd > 0.75 and nd < 0.875 ? 0.75 : nd > 0.875 ? 1 : nd <0 and nd >-0.25 ? 0 : nd < -0.25 and nd > -0.5 ? -0.25 : nd < -0.5 and nd > -0.75 ? -0.5 : nd < -0.75 and nd > -0.875 ? -0.75 : nd < -0.875 ? -1 : nd step //----Normalization Function // @params s = volume, l = lookback period n(s,l) => hi = ta.highest(s, l) lo = ta.lowest(s, l) n = (s - lo) / (hi - lo)+1 n //----Trigger Rotation v00 = n(volume,l00) b00 = 0.0, s00 = 0.0 if close > open b00 := v00 * math.abs(open / close - 1) b00 if close < open s00 := v00 * math.abs(open / close - 1) s00 d00 = ta.cum(b00 - s00) nd00 = (n(d00,l00) -1.5)*2.0 nd00 := ta.alma(nd00,l00,0.95,6) nd10 = ta.rma(nd00,2) //----Fast Rotation v01 = n(volume,l01) b01 = 0.0, s01 = 0.0 // Buy volume if close > open b01 := v01 * math.abs(open / close - 1) b01 // Sell volume if close < open s01 := v01 * math.abs(open / close - 1) s01 d01 = ta.cum(b01 - s01) nd01 = (n(d01,l01) -1.5)*2.0 nd01 := ta.alma(nd01,l01,0.90,6) nd11 = ta.rma(nd01,3) //----Trend Rotation v04 = n(volume,l04) b04 = 0.0, s04 = 0.0 if close > open b04 := v04 * math.abs(open / close - 1) b04 if close < open s04 := v04 * math.abs(open / close - 1) s04 d04 = ta.cum(b04 - s04) nd04 = (n(d04,l04) -1.5)*2.125 nd04 := ta.alma(nd04,l04,0.9,6) nd04 := step(nd04) //----Plots c01=nd01 > nd11 ? #FFFFFF : #787B86 c02=nd02 > 0 ? #B2B5BE5F : #787B865F c12=nd02 > 0 ? #B2B5BE2F : #787B862F c03=nd03 > 0 ? #B2B5BE5F : #787B865F c13=nd03 > 0 ? #B2B5BE2F : #787B862F c04=nd04 > 0 ? #B2B5BE5F : #787B865F c14=nd04 > 0 ? #B2B5BE2F : #787B862F z=plot(0,'0',na) //fill(plot(nd01,'Fast Rotation',c01),plot(nd11,'Smooth Fast Rotation',c01),color=c01) //fill(z,plot(nd04,'Trend Rotation',c04,style=plot.style_stepline),color=c14) fill(hline(1,'1',#FF52528F,linestyle=hline.style_solid),hline(0.75,'0.75',#FF52528F,linestyle=hline.style_dotted),color= nd00 > 0.75 and nd00 < nd10 ? #FF5252CF : #FF52522F) hline(0,'0',#FFFFFF8F,linestyle=hline.style_solid) fill(hline(-0.75,'-0.75',#00BCD48F,linestyle=hline.style_dotted),hline(-1,'-1',#00BCD48F,linestyle=hline.style_solid),color= nd00 < -0.75 and nd00 > nd10 ? #00BCD4CF : #00BCD42F) //----Basic Single Alert bool vis_alert = input(false, 'Show Alert?') threshold = input(0.75,'Alert Threshold') long = ta.crossover(nd01,nd11) and nd01 <= - threshold and nd00 > nd10 short = ta.crossunder (nd01,nd11) and nd01 >= threshold and nd00 < nd10 cond = long or short bgcol = long ? #00BCD4 : short ? #FF5252 : na bgcolor(vis_alert ? bgcol : na ,title='Alert Trigger') alertcondition(cond, title='Rotations X', message='Rotations X')