在5分钟图跨周期读取15分钟指标,发现只会在第一根5分钟K线更新实时值,剩余2根5分钟K线不会更新。

您好,反映一个5分钟跨周期数据库方式读取15分钟指标bug 问题。

问题现象:在5分钟图通过跨周期数据库方式,读取并打印15分钟的ma及close 指标,发现只会在当前15分钟周期的第一根5分钟K线更新这两个指标,剩余2根5分钟K线不会更新指标。

示图:(上图为5分钟周期,下图为插入的15分钟周期)

如上图:在5分钟图跨周期数据库读取15分钟11点K线的MA、close值时候,只在5分钟图的对应周期第一根K线刷新值,余下2根K线没有刷新对应实时的MA、close值(5分钟图黄线为实时打印读取的15分钟close值,其值应以11:10的K线收盘价画横线,而不是固定为11点k线的收盘价)。

而通过查看数据管理的数据库,是有动态更新15分钟的值的,如下图:

对应代码:见附件。

期望:希望指导解决一下,在5分钟周期可以动态读取15分钟周期ma、close 值。谢谢!


K线不能自动更新,导致信号丢失
[智大领峰-指标-k线]蜡烛图
跨周期下小周期K线缺失
关于K线剩余的时间
如何从第一根K线开始画线
当根k线平仓后不开仓 下根K线开仓
请问如何在只打开5分钟周期K线图层时,在5分钟周期K线显示60分钟周期10均线
TB跨周期问题,为了避免引入未来数据,是否会系统性的延迟一根K线
跨周期指标为什么是上一根k线数据??
最后一根K线在收盘前交易

我认为跨周期完全没有必要用读写数据库的方式

另外代码属于不能运行的,请贴全

你好,这个是参考了旗舰版帮助里面交易策略进阶的数据库读取方式,如果有其它更好方式麻烦指导一下,另外补充完整代码,谢谢!

15分钟图代码:

Params

   Numeric length(10);

Vars

NumericSeries MA;

string strkey;

       string strValue;

NumericSeries K;

       string strkey1;

string strValue1;//定义15分钟写入数据库变量

Begin

   MA = AverageFC(Close,length);

   strKey = DateToString(Date)+"日"+Text(Hour)+":"+Text(Minute);

   strValue = Text(MA);

   SetTBProfileString("15分钟MA","MinuteMA:"+strKey,strValue);

   PlotNumeric("MA",MA,0,Red);

K = Close;

strKey1 = DateToString(Date)+"日"+Text(Hour)+":"+Text(Minute);

strValue1 = Text(K);                

SetTBProfileString("15分钟Close","MinuteC:"+strKey1,strValue1);//在15分钟收盘价表存入15分钟Close值

PlotNumeric("15Close",K,0,Yellow);

End





5分钟图代码:


Params

   Numeric maLength(2);  //1分钟周期1分钟均线

Vars

//----------------------跨周期读取数据库------------------------------

NumericSeries My15mMA; //指向15分钟MA数据库表取15分钟的MA

StringSeries strKey1;  //定义key1  

stringSeries strValue1; //定于key1对应的值

NumericSeries My15mclose; //指向15分钟Close数据库表取15分钟的Close

StringSeries strKey2;  //定义key2  

stringSeries strValue2; //定于key对应的值2

Begin

ma = AverageFC(Close,maLength);

If(Date!=Date[1])    // 读数据库程序

     {          

         strKey1 = DateToString(Date[1]);

         strKey2 = DateToString(Date[1]);

     }Else    

    {        

     strKey1 = strKey1[1];

     strKey2 = strKey2[1];

     }

If(Hour!=Hour[1])

 {

           strKey1 = DateToString(Date)+"日"+Text(Hour);

   strKey2 = DateToString(Date)+"日"+Text(Hour);

      }Else

  {  

   strKey1 = strKey1[1];

   strKey2 = strKey2[1];

 }

If(Minute!=Minute[1])

  {    strKey1 = DateToString(Date)+"日"+Text(Hour)+":"+Text(Minute);

strKey2 = DateToString(Date)+"日"+Text(Hour)+":"+Text(Minute);

      } Else

 {     strKey1 = strKey1[1]; //定义key1

strKey2 = strKey2[1]; //定义key2

  }

strValue1= GetTBProfileString("15分钟MA","MinuteMA:"+strKey1);    //当日从15分钟MA表取值

     If(strValue1 != InvalidString)    

     {        

         My15mMA = Value(strValue1);

      }Else    

      {        

         My15mMA = My15mMA[1];  

       }

Plotnumeric("My15mMA",My15mMA,0,Red);//跨周期读取15分钟ma值  

strValue2= GetTBProfileString("15分钟Close","MinuteC:"+strKey2);    //当日从15分钟Close表取值

     If(strValue2 != InvalidString)    

     {        

         My15mclose = Value(strValue2);

      }Else    

      {        

         My15mclose = My15mclose[1];    

       }                      

Plotnumeric("My15mclose",My15mclose,0,Yellow);//跨周期读取15分钟Close值  

End