设为首页收藏本站

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

恳请哪位老师提供一个tb的海龟汤交易程序。 [复制链接]

Rank: 1

精华
0
UID
219116
积分
6
帖子
3
主题
3
阅读权限
10
注册时间
2015-9-8
最后登录
2016-4-17
跳转到指定楼层
1#
发表于 2015-12-30 22:05:29 |只看该作者 |倒序浏览
恳请哪位老师提供一个tb的海龟汤交易程序,或者有偿写一个,联系电话:15737175291

Rank: 1

精华
0
UID
212983
积分
49
帖子
34
主题
15
阅读权限
10
注册时间
2015-7-6
最后登录
2023-4-19
2#
发表于 2016-1-5 11:26:44 |只看该作者
TB自带的公式应用里面有海龟交易 TurtleTrader
或者在论坛里面搜索早期关于海龟的帖子也可以的

使用道具 举报

Rank: 1

精华
0
UID
216337
积分
19
帖子
9
主题
3
阅读权限
10
注册时间
2015-8-7
最后登录
2016-11-5
3#
发表于 2016-1-5 23:23:32 |只看该作者

Begin
        MinPoint = MinMove*PriceScale;
        MyBarsSinceToday = BarsSinceToday;
        CloseD_1 = CloseD(1);
        
        if(BarsSinceToday==0)
        {
                DayCount = DayCount + 1;  //记录交易日数;
                DayHigh = High;
                DayLow = Low;
               
                //从第二个交易日开始记录;
                if(DayCount>=2)  
                {                        
                        // 前一日真实波幅;
                        Atr = max(max(Abs(DayHigh[1]-CloseD_1),Abs(DayLow[1]-CloseD_1)),DayHigh[1]-DayLow[1]);  
                        
                        // 存储前一天的Atr到全局变量环0-19;
                        AtrIndex =  (DayCount-2)%LengthAtr;
                        SetGlobalVar(AtrIndex,Atr[1]);
                }
               
                // 从第LengthAtr+1个交易日开始计算;
                if(DayCount>=LengthAtr+1)  
                {
                        // 计算日线级别长度为LengthAtr的平均真实波幅;
                        AtrAve = 0 ;
                        for i=0 to LengthAtr-1
                        {
                                AtrAve = AtrAve +  getGlobalVar(i);
                        }
                        AtrAve = AtrAve/LengthAtr;
                        N = IntPart(AtrAve);
                        
                        DonchianFastUpper = Highest(DayHigh[1],(LengthAtr-0.1)*(MyBarsSinceToday[1]+1));
                        DonchianFastLower = Lowest(DayLow[1],(LengthAtr-0.1)*(MyBarsSinceToday[1]+1));
                        
                        DonchianSlowUpper = Highest(DayHigh[1],(LengthSlow-0.1)*(MyBarsSinceToday[1]+1));
                        DonchianSlowLower = Lowest(DayLow[1],(LengthSlow-0.1)*(MyBarsSinceToday[1]+1));
                        
                        DonchianExitUpper = Highest(DayHigh[1],(LengthExit-0.1)*(MyBarsSinceToday[1]));
                        DonchianExitLower = Lowest(DayLow[1],(LengthExit-0.1)*(MyBarsSinceToday[1]));
                }
               
                //账户最新资产 = 按当前Bar开盘价计算的可用资金 + 持仓保证金 ;
                TotalEquity = Portfolio_CurrentCapital() + Portfolio_UsedMargin();
                //标准单位头寸 = (本金*风险比例)/价值波动率
                TurtleUnits = (TotalEquity*RiskRatio/100) /(N * ContractUnit()*BigPointValue());
                TurtleUnits = IntPart(TurtleUnits); // 对小数取整
                // PlotString("Units","Units="+Text(TurtleUnits),High+(High-Low),white);
                // PlotString("N","N="+Text(N),Low-(High-Low)/2,white);
        }
        Else
        {
                DayHigh = Max(DayHigh,High);
                DayLow = Min(DayLow,Low);
        }

        If(MarketPosition==0 and TurtleUnits>=1)
        {
                // 首次入市1:带过滤条件的,如果过滤条件为真,则需要前一笔交易是否是突破失败;
                if(LastProfitableTradeFilter==false Or PreBreakoutFailure )
                {
                        //开多1:突破短周期唐奇安通道上轨;
                        If(High>DonchianFastUpper)
                        {
                                MyPrice = Max(Open,DonchianFastUpper)+MinPoint;
                                Buy(TurtleUnits,MyPrice);
                                MyExitPrice = MyPrice - 2*N;
                                SendOrderThisBar = true;
                        }
                        
                        //开空1:突破短周期唐奇安通道下轨;
                        if(Low<DonchianFastLower)
                        {
                                MyPrice = Min(Open,DonchianFastLower)-MinPoint;
                                SellShort(TurtleUnits,MyPrice);
                                MyExitPrice = MyPrice + 2*N;
                                SendOrderThisBar = true;
                        }
                }
               
                // 首次入市2:过滤条件之外的,长周期唐奇安通道突破开仓;
                //开多2:突破长周期唐奇安通道上轨;
                else
                {
                        if(CrossOver(High,DonchianSlowUpper))
                        {
                                MyPrice = Max(Open,DonchianSlowUpper)+MinPoint;
                                Buy(TurtleUnits,MyPrice);
                                MyExitPrice = MyPrice - 2*N;
                                SendOrderThisBar = true;
                        }
                        //开空2:突破长周期唐奇安通道下轨;
                        if(CrossUnder(Low,DonchianSlowLower))
                        {
                                MyPrice = Min(Open,DonchianSlowLower)+MinPoint;
                                SellShort(TurtleUnits,MyPrice);
                                MyExitPrice = MyPrice + 2*N;
                                SendOrderThisBar = true;
                        }
                }
        }
        
        // 当持有多单;
        if(MarketPosition==1)
        {
                //离市:价格反向穿越离市的唐奇安通道;
                if(CrossUnder(Low,DonchianExitLower))
                {
                        MyPrice = Min(Open,DonchianExitLower)-MinPoint;
                        Sell(0,MyPrice);
                        PreBreakoutFailure = False;  //假突破值为假;
                        // PlotBool("突破",PreBreakoutFailure,High,white);
                }
                Else
                {
                        //加仓:与最近一次开仓价间隔0.5*N开仓;
                        if(High>LastEntryPrice+0.5*N and TurtleUnits>=1)
                        {
                                MyPrice = Max(Open,LastEntryPrice+0.5*N)-MinPoint;
                                Buy(TurtleUnits,MyPrice);
                                SendOrderThisBar = true;
                        }
                        
                        //止损:价格反向穿越最近一次开仓价格-2N;
                        if(Low<LastEntryPrice-2*N)
                        {
                                MyPrice = Min(Open,LastEntryPrice-2*N)-MinPoint;
                                Sell(0,MyPrice);
                                PreBreakoutFailure = True;  //假突破值为真;
                                // PlotBool("突破",PreBreakoutFailure,High,white);
                        }
                }
        }
        // 当持有空单;
        else if(MarketPosition==-1)
        {
                // 离市:价格反向穿越离市的唐奇安通道;
                if(CrossOver(High,DonchianExitUpper))
                {
                        MyPrice = Max(Open,DonchianExitUpper)+MinPoint;
                        BuyToCover(0,MyPrice);
                        PreBreakoutFailure = False;  //假突破值为假;
                        // PlotBool("突破",PreBreakoutFailure,High,white);
                }
                Else
                {
                        // 加仓:与最近一次开仓价格间隔0.5*N开仓;
                        if(Low<LastEntryPrice-0.5*N and TurtleUnits>=1)
                        {
                                MyPrice = Min(Open,LastEntryPrice-0.5*N)-MinPoint;
                                SellShort(TurtleUnits,MyPrice);
                                SendOrderThisBar = true;
                        }
                        
                        // 止损:价格反向穿越最近一次开仓价格+2N;
                        if(High>LastEntryPrice+2*N)
                        {
                                MyPrice = Max(Open,LastEntryPrice+2*N)+MinPoint;
                                BuyToCover(0,MyPrice);
                                PreBreakoutFailure = True;  //假突破值为真;
                                // PlotBool("突破",PreBreakoutFailure,High,white);
                        }
                }
        }
        
        PlotNumeric("DonchianFastUpper",DonchianFastUpper);
        PlotNumeric("DonchianFastLower",DonchianFastLower);
        PlotNumeric("DonchianSlowUpper",DonchianSlowUpper);
        PlotNumeric("DonchianSlowLower",DonchianSlowLower);
        PlotNumeric("DonchianExitUpper",DonchianExitUpper);
        PlotNumeric("DonchianExitLower",DonchianExitLower);        
        
        // Commentary("点值="+Text(ContractUnit()*BigPointValue()));
        Commentary("TotalEquity="+Text(TotalEquity));
        Commentary("N="+Text(N));
        Commentary("Units="+Text(TurtleUnits));
        // Commentary("Atr="+Text(Atr));
        // Commentary("AtrAve="+Text(AtrAve));
        // PlotNumeric("AtrAve",AtrAve);
        Commentary("DayCount="+Text(DayCount));
        Commentary("MyBarsSinceToday="+Text(MyBarsSinceToday[1]+1));
        
        if(PreBreakoutFailure == True)
        {
                Commentary("PreBreakoutFailure = True");
        }Else
        {
                Commentary("PreBreakoutFailure = false");
        }
        
        if(LastProfitableTradeFilter==true)
        {
                Commentary("LastProfitableTradeFilter = True");
        }Else
        {
                Commentary("LastProfitableTradeFilter = False");
        }
        
End

使用道具 举报

Rank: 1

精华
0
UID
222824
积分
1
帖子
1
主题
0
阅读权限
10
注册时间
2015-11-9
最后登录
2016-4-7
4#
发表于 2016-3-16 23:47:13 |只看该作者
gfqh882011127 发表于 2016-1-5 23:23
Begin
        MinPoint = MinMove*PriceScale;
        MyBarsSinceToday = BarsSinceToday;

请问,这个海龟和TB系统自带的海龟有什么不同的地方吗?

使用道具 举报

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

bottom

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

GMT+8, 2024-4-29 01:36

Powered by Discuz! X2 LicensedChrome插件扩展

© 2011-2012 交易开拓者 Inc.

回顶部