PivotPoints with Momentum confirmation by PeterO

Peter_O · study · 32 行 · 点赞 2,017 · TradingView 原页

本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。

Pine Script

//@version=4
study(title = "PivotPoints with Momentum confirmation by PeterO", shorttitle="PivotPoints", overlay = true)
 
// SMI Momentum by UCS {
a = input(5, "Percent K Length")
b = input(3, "Percent D Length")
// Range Calculation
ll = lowest (low, a)
hh = highest (high, a)
diff = hh - ll
rdiff = close - (hh+ll)/2
// Nested Moving Average for smoother curves
avgrel = ema(ema(rdiff,b),b)
avgdiff = ema(ema(diff,b),b)
// SMI calculations
SMI = avgdiff != 0 ? (avgrel/(avgdiff/2)*100) : 0
//} End of SMI Momentum by UCS
 
PL=pivotlow(low,1,1)
PH=pivothigh(high,1,1)
 
PIVOTLOW = rising(SMI,1) and ((PL and (falling(SMI,1)[1] or (rising(SMI,1)[1] and falling(SMI,1)[2]))) or (PL[1] and falling(SMI,1)[1] and low>low[2]))
PIVOTHIGH = falling(SMI,1) and ((PH and (rising(SMI,1)[1] or (falling(SMI,1)[1] and rising(SMI,1)[2]))) or (PH[1] and rising(SMI,1)[1] and high<high[2]))
 
PINBAR_HIGH=high>high[1] and open < high - (tr*2/3) and close < high - (tr*2/3) and falling(SMI,1) and rising(SMI,1)[1] 
PINBAR_LOW=low<low[1] and open > low + (tr*2/3) and close > low + (tr*2/3) and rising(SMI,1) and falling(SMI,1)[1]
 
plotshape(PL, location=location.belowbar, style=shape.triangleup, color=color.black, size=size.tiny, title="PivotLow", transp=45)
plotshape(PH, location=location.abovebar, style=shape.triangledown, color=color.black, size=size.tiny, title="PivotHigh", transp=45)
 
plotshape(PIVOTLOW or PINBAR_LOW ? low - 10*syminfo.mintick : na, location=location.absolute, style=shape.triangleup, color=color.green, size=size.small, title="PivotLow", transp=5)
plotshape(PIVOTHIGH or PINBAR_HIGH ? high + 10*syminfo.mintick : na, location=location.absolute, style=shape.triangledown, color=color.red, size=size.small, title="PivotHigh", transp=5)

← 返回列表