如何将移动均线中的第一个柱锚定到日内高点或低点?

时间:2018-11-12 05:19:41

标签: moving-average tradingview-api pine-script

我正在尝试改编Jayy在TradingView上发布的脚本。如果您指定柱线编号作为输入,则脚本会将移动均线锚定于日内柱线。我想做的是将移动平均线固定在日内时段的高点或低点,例如Highest(high,20)。 Jayy脚本的一部分在下面。如果有任何建议或想法,我将不胜感激。

startBar01=input(0,"1/ Starting Bar Number, for Midas VWAP", 
integer,minval=-1)
up01=input(false, title="Show upper resistance only - top to trend down" )
mid01=input(true, title=" Show MIDAS line (midline)")
low01=input(false, title="Show lower support only - bottom to trend up" )

v01 = na(volume) ? 1 : volume
cumV01= cum(v01)
CumPV01= cum(hl2*v01)
SupportCumPV01 = cum(low*v01)
ResistanceCumPV01 = cum(high*v01)

startV01 = valuewhen(startmidas01,cumV01,0)
StartPV01 = valuewhen(startmidas01,CumPV01,0)
SupportStartPV01 = valuewhen(startmidas01,SupportCumPV01,0)
ResistanceStartPV01 = valuewhen(startmidas01,ResistanceCumPV01,0)

Midas01 = (CumPV01-StartPV01)/(cumV01-startV01)
SupportMidas01 = (SupportCumPV01-SupportStartPV01)/(cumV01-startV01)
ResistanceMidas01 = (ResistanceCumPV01-ResistanceStartPV01)/(cumV01-startV01)

middle01 = plot( mid01 and showmidas? Midas01:na, color=aqua,linewidth=3, title="Midas Resistance 1M")
lower01 = plot(low01 and showmidas? SupportMidas01:na, color=teal,linewidth=1, title="Midas Resistance 1S")
upper01 = plot(up01 and showmidas?ResistanceMidas01:na, color=RED,linewidth=1, title="Midas Resistance 1R")
fill(lower01,upper01,color=#1c86ee,transp=97)

0 个答案:

没有答案