代码:
//默认展示MA Cross。移动平均线
// this.chart.chart().createStudy("MA Cross", false, false, [10, 20]);//10日和20日
不同颜色:
//均线
_this.MALine5 = widget
.chart()
.createStudy("Moving Average", false, false, [5, "close", 0], null, {
"Plot.color": "green",
"Plot.linewidth": 0,
});
_this.MALine10 = widget
.chart()
.createStudy("Moving Average", false, false, [10, "close", 0], null, {
"Plot.color": "red",
"Plot.linewidth": 0,
});
_this.MALine20 = widget
.chart()
.createStudy("Moving Average", false, false, [20, "close", 0], null, {
"Plot.color": "#409EFF",
"Plot.linewidth": 0,
});
隐藏均线:
//均线
_this.MALine5 = widget
.chart()
.createStudy("Moving Average", false, false, [5, "close", 0], null, {
"Plot.color": "green",
"Plot.linewidth": 0,
});
_this.MALine10 = widget
.chart()
.createStudy("Moving Average", false, false, [10, "close", 0], null, {
"Plot.color": "red",
"Plot.linewidth": 0,
});
_this.MALine20 = widget
.chart()
.createStudy("Moving Average", false, false, [20, "close", 0], null, {
"Plot.color": "#409EFF",
"Plot.linewidth": 0,
});
widget.chart().getStudyById(_this.MALine5).setVisible(false);
widget.chart().getStudyById(_this.MALine10).setVisible(false);
widget.chart().getStudyById(_this.MALine20).setVisible(false);