设为首页收藏本站

 找回密码
 注册
查看: 2329|回复: 1
打印 上一主题 下一主题

关于调用跨周期数据在交易指令里遇到的问题 [复制链接]

Rank: 5Rank: 5

精华
0
UID
28852
积分
651
帖子
153
主题
42
阅读权限
60
注册时间
2011-3-15
最后登录
2022-1-5
跳转到指定楼层
1#
发表于 2011-6-8 12:06:45 |只看该作者 |倒序浏览
小弟我是通过跨周期调用15分钟和30分钟线上的数据,然后在3分钟线上,用调用来的数据做开仓的判断条件,但是遇到一个问题,现将代码贴出来,望各路高手帮忙看下 问题出在哪里,
//15分钟线下的
//------------------------------------------------------------------------
Params
        Numeric length(5);
Vars
    NumericSeries H1;
    NumericSeries L1;
        NumericSeries Myclose15;
        String strkeyDate15;
Begin
   L1=Highest(Low,length);//求length周期内最低价的最大值
   H1=Lowest(High,length);//求length周期内最高价的最小值
   Myclose15=close;
   strkeyDate15=DateToString(Date)+":"+TimeToString(Time);
   SetTBProfileString("Min15L1",strkeyDate15,Text(L1));
   SetTBProfileString("Min15H1",strkeyDate15,Text(H1));
   SetTBProfileString("Myclose15",strkeyDate15,Text(close));
   PlotNumeric("Min15L1",L1);
   PlotNumeric("Min15H1",H1);
   PlotNumeric("Myclose15",Myclose15);
End

//30分钟线下
//------------------------------------------------------------------------
Params
        Numeric length(5);
Vars
    NumericSeries H1;
    NumericSeries L1;
        NumericSeries Myclose30;
        String strkeyDate30;
Begin
   L1=Highest(Low,length);//求length周期内最低价的最大值
   H1=Lowest(High,length);//求length周期内最高价的最小值
   Myclose30=close;
   strkeyDate30=DateToString(Date)+":"+TimeToString(Time);
   SetTBProfileString("Min30L1",strkeyDate30,Text(L1));
   SetTBProfileString("Min30H1",strkeyDate30,Text(H1));
   SetTBProfileString("Myclose30",strkeyDate30,Text(close));
   PlotNumeric("Min30L1",L1);
   PlotNumeric("Min30H1",H1);
   PlotNumeric("Myclose30",Myclose30);
End


然后我在3分钟线下调用以上两个周期的数据来做开仓的判断条件 代码如下
// 类别: 交易指令
// 类型: 多头建仓
// 输出:
//------------------------------------------------------------------------

Vars
        NumericSeries Min15L1;
        NumericSeries Min15H1;
        NumericSeries Myclose15;
        NumericSeries Min30L1;
        NumericSeries Min30H1;
        NumericSeries Myclose30;
        StringSeries strKey15;
    string strValue15L;
        string strValue15H;
        string strValue15C;
        StringSeries strKey30;
    string strValue30L;
        string strValue30H;
        string strValue30C;
        BoolSeries Condition16;
        BoolSeries Condition17;
        BoolSeries Condition18;
        BoolSeries Condition19;
Begin
        If(Minute==00||Minute==15||Minute==30||Minute==45)
        {
                strKey15 = DateToString(Date)+":"+TimeToString(Time);        
        }Else
        {
                strKey15 = strKey15[1];
        }
        strValue15L=GetTBProfileString("Min15L1",strKey15);
        strValue15H=GetTBProfileString("Min15H1",strKey15);
        strValue15C=GetTBProfileString("Myclose15",strKey15);
        If(strValue15L!=InvalidString)
        {
        Min15L1=Value(strValue15L);
        }Else
        {
        Min15L1=Min15L1[1];
        }
        If(strValue15H!=InvalidString)
        {
        Min15H1=Value(strValue15H);
        }Else
        {
        Min15H1=Min15H1[1];
        }
        If(strValue15C!=InvalidString)
        {
        Myclose15=Value(strValue15C);
        }Else
        {
        Myclose15=Myclose15[1];
        }//=========================================================================调用15分钟的H1\L1\Close
        If(Minute==00||Minute==30)
        {
                strKey30 = DateToString(Date)+":"+TimeToString(Time);        
        }Else
        {
                strKey30 = strKey30[1];
        }
        strValue30L=GetTBProfileString("Min30L1",strKey30);
        strValue30H=GetTBProfileString("Min30H1",strKey30);
        strValue30C=GetTBProfileString("Myclose30",strKey30);
        If(strValue30L!=InvalidString)
        {
        Min30L1=Value(strValue30L);
        }Else
        {
        Min30L1=Min30L1[1];
        }
        If(strValue30H!=InvalidString)
        {
        Min30H1=Value(strValue30H);
        }Else
        {
        Min30H1=Min30H1[1];
        }
        If(strValue30C!=InvalidString)
        {
        Myclose30=Value(strValue30C);
        }Else
        {
        Myclose30=Myclose30[1];
        }//=========================================================================调用30分钟的H1\L1\Close
        Condition16=Myclose15>Min15L1;
        Condition17=(Myclose15<Min15L1 And Myclose15>Min15H1 And ((Myclose15-Min15H1)/(Min15L1-Min15H1))<=0.3);
        Condition18=Myclose30>Min30L1;
        Condition19=(Myclose30<Min30L1 And Myclose30>Min30H1 And ((Myclose30-Min30H1)/(Min30L1-Min30H1))<=0.3);
If(Date!=date[1] And High==Low ) Return;//避免在8点59分发单
If(T<0.145400)//在14点54分之前执行以下操作
{
If((Condition16[1] Or Condition17[1])Or(Condition18[1]  Or Condition19[1]))
                {
                    Buy(0,Open);
                }
}
End

但是出现的结果令人费解啊,如图,我值加入一个多头开仓的指令,图表上奇怪的会显示平仓的信号,不知道哪里出问题了,大哥大姐们帮忙看下吧,,小弟谢过了
附件: 你需要登录才可以下载或查看附件。没有帐号?注册
程序化模型编写服务永久地址http://uucxh.taobao.com/

Rank: 5Rank: 5

精华
0
UID
28852
积分
651
帖子
153
主题
42
阅读权限
60
注册时间
2011-3-15
最后登录
2022-1-5
2#
发表于 2011-6-8 15:29:48 |只看该作者
回复 1# a415260930


    问题已解决 呵呵 设置问题 不在代码上,笨死了自己 呵呵

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

bottom

静态版|手机版|联系我们|交易开拓者 ( 粤ICP备07044698   

GMT+8, 2024-5-23 20:04

Powered by Discuz! X2 LicensedChrome插件扩展

© 2011-2012 交易开拓者 Inc.

回顶部