DoPushBar新建图层出错

DoPushBar新建图层出错,帮忙看看。

多图层的DoPushBar新建

Params

//此处添加参数

Numeric beginTime(20190101.000000); //数据开始时间

String sym("rb888.SHFE"); //合约名称

String freq("1m"); //数据源周期

String freq1("15m"); //数据源周期

String freq2("60m"); //数据源周期

Integer millsec(1000); //定时器触发间隔

Numeric klineLow(100); //K线Low

Numeric klineHigh(140); //K线High

Numeric klineRangeRate(0.0008); //K线变动范围系数

Numeric klineJunpRate(0.0035); //k线数据跳跃系数

Numeric FastLength(5); //短期指数平均线参数

Numeric SlowLength(20); //长期指数平均线参数

Vars

//此处添加变量

Numeric avg;

Global Integer myCodeId;

Global Integer myCodeId1;

Global Integer myCodeId2;

CodeProperty myPty;

Global Integer cnt(10);

Global Numeric cycBars(10);

Global Numeric base(0);

Bar barTmp1;

Bar barTmp2;

Tick tickTmp1;

Tick tickTmp2;

Numeric nowTime;

Series<Numeric> AvgValue1;

Series<Numeric> AvgValue2;

Defs

Integer CreateBar(BarRef iBar,Numeric iBase)

{

iBar.open=iBar.open*(-1);

       iBar.high=iBar.high*(-1);

       iBar.low=iBar.low*(-1);

       iBar.close=iBar.close*(-1);

iBar.volume=Rand(iBase*10-100,iBase*10+100);

iBar.openInt=Rand(iBase*10-100,iBase*10+100);

Commentary("base="+Text(base));

Commentary("offset="+Text(iBase*klineRangeRate));

Return 1;

}


Integer CreateTick(TickRef iTick,Numeric iBase)

{

iTick.open=iTick.open*(-1);

       iTick.high=iTick.high*(-1);

       iTick.low=iTick.low*(-1);

       iTick.last=iTick.last*(-1);

iTick.volume=Rand(iBase*10-100,iBase*10+100);

iTick.totalVolume=iTick.volume+100;

iTick.openInt=Rand(iBase*10-100,iBase*10+100);

//...

Commentary("base="+Text(base));

Commentary("offset="+Text(iBase*klineRangeRate));

Return 1;

}


Numeric GetBase(Integer current)

{

if(base==0)

{

base=Rand(klineLow,klineHigh);

}

if(Mod(current,cycBars)==0)

{

cycBars=rand(30,60);    

base=Rand(base-base*klineJunpRate,base+base*klineJunpRate);

}

Return base;

}


Integer DoPushBar(Integer layerId,Numeric datetime,Bool isReal)

{

//抛bar数据

If(Data[layerId].Frequency=="tick")

{

Data[myCodeId].tickTmp1=Data[myCodeId].tickTmp2; //清空

CreateTick(Data[layerId].tickTmp1,GetBase(CurrentBar()));

Data[layerId].tickTmp1.dateTime=datetime;

Data[layerId].PushBar(tickTmp1);

}Else

{

Data[myCodeId].barTmp1=Data[myCodeId].barTmp2;//清空

CreateBar(Data[layerId].barTmp1,GetBase(CurrentBar()));

Data[layerId].barTmp1.dateTime=datetime;

If(isReal)

{

Data[layerId].barTmp1.lastDateTime=SystemDateTime();

}

Data[layerId].PushBar(barTmp1);

}

Return 1;

}


Events

//此处实现事件函数


//初始化事件函数,策略运行期间,首先运行且只有一次,应用在订阅数据等操作

OnInit()

