TB跨周期、跨品种调用数据的实现方法_第1页
TB跨周期、跨品种调用数据的实现方法_第2页
TB跨周期、跨品种调用数据的实现方法_第3页
TB跨周期、跨品种调用数据的实现方法_第4页
TB跨周期、跨品种调用数据的实现方法_第5页
已阅读5页,还剩24页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、TB跨周期、跨品种调用数据的实现方法,关于跨周期,使用算法整合当前周期上的bar数据,取得相应周期的bar数据。(难)学习请点击我 使用函数DataConvert。 使用数据库SetTBProfileString、GetTBProfileString.,写公式信息文件,SetTBProfileString写入 Bool SetTBProfileString(String strSection,String strKey,String strValue) GetTBProfileString读取 String GetTBProfileString(String strSection,String

2、 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); st

3、rKey = 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!=Date1) strKey = DateToString(Date1); Else strKey = strKey1;

4、 strValue = GetTBProfileString(DayMA,strKey); If(strValue != InvalidString) DayMAValue = Value(strValue); Else DayMAValue = DayMAValue1; PlotNumeric(DayMA,DayMAValue); End,步骤三 详细代码,跨周期例子(一),上图为日线图 下图为5分钟图 从五分钟上读取日线图上的MA数据,跨品种、跨周期例子(二),在1分钟线上取得1小时和日线周期举例讲解具体应用。,操作步骤一,1、新建一个工作区,包含上下三个图表窗体,上面左边选择股指指数日线

5、,上面右边选择股指指数小时线,下面选择1分钟股指IF1101周期。,操作步骤二,2、新建一个技术指标,命名为DayLine。 编译成功后插入日线图表中。,Params Numeric length(10); Numeric length1(10); Numeric length2(20); Vars Numeric MA1; Numeric MA2; string strkeyDate; Begin MA1 = AverageFC(Close,length1); MA2 = AverageFC(Close,length2); strKeyDate = DateToString(Date); S

6、etTBProfileString(Symbol,DayMA1:+strKeyDate,Text(MA1); SetTBProfileString(Symbol,DayMA2:+strKeyDate,Text(MA2); PlotNumeric(DayMA1,MA1); PlotNumeric(DayMA2,MA2); End,操作步骤三,3、新建一个技术指标,HourLine。 编译成功后插入小时线图表中。,Params Numeric length(10); Numeric length1(10); Numeric length2(20); Vars Numeric MA1; Numeri

7、c MA2; string strkeyDate; Begin MA1 = AverageFC(Close,length1); MA2 = AverageFC(Close,length2); strKeyDate = DateToString(Date)+:+Text(Hour); SetTBProfileString(Symbol,HourMA1:+strKeyDate,Text(MA1); SetTBProfileString(Symbol,HourMA2:+strKeyDate,Text(MA2); PlotNumeric(HourMA1,MA1); PlotNumeric(HourMA

8、2,MA2); End,操作步骤四,4、新建一个技术指标,MinLine。 编译成功后插入1分钟图表中。,Vars NumericSeries DayMA1; NumericSeries DayMA2; NumericSeries HourMA1; NumericSeries HourMA2; StringSeries strKeyDate; StringSeries strKeyHour; string DayValue1; string DayValue2; string HourValue1; string HourValue2; Begin If(Date!=Date1) strKey

9、Date = DateToString(Date); Else strKeyDate = strKeyDate1; If(Hour!=Hour1) strKeyHour = DateToString(Date)+:+Text(Hour); Else strKeyHour = strKeyHour1;,/读取日线 DayValue1 = GetTBProfileString(“If000,DayMA1:+strKeyDate); DayValue2 = GetTBProfileString(“If000,DayMA2:+strKeyDate); /读取小时线 HourValue1 = GetTB

10、ProfileString(“If000,HourMA1:+strKeyHour); HourValue2 = GetTBProfileString(“If000,HourMA2:+strKeyHour); DayMA1 = Value(DayValue1); DayMA2 = Value(DayValue2); HourMA1 = Value(HourValue1); HourMA2 = Value(HourValue2); /输出 PlotNumeric(DayMA1,DayMA1);PlotNumeric(DayMA2,DayMA2); PlotNumeric(HourMA1,HourM

11、A1); PlotNumeric(HourMA2,HourMA2); End,跨周期实现从1分钟周期上取得日线上的KDJ信息 用到的函数有SetTBProfileString、GetTBProfileString、,熟悉与掌握 (练习一),跨周期例子三,在日线图上保存每日的KDJ数据,Params Numeric Length(14); Numeric SlowLength(3); Numeric SmoothLength(3); Vars NumericSeries HighestValue; NumericSeries LowestValue; NumericSeries KValue;

12、Numeric DValue; StringSeries strKeyDate;/日期变量,使用序列字符串,新建技术指标公式,命名为DayAvgLine,公式内容如下:,Begin /获得日期 If(Date!=Date1) strKeyDate = DateToString(Date); Else strKeyDate = strKeyDate1; /计算KDJ值 HighestValue = HighestFC(High, Length); LowestValue = LowestFC(Low, Length); KValue = SummationFC(Close - LowestVal

13、ue,SlowLength)/SummationFC(HighestValue-LowestValue,SlowLength)*100; DValue = AverageFC(KValue,SmoothLength);,/将KDJ信息保存在数据库中 SetTBProfileString(Symbol,KValue_+strKeyDate,Text(KValue); SetTBProfileString(Symbol,DValue_+strKeyDate,Text(DValue); SetTBProfileString(Symbol,JValue_+strKeyDate,Text(3*KValu

14、e - 2*DValue); /在日线图上输出KDJ值 PlotNumeric(KValue,KValue); PlotNumeric(DValue,DValue); PlotNumeric(JValue,3*KValue - 2*DValue); End,在分钟线上取得相应日期的KDJ值,新建技术指标公式,命名为GetDayAvgLine,公式内容如下:,Vars NumericSeries KValue; NumericSeries DValue; NumericSeries JValue; StringSeries strKeyDate;,Begin If(Date!=Date1) strKeyDate = DateToString(Date); Else strKeyDate = strKeyDate1; KValue=Value(GetTBProfileString(Symbol,KValue_+strKeyDate); DValue=Value(GetTBProfileString

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论