//------------------------------------------------------------------------
// 简称: test230405
// 名称:
// 类别: 公式应用
// 类型: 用户应用
// 输出: Void
//------------------------------------------------------------------------
Params
Numeric length1(25);
Numeric length2(180);
Numeric lots(1);
Numeric BS1(0);
Numeric BS2(1);
Vars
Series<Numeric> upline;
Series<Numeric> downline;
Series<Numeric> ma111;
Series<Numeric> line;
Series<Numeric> MyExitPrice;
Global Numeric s1(0);
Global Numeric s2(0);
Series<Numeric> moveprice;
Series<Numeric> atr;
Events
//此处实现事件函数
//初始化事件函数,策略运行期间,首先运行且只有一次
OnInit()
{
SetConsecEntries(1);
}
//Bar更新事件函数,参数indexs表示变化的数据源图层ID数组
OnBar(ArrayRef<Integer> indexs)
{
Range[0:DataSourceSize() - 1]
{
atr=AvgTrueRange(14);
upline=Average(H[1],length1)+BS1*atr;
downline=Average(L[1],length1)-BS1*atr;
line=abs(upline+downline)/2;
moveprice=Abs(upline-downline)*BS2;
ma111=Average(C[1],length2);
PlotNumeric(\"短周期上轨\",upline,0,Red);
PlotNumeric(\"短周期下轨\",downline,0,Red);
PlotNumeric(\"中线\",line,0,yellow);
PlotNumeric(\"方向线\",ma111,0,Blue);
//PlotNumeric(\"出场线\",MyExitPrice,0,White);
Commentary(\"出场价=\"+Text(MyExitPrice));
Commentary(\"移损价=\"+Text(moveprice));
}
//以下是多头进场部分
If(longCurrentContracts==0 And H>=upline and C[1]<upline[1] And line>=ma111 And line[1]>ma111[1] and Open<upline)
{
Buy(lots,max(o,upline));
MyExitPrice=downline;
PlotAuto(\"多1\",\"多1\",low-40,White);
}
If(longCurrentContracts==1 And High[1] >= (EntryPrice + moveprice) and BarsSinceEntry>0 )
{
MyExitPrice=max(AvgEntryPrice,upline);
}
If( longCurrentContracts==1 And L<=MyExitPrice and s1<=0 And BarsSinceEntry>0 )
{
Sell(lots,MyExitPrice);
PlotAuto(\"平多1\",\"平多1\",H+40,White);
}
}
老师,为啥这个开仓这个点是在上面?问题出在哪,这是在三分钟周期上,大周期反而没事?感谢
完全看不懂你的在问什么
首先,你要先确定这个信号是哪句代码发出的。可以用commentary在每个信号命令后面加上输出内容来区分。
其次,找到执行代码后,考察这个信号命令的条件,逐个分析数值内容是否合理正确,同样是借用commentary,print,plot等工具来处理