设为首页收藏本站

 找回密码
 注册
楼主: kongwei1107
打印 上一主题 下一主题

请版主看看陈总讲课的这段程序为什么我总调不通? [复制链接]

Rank: 2

精华
0
UID
102604
积分
70
帖子
7
主题
3
阅读权限
30
注册时间
2012-3-6
最后登录
2012-4-6
31#
发表于 2012-3-8 11:21:37 |只看该作者
回复 2# 追涨杀跌


    aeetesking@qq.com; 非常感谢!

使用道具 举报

Rank: 4

精华
0
UID
13040
积分
337
帖子
69
主题
39
阅读权限
50
注册时间
2010-6-25
最后登录
2013-8-6
32#
发表于 2012-3-12 01:29:13 |只看该作者
回复 2# 追涨杀跌

非常感谢!392613533@QQ.COM

使用道具 举报

Rank: 4

精华
0
UID
57361
积分
383
帖子
45
主题
15
阅读权限
50
注册时间
2011-8-3
最后登录
2017-3-21
33#
发表于 2012-5-4 11:38:40 |只看该作者
好像#10楼的代码有错误:
117行源代码为
If(LowerAfterEntry<=EntryPrice*(1+BreakEvenStop/1000))               StopLine=EntryPrice;
我感觉应该是
If(LowerAfterEntry<=EntryPrice*(1-BreakEvenStop/1000))               StopLine=EntryPrice;
原来一切都都缘于概率和统计

使用道具 举报

Rank: 2

精华
0
UID
107997
积分
115
帖子
89
主题
6
阅读权限
30
注册时间
2012-3-30
最后登录
2015-2-14
34#
发表于 2012-5-4 16:02:25 |只看该作者
追涨杀跌 发表于 2011-6-30 22:07
回复 1# kongwei1107

这个例子的源代码,课后有很多朋友都拷贝了,如果需要,留下您的Email,回头发给您 ...

谢谢超版,给我发一份吧。
lanhaiyanjiu123@sohu.com

使用道具 举报

Rank: 4

精华
0
UID
66713
积分
281
帖子
101
主题
37
阅读权限
50
注册时间
2011-9-20
最后登录
2022-11-19
35#
发表于 2012-5-4 22:44:29 |只看该作者
我也想要一份,谢谢!szzhhajd@163.com

使用道具 举报

Rank: 4

精华
0
UID
66713
积分
281
帖子
101
主题
37
阅读权限
50
注册时间
2011-9-20
最后登录
2022-11-19
36#
发表于 2012-5-4 22:46:48 |只看该作者
追涨杀跌 发表于 2011-6-30 22:07
回复 1# kongwei1107

这个例子的源代码,课后有很多朋友都拷贝了,如果需要,留下您的Email,回头发给您 ...

我也想要一份,谢谢!szzhhajd@163.com

使用道具 举报

Rank: 5Rank: 5

精华
0
UID
4647
积分
1403
帖子
432
主题
31
阅读权限
60
注册时间
2009-6-16
最后登录
2019-10-27
37#
发表于 2012-5-6 09:05:56 |只看该作者
花了一点时间学习了穿堂风老兄的版本,针对当前BAR内开平仓的问题,做了几处修改,基本上能运行了,优化后模型在IF000上能够获利。

现将修改后的贴出来供大家参考。再次感谢穿堂风兄,让我学到不少东西!

//------------------------------------------------------------------------
// 简称: atest0_
// 名称: 陈总课件_穿堂风修改_liq77再次修改
// 类别: 公式应用
// 类型: 用户应用
// 输出:
//------------------------------------------------------------------------

Params                                                
        Numeric Length1(10);
        Numeric Length2(20);
        Numeric Lots(1);   
        Numeric InitialStop(20);                    // 初始止损(千分之N)
        Numeric BreakEvenStop(30);                  // 保本止损(千分之N)
        Numeric TrailingStop(50);                   // 追踪止损(千分之N)
         
