以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://222.73.7.161/bbs/index.asp)
--  公式模型编写问题提交  (http://222.73.7.161/bbs/list.asp?boardid=4)
----  [求助]TB代码修改成金字塔代码  (http://222.73.7.161/bbs/dispbbs.asp?boardid=4&id=171695)

--  作者:诚诚
--  发布时间:2019/8/19 12:57:18
--  [求助]TB代码修改成金字塔代码
原来是在TB交易开拓者运行的策略源码,现想请技术员修改某些语句代码以便能加载到金字塔运行。
Params
Numeric AfStep( 0.02);
Numeric AfLimit( 0.2 ) ;
Numeric Length(50); //均线周期
Numeric Tiao(0); //跳数
Numeric Lots(1); //仓量 
Numeric lostPoint(100); // 50个点,止损
Vars
Numeric oParCl( 0 ); 
Numeric oParOp( 0 );
Numeric oPosition( 0 ); 
Numeric oTransition( 0 );
NumericSeries sar; 
Numeric ma;
NumericSeries isDo;
NumericSeries lastOpen; 
// NumericSeries sar;
Numeric minpoint;
NumericSeries myenterPrice;
Numeric zhisunPrice;
Begin

ma = AverageFC(Close[1],Length);
ParabolicSAR( AfStep, AfLimit, oParCl, oParOp, oPosition, oTransition ) ;


COMMENTARY("oParCl="+ Text(oParCl));
// COMMENTARY("oParOp"+ Text(oParOp));
// COMMENTARY("oPosition"+ Text(oPosition));
// COMMENTARY("oTransition"+ Text(oTransition));
// COMMENTARY("MarketPosition"+ Text(MarketPosition));
// COMMENTARY("isDo[0]"+ Text(isDo));
// COMMENTARY("isDo[1]"+ Text(isDo[1]));
COMMENTARY("ma="+ Text(ma));
PlotNumeric("oParCl" , oParCl);
minpoint = MinMove*PriceScale;
zhisunPrice = MinMove * PriceScale * lostPoint;
isDo = oParCl - ma - 10 * Tiao;

If(MarketPosition==1 ) 
{
// If(isDo[0] > 0 && isDo[1] <= 0){
If(oParCl > H){
Sell(Lots, (h+l)/2);
SellShort(Lots, (h+l)/2);
lastOpen = O;
}
// zhisunPrice
else if(close[1] < lastOpen - zhisunPrice) {
sell(LOTS, open);
}
}Else If(MarketPosition==-1){
If(oParCl < L){
BuyToCover(Lots, (h+l)/2);
Buy(Lots, (h+l)/2);
lastOpen = O;
// zhisunPrice
}else if (close[1] > lastOpen + zhisunPrice)
{
BuyToCover(LOTS,o);
 

}
}Else If(MarketPosition==0){
If(oParCl < L){
Buy(Lots, O);
lastOpen = O;
}Else If(oParCl > H){
SellShort(Lots, O);
lastOpen = O;
}
}
End

--  作者:FireScript
--  发布时间:2019/8/19 14:01:53
--  
 因为代码不兼容,基本上需要全部修改一遍。工作人员需要尝试一下。此类需求建议直接提供策略思路会好点,因为有些软件代码系统和我们金字塔的差异还是非常大的。修改得话,我们还要去查阅其他软件的文档才能实现。