文档介绍:TB跨周期、跨品种调用数据的实现方法
关于跨周期
使用算法整合当前周期上的bar数据,取得相应周期的bar数据。(难)学习请点击我
使用函数DataConvert。
使用数据库SetTBProfileString、GetTBProfileString.
写公式信息文件
SetTBProfileString写入
Bool SetTBProfileString(String strSection,String strKey,String strValue)
GetTBProfileString读取
String GetTBProfileString(String strSection,String strKey)
strSection:块名
strKey:键名
strValue:存储值
图表1
图表2
图表3
跨周期举例(一)
以5分钟周期调用日线指标数据举例讲解具体应用。
操作步骤一
1、新建一个工作区,包含上下两个图表窗体,上面选择日线周期,下面选择5分钟周期。
操作步骤二
2、新建一个技术指标,命名为MyDayMA。
编译成功后插入日线图表中。
详细代码
Params
Numeric length(10);
Vars
Numeric MA;
string strkey;
string strValue;
Begin
MA = AverageFC(Close,length);
strKey = DateToString(Date);
strValue = Text(MA); SetTBProfileString("DayMA",strKey,strValue);
PlotNumeric("MA",MA);
End
操作步骤三
3、新建一个技术指标,My5MinMA。
编译成功后插入5分钟图表中。
Vars
NumericSeries DayMAValue;
StringSeries strKey;
string strValue;
Begin
If(Date!=Date[1])
{
strKey = DateToString(Date[1]);
}Else
{
strKey = strKey[1];
}
strValue = GetTBProfileString("DayMA",strKey);
If(strValue != InvalidString)
{
DayMAValue = Value(strValue);
}Else
{
DayMAValue = DayMAValue[1];
}
PlotNumeric("DayMA",DayMAValue);
End
步骤三
详细代码
跨周期例子(一)
上图为日线图
下图为5分钟图
从五分钟上读取日线图上的MA数据