Vars                                                   
        NumericSeries MA1;                           
        NumericSeries MA2;
        BoolSeries condBuy(false);
        BoolSeries condSell(false);
        Numeric MinPoint;
        Numeric MyPrice;
        NumericSeries HigherAfterEntry;
        NumericSeries LowerAfterEntry;
        BoolSeries bLongStoped(false);
        BoolSeries bShortStoped(false);
        Numeric StopLine;
        Numeric StopLine1;
        Numeric StopLine2;
        Numeric StopLine3;
        String strDate;
        String strTime;
        String TRADENAME;

Begin  
        if(condBuy==false and condSell==false )
        {
                condBuy=condBuy[1];
                condSell=condSell[1];
        }
        if(BarStatus>0)
        {
                bLongStoped=bLongStoped[1];                  //多头止损情况
                bShortStoped=bShortStoped[1];                //空头止损情况
        }
                                                                                                
        MinPoint=MinMove * PriceScale;
        MA1=AverageFC(Close,Length1);              
        MA2=AverageFC(Close,Length2);               
        condBuy=CrossOver(MA1,MA2);
        condSell=CrossUnder(MA1,MA2);
        
        If(MarketPosition!=1 and condBuy[1]==true and bLongStoped==False)//初次进场做多
        {
                Buy(Lots,Open);
                        
                HigherAfterEntry=Open;
                LowerAfterEntry=Open;
                        
                bLongStoped=False;//重置标志
                bShortStoped=False;//重置标志
               
                Commentary("Buy Firsttime at "+text(Open));
                Commentary("HAE="+TEXT(HigherAfterEntry)+" LAE="+Text(LowerAfterEntry));
                Commentary("bLongStoped="+IIFString(bLongStoped,"TRUE","FALSE"));
                Commentary("bShortStoped="+IIFString(bShortStoped,"TRUE","FALSE"));               
        }
        If(MarketPosition!=-1 and condSell[1]==true and bShortStoped==False)//初次进场做空
        {
                SellShort(lots,Open);
                        
                HigherAfterEntry=Open;
                LowerAfterEntry=Open;
                        
                bLongStoped=False;//重置标志
                bShortStoped=False;//重置标志
        
                Commentary("SellShort Firsttime at "+text(Open));
                Commentary("HAE="+TEXT(HigherAfterEntry)+" LAE="+Text(LowerAfterEntry));
                Commentary("bLongStoped="+IIFString(bLongStoped,"TRUE","FALSE"));
                Commentary("bShortStoped="+IIFString(bShortStoped,"TRUE","FALSE"));
        }
        If(BarsSinceEntry>=1)
        {
                HigherAfterEntry=Max(HigherAfterEntry[1],High[1]);
                LowerAfterEntry=Min(LowerAfterEntry[1],Low[1]);
        }
       // Else
        //{
        //        HigherAfterEntry=HigherAfterEntry[1];
        //        LowerAfterEntry=LowerAfterEntry[1];
       // }
               
        If(MarketPosition==1)//多头止损部分的代码
        {
               
                StopLine=EntryPrice * (1-InitialStop/1000);        
                If (HigherAfterEntry>=EntryPrice*(1+BreakEvenStop/1000))
                {
                        StopLine=EntryPrice;
                }
                If (StopLine<HigherAfterEntry*(1-TrailingStop/1000))
                {
                        StopLine=HigherAfterEntry*(1-TrailingStop/1000);
                }
                              
                Commentary("止损价:"+Text(StopLine));        
               
                If(Low<=StopLine)// 止损触发
                {
                        MyPrice=StopLine;
                        If(Open<MyPrice)
                        {
                                MyPrice=Open;
                        }
                        Sell(Lots,MyPrice);
                                       
                        bLongStoped=True;                // 止损后设置标志
                                                    
                        Commentary("Long Position Stoped at "+text(MyPrice));
                }
        }
        If(MarketPosition==-1)//空头止损部分的代码
        {
                StopLine=EntryPrice*(1+InitialStop/1000);
                               
                If(LowerAfterEntry<=EntryPrice*(1-BreakEvenStop/1000))
                               
                                StopLine=EntryPrice;
                               
                If(StopLine<LowerAfterEntry*(1+TrailingStop/1000))
                               
                                StopLine=LowerAfterEntry*(1+TrailingStop/1000);
                                       
                Commentary("止损价:"+Text(StopLine));
               
                If(High>=StopLine)// 止损触发
                {
                        MyPrice=StopLine;
                        If(Open>MyPrice)
                        {
                                MyPrice=Open;
                        }
                        BuyToCover(Lots,MyPrice);
        
                        bShortStoped=True;                // 止损后设置标志
                     
                        Commentary("Short Position Stoped at "+text(MyPrice));
                }
        }
        IF(bLongStoped AND MarketPosition==0 AND H>HigherAfterEntry)//二次进场做多
        {
                MyPrice=HigherAfterEntry+MinPoint;
                If(Open>MyPrice)
                {
                        MyPrice=Open;
                }
                        
                Buy(Lots,MyPrice);
                        
                bLongStoped=False;
                        
                HigherAfterEntry=AvgEntryPrice;
                LowerAfterEntry=HigherAfterEntry;
               
                Commentary("Buy Secondtime at "+text(Open));
                Commentary("HAE="+TEXT(HigherAfterEntry)+" LAE="+Text(LowerAfterEntry));
                Commentary("bLongStoped="+IIFString(bLongStoped,"TRUE","FALSE"));
                Commentary("bShortStoped="+IIFString(bShortStoped,"TRUE","FALSE"));
                        
                Return;
        }
        If(bShortStoped AND MarketPosition==0 AND L<LowerAfterEntry)//二次进场做空
        {
                MyPrice=LowerAfterEntry - MinPoint;
                If(Open<MyPrice)
                {
                        MyPrice = Open;
                }
                        
                SellShort(Lots,MyPrice);
                        
                bShortStoped=False;
               
                LowerAfterEntry=AvgEntryPrice;
                HigherAfterEntry=LowerAfterEntry;
                        
                Commentary("SellShort Secondtime at "+text(Open));
                Commentary("HAE="+TEXT(HigherAfterEntry)+" LAE="+Text(LowerAfterEntry));
                Commentary("bLongStoped="+IIFString(bLongStoped,"TRUE","FALSE"));
                Commentary("bShortStoped="+IIFString(bShortStoped,"TRUE","FALSE"));
                        
                Return;
        }
