设为首页收藏本站

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

45分钟高低点记录,突破买进系统(含追踪止盈) [复制链接]

Rank: 4

精华
0
UID
11216
积分
254
帖子
35
主题
6
阅读权限
50
注册时间
2010-5-30
最后登录
2010-11-18
跳转到指定楼层
1#
发表于 2010-8-7 23:02:11 |只看该作者 |倒序浏览
本帖最后由 paozi84 于 2010-8-7 23:05 编辑

大概框架就是这样,但是为什么一调用程序了以后,在10点之前每个BAR上都会有买点?我在开仓位置是明明设置了Time>0.0915+nMins*0.0001。请高手指教!

params
        Numeric nMins(45);
Vars
        NumericSeries  HighestOfMins;
        NumericSeries  MidOfMins;
        NumericSeries  lowestOfMins;
        Numeric myprice;
        Numericseries Higherafterentry;
        Numericseries Lowerafterentry;
        Numeric HV(0);
        Numeric tstop(0);
        BoolSeries bLongTrailingStoped;//多头止损/止盈标记
     BoolSeries bshortTrailingStoped;//多头止损/止盈标记



Begin       

        If(Date != Date[1])
        {
                HighestOfMins = High;
                lowestOfMins = Low;
        }Else If(Time < 0.0915+nMins*0.0001)
        {
                HighestOfMins = max(high,HighestOfMins[1]);
                lowestOfMins = min(Low,lowestOfMins[1]);
        }Else
        {
                HighestOfMins = HighestOfMins[1];
                lowestOfMins = lowestOfMins[1];
        }
        MidOfMins=(HighestOfMins+lowestOfMins)/2;
If(BarsSinceEntry == 1)

        {
        HigherAfterEntry = AvgEntryPrice;
        LowerAfterEntry = HigherAfterEntry;
    }
Else If(BarsSinceEntry > 1)
   {
        HigherAfterEntry = Max(HigherAfterEntry[1],High[1]);
        LowerAfterEntry = Min(LowerAfterEntry[1],Low[1]);
    }
    Commentary("HigherAfterEntry="+Text(HigherAfterEntry));
    Commentary("LowerAfterEntry="+Text(LowerAfterEntry));
If(MarketPosition==1)
        HV=HigherAfterEntry-EntryPrice ;
If(MarketPosition==-1)
        HV=Abs(LowerAfterEntry-EntryPrice);
If(BarStatus > 0)
{
        bLongTrailingStoped = bLongTrailingStoped[1];
        bShortTrailingStoped = bShortTrailingStoped[1];
}
Commentary("bLongTrailingStoped="+IIFString(bLongTrailingStoped,"True","False"));
Commentary("bShortTrailingStoped="+IIFString(bShortTrailingStoped,"True","False"));


//------------------开仓功能代码----------------------------------------------

If(MarketPosition!=1 && High>HighestOfMins && Time>0.0915+nMins*0.0001)
        {
                MyPrice =  HighestOfMins;
                If(Open >  HighestOfMins) MyPrice = Open;
                Buy(1,MyPrice);
        }       
If(MarketPosition!=-1 && low<lowestOfMins && Time>0.0915+nMins*0.0001)
        {
                MyPrice =   lowestOfMins;
                If(Open <   lowestOfMins ) MyPrice = Open;
                SellShort(1,MyPrice);

        }
//------------------止损平仓功能代码----------------------------------------------
If(MarketPosition==1 && low<=  MidOfMins)
   {
                MyPrice =   MidOfMins;
                If(Open <   MidOfMins ) MyPrice = Open;
                Sell(1,MyPrice);

        }
             
If(MarketPosition==-1 &&  high>=  MidOfMins)
   {
                MyPrice =   MidOfMins;
                If(Open > MidOfMins ) MyPrice = Open;
                BuyToCover(1,MyPrice);
      
        }
//------------------追踪止盈平仓功能代码----------------------------------------------

If(MarketPosition==1 && 10<=HV&&HV<20);
{ Tstop=5;
        If(Low <= HigherAfterEntry - TStop);
        {
                MyPrice = HigherAfterEntry - TStop;
                If(Open < MyPrice) MyPrice = Open;
                Sell(1,MyPrice);
    bLongTrailingStoped=True;

        }
}       
If(MarketPosition==-1 && 10<=HV && HV<20)  
{ Tstop=5;
        If(High>= HigherAfterEntry + TStop);
        {
                MyPrice = HigherAfterEntry + TStop;
                If(Open >MyPrice) MyPrice = Open;
                BuyToCover(1,MyPrice);
       bshortTrailingStoped=True;
}
}
//------------------再次开仓功能----------------------------------------------
If(bLongTrailingStoped && MarketPosition==0 && High > HigherAfterEntry)
{
        MyPrice = HigherAfterEntry ;
        If(Open > MyPrice) MyPrice = Open;
        Buy(1,MyPrice);
        bLongTrailingStoped = False;

}
If(bShortTrailingStoped && MarketPosition==0 && Low < LowerAfterEntry)
{
        MyPrice = LowerAfterEntry ;
        If(Open < MyPrice) MyPrice = Open;
        SellShort(1,MyPrice);
        bShortTrailingStoped= False;

}

End
附件: 你需要登录才可以下载或查看附件。没有帐号?注册

Rank: 7Rank: 7Rank: 7

精华
0
UID
7437
积分
2872
帖子
537
主题
133
阅读权限
80
注册时间
2010-3-15
最后登录
2013-11-15
2#
发表于 2010-8-8 14:37:45 |只看该作者
本帖最后由 欲速不达 于 2010-8-8 15:06 编辑

开仓条件前面加一句if(time<=0.1000) Return;去掉&& Time>0.0915+nMins*0.0001,后面的反复开仓问题出在平仓上,如果没有平仓代码,直接去掉&& Time>0.0915+nMins*0.0001都可以

使用道具 举报

Rank: 4

精华
0
UID
11216
积分
254
帖子
35
主题
6
阅读权限
50
注册时间
2010-5-30
最后登录
2010-11-18
3#
发表于 2010-8-8 16:44:35 |只看该作者
请问if(time<=0.1000) Return;与 Time>0.0915+nMins*0.0001各表达的涵义不是一样的嘛?一个是如果时间每到10点,返回;另外一个是时间超过10点以后才开仓。

使用道具 举报

Rank: 7Rank: 7Rank: 7

精华
0
UID
7437
积分
2872
帖子
537
主题
133
阅读权限
80
注册时间
2010-3-15
最后登录
2013-11-15
4#
发表于 2010-8-8 23:51:08 |只看该作者
今天的10点以前也即昨天的10点以后,time并没有界定为当天时间

使用道具 举报

Rank: 5Rank: 5

精华
0
UID
24835
积分
910
帖子
94
主题
6
阅读权限
60
注册时间
2011-1-25
最后登录
2022-2-24
5#
发表于 2011-2-3 12:32:37 |只看该作者
0.0915+45*0.0001=这个表示10点???不是吧???

使用道具 举报

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

bottom

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

GMT+8, 2024-5-10 17:35

Powered by Discuz! X2 LicensedChrome插件扩展

© 2011-2012 交易开拓者 Inc.

回顶部