![](/img/trans.png)
[英]How do you create a signal when close price is lower than previous close in pine script?
[英]How to draw highest price of the previous month in the lower timeframes in Pine script?
我想在较低的时间范围内水平绘制上个月的最高价格。 如何在较短的时间范围内从上个月的第一根蜡烛开始画一条线?
line.new(x1 = time[1] , y1 = a, x2 = time , y2 = a, xloc = xloc.bar_time)
通过request.security()
function 获取上个月的高值。
然后使用内置变量time
和内置 function timestamp()
计算出当月的第一根蜡烛。
//@version=5
indicator("My Script", overlay=true)
high_month = request.security(syminfo.tickerid, "M", high[1], lookahead=barmerge.lookahead_on)
targetDate = time >= timestamp(year(timenow), month(timenow), 1, 0, 0, 0)
beginMonth = not targetDate[1] and targetDate
var line l_high_month = na
if (beginMonth)
l_high_month := line.new(bar_index, high_month, bar_index+1, high_month, extend=extend.right, color=color.green)
line.delete(l_high_month[1])
plotshape(beginMonth, "T", shape.triangleup, location.belowbar, size=size.small)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.