End

//------------------------------------------------------------------------
// 编译版本        GS2010.12.08
// 用户版本        2012/05/05 09:24
// 版权所有       
// 更改声明        TradeBlazer Software保留对TradeBlazer平台
//                        每一版本的TrabeBlazer公式修改和重写的权利
//------------------------------------------------------------------------

使用道具 举报

Rank: 5Rank: 5

精华
0
UID
4647
积分
1403
帖子
432
主题
31
阅读权限
60
注册时间
2009-6-16
最后登录
2019-10-27
38#
发表于 2012-5-6 09:22:05 |只看该作者
本帖最后由 liq77 于 2012-5-6 09:24 编辑

再放两张讯号图:
1.赚得很爽;

2.反复折磨;

1.

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

使用道具 举报

Rank: 5Rank: 5

精华
0
UID
73474
积分
1249
帖子
695
主题
30
阅读权限
60
注册时间
2011-10-22
最后登录
2015-11-6
39#
发表于 2012-5-6 10:29:33 |只看该作者
请问,Iiq77老师,为什么把这段去掉啊?
// Else
        //{
        //        HigherAfterEntry=HigherAfterEntry[1];
        //        LowerAfterEntry=LowerAfterEntry[1];
       // }

使用道具 举报

Rank: 5Rank: 5

精华
0
UID
4647
积分
1403
帖子
432
主题
31
阅读权限
60
注册时间
2009-6-16
最后登录
2019-10-27
40#
发表于 2012-5-6 19:10:10 |只看该作者
简单地说,这段代码会导致“高低点变量”的传递不受本次持仓条件的限制。某些条件下会导致同一根K线上开仓后立即止损平仓,与原先的设计不符。

使用道具 举报

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

bottom

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

GMT+8, 2024-5-4 10:07

Powered by Discuz! X2 LicensedChrome插件扩展

© 2011-2012 交易开拓者 Inc.

回顶部