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


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

   

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


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

主题:TB转金字塔

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


加好友 发短信
等级:新手上路 帖子:23 积分:0 威望:0 精华:0 注册:2021/3/24 10:28:49
TB转金字塔  发帖心情 Post By:2021/3/30 8:38:47    Post IP:58.246.57.26[显示全部帖子]

老师好,请您帮忙改成金字塔的交易模型吧,TB的我实在是适应不了,谢谢您啦!

代码如下:

Params
    Numeric OFF(0); 
Numeric M(85);
Numeric ZJL(10);
Numeric STPRATE(3.5);
Vars
Numeric MN2;
Numeric MN3;
Series<Numeric> MA2;
Series<Numeric> MA3;
Numeric P;
Series<Numeric> MID1;
Series<Numeric> UPPER1;
Series<Numeric> LOWER1;
Series<Numeric> BLDK1;
Series<Bool> BuyConPre;
Series<Bool> SelConPre;
Bool BuyCon;
Bool SelCon;
Numeric BuyPrice;
Numeric SelPrice;
Numeric MINDIFF;
Numeric BuySTPPrice;
Numeric SelSTPPrice;
Series<Bool> BuyExitCon2PRE;
Series<Bool> BuyExitCon3PRE;
Series<Bool> BuyExitCon8PRE;
Series<Bool> SelExitCon2PRE;
Series<Bool> SelExitCon3PRE;
Series<Bool> SelExitCon8PRE;
Bool BuyExitCon2;
Bool BuyExitCon3;
Bool BuyExitCon8;
Bool SelExitCon2;
Bool SelExitCon3;
Bool SelExitCon8;
Numeric BuyExitPrice2;
Numeric SelExitPrice2;
Numeric BuyExitPrice3;
Numeric SelExitPrice3;
Numeric BuyExitPrice8;
Numeric SelExitPrice8;
Numeric LotsOrder;
Series<Numeric> XH;
Series<Numeric> XL;
Series<Numeric> MAH;
Series<Numeric> MAL;
Series<Numeric> ZH;
Series<Numeric> ZL;
Events
    onBar(ArrayRef<Integer> indexs)
    {    
    //------------------------------------------------------------------
    XH=(H+C)/2;
    XL=(L+C)/2;
    MAH=(AverageFC(XH,2)+AverageFC(XH,4))/2;
    MAL=(AverageFC(XL,2)+AverageFC(XL,4))/2;
    ZH=MAH*(1+1/10000);
    ZL=MAL*(1-1/10000);
    //------------------------------------------------------------------
    P=2;
    MID1 =  AverageFC(CLOSE,M);
    UPPER1= MID1 + P*StandardDev(CLOSE,M,2);
    LOWER1= MID1 - P*StandardDev(CLOSE,M,2);
    BLDK1 = (UPPER1-LOWER1)/MID1;
    //------------------------------------------------------------------
    MN2=INTPART(M/2);
    MN3=INTPART(2*M);
    MA2 = AverageFC(CLOSE,MN2);
    MA3 = AverageFC(CLOSE,MN3);
    //------------------------------------------------------------------
    MINDIFF = MinMove*PriceScale;
    //------------------------------------------------------------------
    BuyConPre = (CLOSE>MA2 AND MA2>=MID1 AND MID1>=MID1[1] AND MA3>=MA3[1] AND CLOSE>=UPPER1 AND ZH>=ZH[1]);
    SelConPre = (CLOSE<MA2 AND MA2<=MID1 AND MID1<=MID1[1] AND MA3<=MA3[1] AND CLOSE<=LOWER1 AND ZL<=ZL[1]);
    BuyCon = BuyConPre[1];
    SelCon = SelConPre[1];
    //---------------------------------------------------------------
    BuyPrice = OPEN+OFF*MINDIFF;
    SelPrice = OPEN-OFF*MINDIFF;
    //---------------------------------------------------------------
    LotsOrder = Max(1,max(FLOOR(ZJL*10000/(CLOSE[1]*ContractUnit*0.1),1),1));
    //---------------------------------------------------------------
    If(BuyCon and MarketPosition<=0)
    {
    If(MarketPosition<0)
    {
    BuyToCover(LotsOrder,BuyPrice);
    }
    If(BuyCon)
    {
    Buy(LotsOrder,BuyPrice);
    }
    }
    If(SelCon and MarketPosition>=0)
    {
    If(MarketPosition>0)
    {
    Sell(LotsOrder,SelPrice);
    }
    If(SelCon)
    {
    SELLSHORT(LotsOrder,SelPrice);
    }
    }
    //---------------------------------------------------------------
    BuySTPPrice = AvgEntryPrice*(1 - STPRATE/100);
    SelSTPPrice = AvgEntryPrice*(1 + STPRATE/100);
    //-------------------------------------------------------------------------
    //平仓条件区
    BuyExitCon2PRE = (CLOSE<MID1);
    SelExitCon2PRE = (CLOSE>MID1);
    BuyExitCon3PRE = (MA2<=MA3 AND CLOSE<MA2);
    SelExitCon3PRE = (MA2>=MA3 AND CLOSE>MA2);
    BuyExitCon8PRE = (LOW<=BuySTPPrice);
    SelExitCon8PRE = (High>=SelSTPPrice);
    //-------------------------------------------------------------------------
    BuyExitCon2 = (MarketPosition>0 and BuyExitCon2PRE[1]);
    SelExitCon2 = (MarketPosition<0 and SelExitCon2PRE[1]);
    BuyExitCon3 = (MarketPosition>0 and BuyExitCon3PRE[1]);
    SelExitCon3 = (MarketPosition<0 and SelExitCon3PRE[1]);
    BuyExitCon8 = (MarketPosition>0 and BuyExitCon8PRE);
    SelExitCon8 = (MarketPosition<0 and SelExitCon8PRE);
    //-------------------------------------------------------------------------
    BuyExitPrice2 = OPEN-OFF*MINDIFF;
    BuyExitPrice3 = OPEN-OFF*MINDIFF;
    SelExitPrice2 = OPEN-OFF*MINDIFF;
    SelExitPrice3 = OPEN-OFF*MINDIFF;
    BuyExitPrice8 = Min(OPEN,BuySTPPrice)-OFF*MINDIFF;
    SelExitPrice8 = Max(OPEN,SelSTPPrice)-OFF*MINDIFF;
    //-------------------------------------------------------------------------
    If(BuyExitCon2)
    {
    Sell(LotsOrder,BuyExitPrice2);
    }
    If(BuyExitCon3)
    {
    Sell(LotsOrder,BuyExitPrice3);
    }
    If(BuyExitCon8)
    {
    Sell(LotsOrder,BuyExitPrice8);
    }
    If(SelExitCon2)
    {
    BuyToCover(LotsOrder,SelExitPrice2);
    }
    If(SelExitCon3)
    {
    BuyToCover(LotsOrder,SelExitPrice3);
    }
    If(SelExitCon8)
    {
    BuyToCover(LotsOrder,SelExitPrice8);
    }
   
    }

//------------------------------------------------------------------------

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


加好友 发短信
等级:新手上路 帖子:23 积分:0 威望:0 精华:0 注册:2021/3/24 10:28:49
  发帖心情 Post By:2021/3/30 16:19:11    Post IP:118.195.142.7[显示全部帖子]

语法差异大?您指的是文华和金字塔的差异小,TB和金字塔的差异大吗?

 回到顶部