以文本方式查看主题

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

--  作者:jinzitahu
--  发布时间:2012/4/18 13:19:56
--  tb程序改写为金字塔程序,求帮忙啊

Params
Numeric Mult(4);
Numeric Length(30);
Numeric ExitOnCloseMins(15.10);
Numeric StopPercent(0.5);

Vars
Numeric DayOpen;
Numeric UpperBand;
Numeric LowerBand;
Numeric MyPrice;
Numeric myExitPrice;
NumericSeries EntryLots;
NumericSeries ATRValue;


Begin
ATRValue=AvgTrueRange(Length);

DayOpen=OpenD(0);
UpperBand=DayOpen+ATRValue[1]*Mult;
LowerBand=DayOpen-ATRValue[1]*Mult;
EntryLots=IntPart(Portfolio_CurrentCapital*0.3/(Close*ContractUnit*BigPointValue*MarginRatio));

If(MarketPosition!=1 && High>=UpperBand && Time<ExitOnCloseMins/100)
{
MyPrice=UpperBand;
If(Open>MyPrice) Myprice=Open;
Buy(1,MyPrice);
Return;
}

If(MarketPosition!=-1 && Low<=LowerBand && Time<ExitOnCloseMins/100)
{MyPrice=LowerBand;
If(Open<MyPrice) Myprice=Open;
SellShort(1,MyPrice);
Return;
}


If(MarketPosition==1)
{
  If(Low<AvgEntryPrice*(1-StopPercent/100))
    {    
     myExitPrice=AvgEntryPrice*(1-StopPercent/100);
     myExitPrice=Min(Open,myExitPrice);
     Sell(0,myExitPrice);
    }
}

If(MarketPosition==-1)
{
  If(High>AvgEntryPrice*(1+StopPercent/100))
    {
     myExitPrice=AvgEntryPrice*(1+StopPercent/100);
     myExitPrice=Max(Open,myExitPrice);
     BuyToCover(0,myExitPrice);
    }
}

If(Time>=ExitonCloseMins/100)
{
   Sell(0,Open);
   BuyToCover(0,Open);
}

End


--  作者:just
--  发布时间:2012/4/18 13:36:49
--  
把你的交易思路说一下吧,看看我们能不能帮你实现。