{

CreateTimer(millsec);


//自定义合约

myPty.symbol="my888.SHFE"; //合约代码

myPty.symbolName="自定义连续"; //商品名称

myPty.bigCategory=Enum_CategoryFutures(); //商品大类

myPty.dealTimes="21:00-23:30;09:00-10:15;10:30-11:30;13:30-15:00";

// 交易时段,格式为: 21:00-23:30;09:00-10:15;10:30-11:30;13:30-15:00;

myPty.decDigits=1; //小数点位数

myPty.priceScale=0.01; //最小变动单元

myPty.minMove=1; //最小变动

myPty.contractUnit=100; //合约单位 期货中1张合约包含N吨铜,小麦等

myPty.bigPointValue=1; //单点价值

CreateProperty(myPty); //创建合约

myCodeId=SubscribeBar(symbol,freq,beginTime);

SubscribeBar(Symbol,freq1, BeginDateTime,EndDateTime,0);

myCodeId1=SubscribeBar(symbol,freq1,beginTime);

SubscribeBar(Symbol,freq2, BeginDateTime,EndDateTime,0);

myCodeId2=SubscribeBar(symbol,freq2,beginTime);

}


//在所有的数据源准备完成后调用,应用在数据源的设置等操作

OnReady()

{

//先抛有时间轴的空数据,用于数据驱动或与其他数据源对其

DoPushBar(myCodeId,NextTradingDateTime(beginTime),False);

DoPushBar(myCodeId1,NextTradingDateTime(beginTime),False);

DoPushBar(myCodeId2,NextTradingDateTime(beginTime),False);

}


OnBarOpen(ArrayRef<Integer> indexs)

{

if(CurrentBar()==0)

{

//修改当前Bar==0数据,立即生效,即可可以访问

DoPushBar(myCodeId,Data[myCodeId].Date()+Data[myCodeId].Time(),False);

}

nowTime=Data[myCodeId].NextBarDateTime();

if(nowTime < SystemDateTime())

{

//抛有历史数据,用于数据驱动或与其他数据源对其

DoPushBar(myCodeId,nowTime,False);

}

if(CurrentBar()==0)

{

//修改当前Bar==0数据,立即生效,即可可以访问

DoPushBar(myCodeId1,Data[myCodeId].Date()+Data[myCodeId].Time(),False);

}

nowTime=Data[myCodeId1].NextBarDateTime();

if(nowTime < SystemDateTime())

{

//抛有历史数据,用于数据驱动或与其他数据源对其

DoPushBar(myCodeId1,nowTime,False);

}

if(CurrentBar()==0)

{

//修改当前Bar==0数据,立即生效,即可可以访问

DoPushBar(myCodeId2,Data[myCodeId].Date()+Data[myCodeId].Time(),False);

}

nowTime=Data[myCodeId2].NextBarDateTime();

if(nowTime < SystemDateTime())

{

//抛有历史数据,用于数据驱动或与其他数据源对其

DoPushBar(myCodeId2,nowTime,False);

}

}



OnTimer(Integer id,Integer millsecs)

{

nowTime=SystemDateTime();

If(Data[myCodeId].IsTradingTime(nowTime))

{//抛有实时数据,用于数据驱动或与其他数据源对其

DoPushBar(myCodeId,nowTime,True);

}

nowTime=SystemDateTime();

If(Data[myCodeId1].IsTradingTime(nowTime))

{//抛有实时数据,用于数据驱动或与其他数据源对其

DoPushBar(myCodeId1,nowTime,True);

}

       nowTime=SystemDateTime();

If(Data[myCodeId2].IsTradingTime(nowTime))

{//抛有实时数据,用于数据驱动或与其他数据源对其

DoPushBar(myCodeId2,nowTime,True);

}

}


如何新建窗口进行画图
新建策略单元
策略研究时运行出错是什么原因
分段新建优化任务??
新建优化任务没反应
关于新建变量的问题
怎么新建公式应用的分组
新建公式虑数能否分组
分段新建优化任务,用不了。
智大领峰怎么新建指标选股

新建的K线没有数据一条直线。

问题是什么

程序做什么的

哪段代码出问题,结果出问题?