以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  求tb改金字塔  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=29697)

--  作者:kongfzchina
--  发布时间:2012/10/9 19:29:21
--  求tb改金字塔
//------------------------------------------------------------------------
// 简称: JYXT_Aberration
// 名称: Aberration
// 类别: 公式应用
// 类型: 用户应用
// 输出:Rookies
//------------------------------------------------------------------------
Params
Numeric Length(35);
Numeric StdDevUp(2.0);
Numeric StdDevDn(-2.0);
Numeric Lots(1);


Vars
NumericSeries UpperBand;
NumericSeries LowerBand;
NumericSeries AveMa;
Numeric StdValue;


Begin

AveMa=Average(Close[1],Length);
StdValue = StandardDev(Close[1],Length);

UpperBand=Avema+StdDevUp*StdValue;
LowerBand=Avema-StdDevUp*StdValue;
PlotNumeric("UpperBand",UpperBand);
PlotNumeric("LowerBand",LowerBand);

PlotNumeric("AveMa",AveMa);
If(MarketPosition!=1 &&CrossOver(Close[1],UpperBand[1]))
{
Buy(Lots,Open);
}

If(MarketPosition!=-1 &&CrossUnder(Close[1],LowerBand[1]))
{
SellShort(Lots,Open);
}

If(MarketPosition==1 && Close[1]<AveMa[1])
{
Sell(Lots,Open);

}

If(MarketPosition==-1 && Close[1]>AveMa[1])
{

BuyToCover(Lots,Open);
}

End

--  作者:every
--  发布时间:2012/10/10 9:07:53
--  

对TB的有些函数不熟悉,速度慢不说,可能还会改的不达效果.

 

推荐楼主把想改的这段TB的代码,用自然语言的形式描述出来,让客服直接用金字塔的语言去实现


--  作者:wood3559
--  发布时间:2012/10/12 11:23:51
--  
供参考

input: length(25,10,60,1);
input: stdDevUp(2,0.1,4,0.2);
input: stdDevDn(2,0.1,4,0.2);

variable: stdValue=0;
variable: Lots=1;
VARIABLE: isThisBarTrade=0;

isThisBarTrade:=0;
AveMa:=ma(ref(close,1),length);
stdValue:=std(ref(close,1),length);
UpperBand:=Avema + stdDevUp * stdValue;
LowerBand:=AveMa - stdDevDn * stdValue;

buy_cond:=cross(ref(close,1),ref(UpperBand,1));
buyshort_cond:=cross(ref(lowerBand,1),ref(close,1));
sell_cond:=ref(close,1)<ref(AveMa,1);
sellshort_cond:=ref(close,1)>ref(AveMa,1);
Long_EntryPrice:=open+2*MINDIFF;
Short_EntryPrice:=open-2*MINDIFF;

if holding<>1 and buy_cond and not(isThisBarTrade) then begin
buy(1,lots,limitr,Long_EntryPrice);
isThisBarTrade:=1;
end;
else if holding<>-1 and buyshort_cond and not(isThisBarTrade) then begin
buyshort(1,lots,limitr,Short_EntryPrice);
isThisBarTrade:=1;
end;
else if holding=1 and sell_cond and not(isThisBarTrade) then begin
sell(1,lots,limitr,Short_EntryPrice);
end;
else if holding=-1 and sellshort_cond and not(isThisBarTrade) then begin
sellshort(1,lots,limitr,Long_EntryPrice);
end;

资产:ASSET,NOAXIS;
可用现金:CASH(0),LINETHICK0;
持仓:HOLDING,LINETHICK0;