//------------------------------------------------------------------------
// 简称: MA_Crossover_Strategy
// 名称: 5日线与20日线金叉死叉策略
// 类别: 交易策略
// 类型: 趋势跟踪
// 输出: 无
//------------------------------------------------------------------------
Params
Numeric FastMAPeriod(5); // 快速均线周期,默认为5日
Numeric SlowMAPeriod(20); // 慢速均线周期,默认为20日
Numeric LotSize(1); // 每次交易的手数
Vars
Numeric MA5; // 5日均线
Numeric MA20; // 20日均线
Bool BuyCondition; // 买入条件
Bool SellCondition; // 卖出条件
Begin
// 计算5日均线和20日均线
MA5 = Average(Close, FastMAPeriod); // 5日均线
MA20 = Average(Close, SlowMAPeriod); // 20日均线
// 判断金叉条件:5日均线上穿20日均线
BuyCondition = CrossOver(MA5, MA20);
// 判断死叉条件:5日均线下穿20日均线
SellCondition = CrossUnder(MA5, MA20);
// 交易逻辑
If (BuyCondition && MarketPosition != 1) {
Buy(LotSize, Open); // 买入
}
If (SellCondition && MarketPosition != -1) {
SellShort(LotSize, Open); // 卖出
}
// 绘制均线
PlotNumeric("MA5", MA5, Red); // 绘制5日均线(红色)
PlotNumeric("MA20", MA20, Blue); // 绘制20日均线(蓝色)
// 绘制买卖信号
If (BuyCondition) {
PlotString("BuySignal", Low, "Buy", Green); // 买入信号(绿色)
}
If (SellCondition) {
PlotString("SellSignal", High, "Sell", Red); // 卖出信号(红色)
}
// 返回0表示函数执行成功
Return 0;
End
其中PlotString("BuySignal", Low, "Buy", Green); // 买入信号(绿色)
},
PlotString("SellSignal", High, "Sell", Red); // 卖出信号(红色)
}显示:函数实现的参数列表和预声明的参数列表不符合,请问如何修改
建议仔细看看这个参数位置,是不是正确填写了