根据视频课写了EMA的双均线系统,但是图上没有信号,麻烦看看

学习视频课的双均线交易系统,写了EMA的双均线交易系统,但是没有信号,麻烦看看。


Params

Numeric Length1(5);

Numeric Length2(20);

Vars

series<Numeric> EMA1;

series<Numeric> EMA2;

series<Bool> bool_crossover;

series<Bool> bool_crossunder;


Events

OnBar(ArrayRef<Integer> indexs)

{

//双EMA均线 用收盘价计算两根均线

PlotNumeric("EMA1",XAverage(Close, Length1));

PlotNumeric("EMA2",XAverage(Close, Length2));

//金叉和死叉状态

bool_crossover = EMA1[1] <= EMA2[1] and EMA1 > EMA2;

bool_crossunder = EMA1[1] >= EMA2[1] and EMA1 < EMA2;

If(bool_crossover[1])

{

Buy(1,Open);

}

If(bool_crossunder[1])

{

SellShort(1,Open);

}

}


双均线系统,出信号未开仓
双均线系统设置止损报错
双均线系统问题
双均线问题
自己编写的ema和系统内置的ema计算结果有差异但是不知道原因
关于Pivot的课没有找到呢,搜索的视频课程只有SAR内容
双均线策略问题
双均线交易系统,我只想做空,或者只想做多
双均线参数优化
双均线系统过滤假金叉

知道错误原因了,ema1和ema2的两行代码漏掉了

😅

bool_crossover = EMA1[1] <= EMA2[1] and EMA1 > EMA2; bool_crossunder = EMA1[1] >= EMA2[1] and EMA1 < EMA2;

改成:bool_crossover = EMA1[12] <= EMA2[12] and EMA1[1] > EMA2[1]; bool_crossunder = EMA1[21] >= EMA2[12] and EMA1[1] < EMA2[1];再试试。

bool_crossover = EMA1[1] <= EMA2[1] and EMA1 > EMA2; bool_crossunder = EMA1[1] >= EMA2[1] and EMA1 < EMA2; 改成:bool_crossover = EMA1[2] <= EMA2[2] and EMA1[1] > EMA2[1]; bool_crossunder = EMA1[2] >= EMA2[2] and EMA1[1] < EMA2[1];再试试。以这个为准

bool_crossover = EMA1[1] <= EMA2[1] and EMA1 > EMA2; bool_crossunder = EMA1[1] >= EMA2[1] and EMA1 < EMA2; 改成:bool_crossover = EMA1[2] <= EMA2[2] and EMA1[1] > EMA2[1]; bool_crossunder = EMA1[2] >= EMA2[2] and EMA1[1] < EMA2[1];再试试。以这个为准

谢谢回复,我试了一下,还是不行😭