开拓者期货期权程序化系统交易论坛

标题: 如何用SetTBProfileString在5分线调用30分线的数据? [打印本页]

作者: wsjtry    时间: 2019-1-3 14:49:45     标题: 如何用SetTBProfileString在5分线调用30分线的数据?

请假,如何用SetTBProfileString在5分线跨周期调用30分线、60分的数据?该怎么写呢?或者参考什么贴?谢谢,非常感谢。
作者: 小米    时间: 2019-1-3 15:33:19

http://bbs.tb18.net/thread-4469-1-1.html
作者: wsjtry    时间: 2019-1-3 17:19:58

本帖最后由 wsjtry 于 2019-1-3 17:31 编辑

新建窗口,这个指标放入大周期30分,60分等,把MA值写数据库供小周期调用
  1. Vars
  2. Numeric length(15);
  3. NumericSeries MA;
  4. string strkey;//设置键名
  5. string strValue;//设置键值
  6. Numeric RQSJ;//日期时间

  7. Begin
  8. MA = XAverage(Close,length);
  9. RQSJ=Date*10000+Hour*100+Minute;//日期时间,作为键名
  10. strKey = Text(RQSJ);//设置键名,以日期小时分钟为键名
  11. strValue = Text(MA);//设置键值

  12. WData=SetTBProfileString("KtMA60",strKey,strValue);//数据块名,键名,键值

  13. PlotNumeric("MA",MA);
  14. Commentary("写键名="+Text(RQSJ));


  15. End
复制代码
//新建窗口,这个指标放入小周期并且小于被调用周期,如5分,10分,15分周期。
  1. Vars

  2. NumericSeries KtValue;//读出的数据
  3. NumericSeries RQSJ;//日期时间
  4. StringSeries strKey;//读取键名
  5. StringSeries strValue;//读取键值

  6. Begin
  7. RQSJ=Date*10000+Hour*100+Minute;//日期时间,作为键名
  8. If(RQSJ!=RQSJ[1]){strKey = Text(RQSJ[1]);}//不同时间K线,取上个时间为键名
  9. Else{strKey = strKey[1];}//取上个时间为键名

  10. strValue = GetTBProfileString("KtMA60",strKey);//根据数据库、键名去读取键值
  11. If(strValue != InvalidString){KtValue = Value(strValue);}//读数据有效
  12. Else{KtValue = KtValue[1];}//读数据无效


  13. PlotNumeric("键值",KtValue);
  14. Commentary("读键名="+Text(RQSJ));
  15. Commentary("读键值="+Text(KtValue));

  16. End
复制代码
目前同周期30分调用30分周期的数据正常,
但是小周期调用大周期就不正常,如5分调用30分,
请教,怎么办呢?谢谢

作者: wsjtry    时间: 2019-1-3 17:32:27

小米 发表于 2019-1-3 15:33
http://bbs.tb18.net/thread-4469-1-1.html

我参照网址的修改了,
目前同周期30分调用30分周期的数据正常,
但是小周期调用大周期就不正常,如5分调用30分,
请教,怎么办呢?
谢谢,非常感谢。




欢迎光临 开拓者期货期权程序化系统交易论坛 (http://bbs.tb18.net/) Powered by Discuz! X2