欢迎使用金字塔普通技术服务论坛,您可以在相关区域发表技术支持贴。
我司技术服务人员将优先处理 VIP客服论坛 服务贴,普通区问题处理速度慢,请耐心等待。谢谢您对我们的支持与理解。


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件公式模型编写问题提交 → 轮回小屋

   

欢迎使用金字塔普通技术服务论坛,您可以在相关区域发表技术支持贴。
我司技术服务人员将优先处理 VIP客服论坛 服务贴,普通区问题处理速度慢,请耐心等待。谢谢您对我们的支持与理解。    


  共有42203人关注过本帖树形打印复制链接

主题:轮回小屋

帅哥哟,离线,有人找我吗?
winewine99
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:新手上路 帖子:47 积分:422 威望:0 精华:1 注册:2010/3/19 15:47:54
老师这个tb如何改成金字塔  发帖心情 Post By:2010/3/25 8:39:06    Post IP:123.112.161.69[显示全部帖子]

 

Params
        Numeric nMins(30);                // N分钟的突破
    Numeric nOffset(3);                // 突破式的价格偏移
Vars
        NumericSeries HighestOf30Min;
    NumericSeries lowestOf30Min;
    Numeric myPrice;
    Numeric MinPoint;
    Numeric lots(1);
Begin
        MinPoint = MinMove*PriceScale;
        If(Date <> Date[1])
        {
                HighestOf30Min = High;
                lowestOf30Min = Low;
        }Else If(Time < 0.0900+nMins*0.0001)
        {
                HighestOf30Min = max(high,HighestOf30Min[1]);
                lowestOf30Min = min(Low,lowestOf30Min[1]);
        }Else
        {
                HighestOf30Min = HighestOf30Min[1];
                lowestOf30Min = lowestOf30Min[1];
        }
       
        If(High >= HighestOf30Min + nOffset*MinPoint && MarketPosition != 1)
        {
                myPrice = HighestOf30Min + nOffset*MinPoint;
                If(Open > myPrice) myPrice = Open;
                Buy(lots,myPrice);
        }

        If(Low <= lowestOf30Min - nOffset*MinPoint && MarketPosition != -1)
        {
                myPrice = lowestOf30Min - nOffset*MinPoint;
                If(Open < myPrice) myPrice = Open;
                SellShort(lots,myPrice);
        }

        If(Time >= 0.1459)
        {
                Sell(lots,Open);
                BuyToCover(lots,Open);
        }
End


 回到顶部
帅哥哟,离线,有人找我吗?
winewine99
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:新手上路 帖子:47 积分:422 威望:0 精华:1 注册:2010/3/19 15:47:54
谢谢老师辛苦了,高高手啊  发帖心情 Post By:2010/3/28 15:12:40    Post IP:123.112.155.84[显示全部帖子]

谢谢老师辛苦了,高高手啊

 回到顶部
帅哥哟,离线,有人找我吗?
winewine99
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:新手上路 帖子:47 积分:422 威望:0 精华:1 注册:2010/3/19 15:47:54
能不能在上面的系统上加入这部分功能?tb格式  发帖心情 Post By:2010/4/3 21:09:01    Post IP:123.112.162.39[显示全部帖子]


 

 

 

Params
        Numeric         tradState(0);                // 当前头寸,1=多,-1=空
        Numeric    tradCyc(0);                        // 持仓周期数
        Numeric         curProfit(0);                //持仓当前浮动盈亏
        Numeric         maxProfit(0);                //持仓最大浮盈
       
        Numeric stopLoss(0); //盈利低于此值时止损,为0不判断
        Numeric stopProfis(0); //盈利高于此值时止赢,为0不判断
       
        Numeric tracProfis(0); //盈利高于此值后执行追踪止赢,为0不判断
        Numeric tracLoss(0); //追踪止盈的回撤值,为0不判断,盈利超过tracProfis后,从最大浮赢回撤tracLoss后止盈       
       
        Numeric returnProfis(0); //盈利高于此值后执行回撤止赢,为0不判断       
               
        Numeric minProfis(0); //持仓bar数超过maxHoles后,盈利依然小于此值平仓,为0不判断       
        Numeric maxHolds(0);//最多持仓bar数,为0不判断
       
        Numeric closeTime(1457); //持仓bar的时间超过此时间后清仓

Vars
        String str(" ");
Begin

        //-------------------------------处理持仓-------------------------------------------
        if(tradState != 0 )
        {               
                //价格止损:亏损超过stopLoss-------------------------------------------------
                If(stopLoss>0)
                {
                        If(curProfit<=(0-stopLoss) )        str = "止损平仓";       
                }
               
                //时间止损:持仓超过maxHolds后最大浮动盈亏在正负minProfis之间------------------------------
                If(minProfis>0 And maxHolds>0)
                {
                        If(curProfit<=minProfis And tradCyc>=maxHolds )        str = "超时未达盈利平仓";                               
                }               
                //超时平仓--------------------------------------------------------------
                If(closeTime>100)
                {
                        If(Time>=0.0001*closeTime)         str = "超过清仓时间平仓";       
               
                }
                //停板平仓-----------------------------------------------
                If(BarStatus==2)
                {
                        if(High==Q_UpperLimit() Or Low==Q_LowerLimit())        str = "停板平仓";       
                }
                Else
                {
                        if(High==Low And High==Close And High[1]==Low[1] And High[2]==Low[2])        str = "停板平仓";                                       
                }

                //价格止盈:盈利超过stopProfis-----------------------------------------------
                If(stopProfis>0)
                {
                        If(curProfit>=stopProfis )        str = "止盈平仓";                       
                }
               
                //跟踪止盈:盈利超过tracProfis后回撤超过tracLoss平仓---------------------------
                If(tracLoss>0 And tracProfis>0)
                {
                        If((maxProfit-curProfit)>=tracLoss And maxProfit>tracProfis)        str = "跟踪止盈平仓";                       
                }
                //回撤止盈:盈利超过returnProfis后回撤平仓-------------------------------------
                If(returnProfis>0 And maxProfit>0.9*returnProfis)
                {
                        If(maxProfit>0.9*returnProfis And maxProfit<=1.1*returnProfis And curProfit<=0.1*maxProfit)        str = "盈利回撤止盈平仓1倍90%";       
                       
                        If(maxProfit>1.1*returnProfis And maxProfit<=2*returnProfis And curProfit<=0.5*maxProfit)        str = "盈利回撤止盈平仓1-2倍50%";       
                       
                        If(maxProfit>2*returnProfis And maxProfit<=3*returnProfis And curProfit<=0.6*maxProfit)        str = "盈利回撤止盈平仓2-3倍40%";                       
                       
                        If(maxProfit>3*returnProfis And maxProfit<=4*returnProfis And curProfit<=0.7*maxProfit)        str = "盈利回撤止盈平仓3-4倍30%";               
                       
                        If(maxProfit>4*returnProfis And maxProfit<=5*returnProfis And curProfit<=0.8*maxProfit)        str = "盈利回撤止盈平仓4-5倍20%";               

                        If(maxProfit>6*returnProfis And curProfit<=0.9*maxProfit)        str = "盈利回撤止盈平仓大于6倍10%";                                                
                       
                }       
        }
        Return str;
End


 回到顶部