能不能帮我写一个pine脚本,功能是同时使用Volatility Oscillator指标、Bollinger Bands指标、Normalized…
- User
能不能帮我写一个pine脚本,功能是同时使用Volatility Oscillator指标、Bollinger Bands指标、Normalized MACD指标。Volatility Oscillator指标、Normalized MACD指标我会提供,Bollinger Bands指标直接调用tradingview的就行,设置保持默认。代码如下Volatility Oscillator指标 // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © veryfid
//@version=4 study("Volatility Oscillator", resolution = "") length = input(100) spike = close - open x = stdev(spike,length) y = stdev(spike,length) * -1
plot(spike, color = color.white, linewidth = 2, title = "Spike Linel")
p1 = plot(x, "Upper Line") p2 = plot(y, "Lower Line")
plot(0, color= color.gray, title= "Zero Line")
plot(spike, color= color.blue, style=plot.style_area, transp=80, title = "Spike Fill")
osc2 = spike
lbR = 5 lbL = 5 rangeUpper =60 rangeLower = 5 plotBull = input(title="Plot Bullish", defval=true) plotHiddenBull = input(title="Plot Hidden Bullish", defval=false) plotBear = input(title="Plot Bearish", defval=true) plotHiddenBear = input(title="Plot Hidden Bearish", defval=false) delay_plot_til_closed = input(title="Delay diversion plot until candle is closed (don't repaint)", defval=false) bearColor = color.red bullColor = color.green hiddenBullColor = color.new(color.green, 80) hiddenBearColor = color.new(color.red, 80) textColor = color.white noneColor = color.new(color.white, 100)
repaint = (not(delay_plot_til_closed) or barstate.ishistory or barstate.isconfirmed)
plFound = na(pivotlow(osc2, lbL, lbR)) ? false : true phFound = na(pivothigh(osc2, lbL, lbR)) ? false : true _inRange(cond) => bars = barssince(cond == true) rangeLower <= bars and bars <= rangeUpper
//------------------------------------------------------------------------------ // Regular Bullish // Osc: Higher Low
oscHL = osc2[lbR] > valuewhen(plFound, osc2[lbR], 1) and _inRange(plFound[1])
// Price: Lower Low
priceLL = low[lbR] < valuewhen(plFound, low[lbR], 1) bullCond = plotBull and priceLL and oscHL and plFound and repaint
plotshape( bullCond ? osc2[lbR] : na, offset=-lbR, title="Regular Bullish Label", text="R", style=shape.labelup, location=location.absolute, color=bullColor, textcolor=textColor, transp=0 )
//------------------------------------------------------------------------------ // Hidden Bullish // Osc: Lower Low
oscLL = osc2[lbR] < valuewhen(plFound, osc2[lbR], 1) and _inRange(plFound[1])
// Price: Higher Low
priceHL = low[lbR] > valuewhen(plFound, low[lbR], 1) hiddenBullCond = plotHiddenBull and priceHL and oscLL and plFound and repaint
plotshape( hiddenBullCond ? osc2[lbR] : na, offset=-lbR, title="Hidden Bullish Label", text="H", style=shape.labelup, location=location.absolute, color=bullColor, textcolor=textColor, transp=0 )
- Assistant
将您提供的Volatility Oscillator和Normalized MACD指标代码与Bollinger Bands指标结合,我们可以创建如下Pine Script代码。这个脚本将会在交易视图上展示全部三个指标:
pinescript