【发布时间】:2021-10-26 03:00:25
【问题描述】:
想知道是否可以帮助我将线条样式集成到 MA/EMA 脚本中。顶部是从交易视图帮助部分中直接提取的关于如何设置趋势线样式的部分。
//@version=4
study(title="Set line style with input", overlay=true)
// STEP 1. Make the input with pull-down menu
styleOption = input(title="Line Style", type=input.string,
options=["solid (─)", "dotted (┈)", "dashed (╌)",
"arrow left (←)", "arrow right (→)", "arrows both (↔)"],
defval="solid (─)")
// STEP 2. Convert the input to a proper line style value
lineStyle = styleOption == "dotted (┈)" ? line.style_dotted :
styleOption == "dashed (╌)" ? line.style_dashed :
styleOption == "arrow left (←)" ? line.style_arrow_left :
styleOption == "arrow right (→)" ? line.style_arrow_right :
styleOption == "arrows both (↔)" ? line.style_arrow_both :
line.style_solid
// STEP 3. Use the input option to set the line's style
if barstate.islastconfirmedhistory
// Create a new line and immediately set its style
line.new(x1=bar_index[55], y1=close[55],
x2=bar_index, y2=close, width=4, color=color.blue,
style=lineStyle)
// Or make a line, and then change its style
myLine = line.new(x1=bar_index[35], y1=close[35],
x2=bar_index, y2=close, width=4, color=color.orange)
line.set_style(id=myLine, style=lineStyle)
// EMA Example Need to Integreate Above style
len1 = input(21, minval=1, title="EMA 1")
src1 = input(close, title="EMA 1 source")
plot(ema(src1, len1), color=#8b0000, title="EMA 1",linewidth=1)
【问题讨论】:
标签: function styles line pine-script trend