【发布时间】:2021-07-08 08:32:58
【问题描述】:
如何根据 if 语句设置趋势线颜色和绘图,即如果股票数据 > 1 年,则使用趋势线 1,否则使用趋势线方法 2:
trend_1 = sma(close, 15)
trend_2 = sma(close, 30)
bearish = true
for i = 0 to trendConfirmationLength - 1
bearish := bearish and (close[i] < trend[i])
bullish = not bearish
// Set the color of the plot based on whether we are bullish (green) or not (red)
c = bullish ? color.green : color.red
// Plot the trend line
trend =
if (len(close) > 252)
trend_1
if (len(close) < 252)
trend_2
trend_plot = plot(trend, title='Trend', color = c)
谢谢
【问题讨论】: