Params
Numeric FastLength(5);// 短期指数平均线参数
Numeric SlowLength(20);// 长期指数平均线参数
Vars
Series<Numeric> AvgValue1;
Series<Numeric> AvgValue2;
Events
OnInit()
{
array<Numeric> timepoint;
timepoint[0] = 0.112950;
timepoint[1] = 0.145930;
SetTriggerBarClose(timepoint);
}
OnReady()
{
SetBackBarMaxCount(1+Max(FastLength,SlowLength));
Range[0:DataSourceSize() - 1]
{
setPlotOption("MA1", "begin-bar", FastLength);
setPlotOption("MA2", "begin-bar", SlowLength);
}
}
OnBar(ArrayRef<Integer> indexs)
{
AvgValue1 = AverageFC(Close,FastLength);
AvgValue2 = AverageFC(Close,SlowLength);
PlotNumeric("MA1",AvgValue1);
PlotNumeric("MA2",AvgValue2);
If(MarketPosition <>1 && AvgValue1[1] > AvgValue2[1])
{
Buy(0,Open);
}
If(MarketPosition <>-1 && AvgValue1[1] < AvgValue2[1])
{
SellShort(0,Open);
}
}
OnBarClose(ArrayRef<Integer> indexs)
{
if(time == 0.1455)
{
sell(0,close);
BuyToCover(0,close);
Commentary("收盘平仓");
}
}
收盘前30秒没有执行平仓
明天我会直播跑这个代码,看看到底会不会发单。
这么多贴就不能放在一个帖子里说明吗?好乱啊
老师你好 前面发的不管 都是一个想法 重复的我自己有删除不了
那以后就更新这个帖子,其他帖子不要回了
你这个图是几分钟周期