新手求助:基于指定时间价格在EURUSD图表绘制点及连线的Pine Script实现
在EURUSD图表绘制复盘点位与线段的Pine Script实现
完整代码
//@version=5 indicator("复盘进场离场标记", overlay=true) // 定义两个目标点位的时间与价格 var float entry_price = 1.06736 var int entry_time = timestamp("2023-03-01", "15:46:02") var float exit_price = 1.06731 var int exit_time = timestamp("2023-03-01", "17:41:15") // 绘制进场标记点 plotshape(time == entry_time, title="进场点", location=location.absolute, style=shape.labelup, color=color.new(color.green, 0), text="进场", textcolor=color.white, size=size.small, y=entry_price) // 绘制离场标记点 plotshape(time == exit_time, title="离场点", location=location.absolute, style=shape.labeldown, color=color.new(color.red, 0), text="离场", textcolor=color.white, size=size.small, y=exit_price) // 绘制连接两点的线段 line.new(entry_time, entry_price, exit_time, exit_price, color=color.new(color.blue, 0), width=2)
关键说明
- 采用Pine Script v5版本,确保兼容TradingView最新功能
- 使用
timestamp()将字符串时间转换为平台可识别的时间戳格式 plotshape()通过不同样式的标签直观区分进场(绿色上标)和离场(红色下标)点位line.new()直接基于两个点位的时间-价格坐标生成连接线段,线段宽度设为2以增强可见性
内容的提问来源于stack exchange,提问作者Leo Torres
相关产品推荐
相关产品推荐

