繁体   English   中英

如何绘制先前的 ohlc4 HMA 烛芯高低以止损??? 脚本

[英]How to plot previous ohlc4 HMA candle wick high and low for a stoploss??? Pinescript

我绘制了蜡烛图,我只是想用之前的蜡烛灯芯高低来绘制我的止损点。 多头低,空头高。

我可以使用真正的收盘价和 heikien ashi 来绘制它,但我想使用图表上绘制的 HMA 蜡烛来设置止损。

任何帮助都会很棒,并且非常感谢提前,

保罗

    //@version=5
    strategy("Hull Candles", overlay=true, margin_long=100, 
    margin_short=100)

len = input(10, title= "Hull Length")
lenclose = input(1, title="Hull Close Lenth")

//Candle values

o = ta.hma(open,len)
c = ta.hma(close,len)
h = ta.hma(high,len)
l = ta.hma(low,len)
t = ticker.new(syminfo.prefix, syminfo.ticker)
t2 = ticker.heikinashi(t)


ohlcFour = ta.hma(ohlc4,len)

colorBody = ohlcFour > ohlcFour[1] ? color.white : #6F00FF
plotcandle(o,h,l,c, color=colorBody, title= "Hull Candles")

//Stoploss labels
longstoploss = request.security(ohlc4, timeframe.period, low[1])
shortstoploss = request.security(ohlc4, timeframe.period, high[1])
longstop = str.tostring(longstoploss)
shortstop = str.tostring(shortstoploss)

Longstoplabel = label.new(x=bar_index,y=na, text = longstop, yloc = yloc.belowbar,textcolor=color.white, color=#000000,size = size.normal,style = label.style_none)
Shortstoplabel = label.new(x=bar_index,y=na, text = shortstop, yloc = yloc.abovebar,textcolor= #6F00FF, color=#000000,size = size.normal,style = label.style_none)

label.delete(Longstoplabel[1])
label.delete(Shortstoplabel[1])

不知道你需要什么,但如果你想要船体蜡烛低,

Hull_Candle_low = ta.valuewhen(close,l,0)

因此,如果您想将止损设在前一个船体蜡烛低点,那就是Hull_Candle_low[1]

短裤/高帮也一样

Hull_Candle_high = ta.valuewhen(close,h,0)

之前的船体蜡烛高点是Hull_Candle_high[1]

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM