老师,使用的是onbar ,交易信号出现后,第二根bar开盘价交易
//------------------------------------------------------------------------
// 简称: opentrade
// 名称:
// 类别: 公式应用
// 类型: 用户应用
// 输出: Void
//------------------------------------------------------------------------
Params
//此处添加参数
Numeric n(10020);
Vars
//此处添加变量
series<Numeric> barslastcrossup;
Bool crossup;
series<Numeric> barslastcrossbelow;
Bool crossbelow;
Events
OnBar(ArrayRef<Integer> indexs)
{
crossup = (c>n and c[1]<=n and marketposition<>1);
barslastcrossup = nthcon(crossup,1);
if(barslastcrossup == 1 and marketposition<>1)
{
buy(1,open);
}
crossbelow = (c<n and c[1]>=n and marketposition<>-1);
barslastcrossbelow = nthcon(crossbelow,1);
if(barslastcrossbelow == 1 and marketposition<>-1)
{
Sell(1,open);
}
PlotAuto(line,n,n,Yellow,Enum_Line,enum_solid,Enum_3Pix);
Commentary(contracts=+text(currentcontracts));
PlotAuto(contracts,text(CurrentContracts),H*1.003,white);
if(c<n and c[1]>=n)
{
PlotAuto(下穿,下穿,L*1.005);
}
if(c>n and c[1]<=n)
{
PlotAuto(上穿,上穿,L*0.995);
}
}
你的代码就是这个运行结果,你是对什么东西不清楚?不知道你在问什么