//------------------------------------------------------------------------
// 簡稱: DayChangeTrenchV1
// 名稱: 日內(nèi)轉(zhuǎn)向加倉交易系統(tǒng)模型TB源碼
// 類別: 公式應(yīng)用
// 類型: 用戶應(yīng)用
//------------------------------------------------------------------------
Params
Bool bInitStatues(false); // 初始化標(biāo)志,修改初始倉位時需設(shè)置為True
Numeric InitMyRealMp(0); // 初始化當(dāng)前倉位,正數(shù)表示多單,負(fù)數(shù)表示空單
Numeric FirstGrid(30); // 第一筆交易的間距,最小跳動;
Numeric AddGrid(5); // 加倉間距,最小跳動
Numeric TotalGrids(10); // 最大交易次數(shù)
Numeric TrailingGrid(30); // 移動止損間距,最小跳動
Numeric EveryLots(1); // 每次開倉手?jǐn)?shù)
Numeric OffSet(1); // 委托價偏差,默認(rèn)買賣價偏差為1個滑點
Numeric ExitOnCloseMins(14.58); //收盤平倉時間
Vars
Numeric HighAfterLongEntry;
Numeric LowAfterShortEntry;
Numeric MyRealMp(0);
Numeric MinPoint;
Numeric tmpPrice;
Numeric tmpLots;
Begin
MinPoint=Minmove*PriceScale;
MyRealMp=GetGlobalVar(0);
HighAfterLongEntry=GetGlobalVar(1);
LowAfterShortEntry=GetGlobalVar(2);
if (BarStatus==0 And (MyRealMp==InvalidNumeric || bInitStatues))
{
MyRealMp=InitMyRealMp;
}
if (Date<>Date[1])
{
HighAfterLongEntry=High;
LowAfterShortEntry=Low;
MyRealMp=0;
}Else
{
HighAfterLongEntry=Max(HighAfterLongEntry,High);
LowAfterShortEntry=Min(Low,LowAfterShortEntry);
} // www.tumamayizhan.com
If (Time<ExitOnCloseMins/100)
{
If ( MyRealMp>0 And HighAfterLongEntry-Low>=TrailingGrid*MinPoint
And(High-Low<TrailingGrid*MinPoint Or(High-Low>=TrailingGrid*MinPoint And close<Open)))
{
tmpPrice=Max(HighAfterLongEntry-(TrailingGrid-OffSet)*MinPoint,Low);
tmpLots=Abs(MyRealMp*EveryLots);
Sell(tmpLots,tmpPrice);
MyRealMp=0;
LowAfterShortEntry=Low;
}Else
If ( MyRealMp<0 And High-LowAfterShortEntry>=TrailingGrid*MinPoint
And(High-Low<TrailingGrid*MinPoint Or(High-Low>=TrailingGrid*MinPoint And close>Open)))
{
tmpPrice=Min(LowAfterShortEntry+(TrailingGrid+OffSet)*MinPoint,High);
tmpLots=Abs(MyRealMp*EveryLots);
BuyToCover(tmpLots,tmpPrice);
MyRealMp=0;
HighAfterLongEntry=0;
}
// 第一筆多單開倉
if (MyRealMp==0 And High-LowAfterShortEntry>=FirstGrid*MinPoint)
{
tmpPrice=Min(LowAfterShortEntry+(FirstGrid+OffSet)*MinPoint,High);
tmpLots=EveryLots;
Buy(tmpLots,tmpPrice);
MyRealMp=1;
HighAfterLongEntry=High;
}Else
// 多單加倉
if (MyRealMp> 0 And MyRealMp <TotalGrids And High-LowAfterShortEntry>=(FirstGrid+MyRealMp*AddGrid)
*MinPoint)
{
tmpPrice=Min(LowAfterShortEntry+(FirstGrid+MyRealMp*AddGrid+OffSet)*MinPoint,High);
tmpLots=EveryLots;
Buy(tmpLots,tmpPrice);
MyRealMp=MyRealMp+1;
}Else
// 第一筆空單開倉
if (MyRealMp==0 And HighAfterLongEntry-Low>=TrailingGrid*MinPoint )
{
tmpPrice=Max(HighAfterLongEntry-(FirstGrid-OffSet)*MinPoint,Low);;
tmpLots=EveryLots;
SellShort(tmpLots,tmpPrice);
MyRealMp=-1;
LowAfterShortEntry=Low ;
}Else
// 空單加倉 www.tumamayizhan.com
if (MyRealMp< 0 And -1*MyRealMp <TotalGrids And HighAfterLongEntry-Low>=(FirstGrid+MyRealMp*AddGrid)
*MinPoint)
{
tmpPrice=Max(HighAfterLongEntry-(FirstGrid-Abs(MyRealMp*AddGrid)-OffSet)*MinPoint,High);
tmpLots=EveryLots;
SellShort(tmpLots,tmpPrice);
MyRealMp=MyRealMp-1;
}
}Else
If (Time>ExitOnCloseMins/100)
{
If (MyRealMp>0)
{
tmpLots=Abs(MyRealMp*EveryLots);
tmpPrice=Close;
Sell(tmpLots,tmpPrice);
MyRealMp=0;
}
If(MyRealMp<0)
{
tmpLots=Abs(MyRealMp*EveryLots);
tmpPrice=Close;
BuyToCover(tmpLots,tmpPrice);
MyRealMp=0;
}
}
SetGlobalVar(0,MyRealMp);
SetGlobalVar(1,HighAfterLongEntry);
SetGlobalVar(2,LowAfterShortEntry);
Commentary("MyRealMp="+Text(MyRealMp));
Commentary("HighAfterLongEntry="+Text(HighAfterLongEntry));
Commentary("LowAfterShortEntry="+Text(LowAfterShortEntry));
//SetExitOnClose;
End
//------------------------------------------------------------------------
// 編譯版本GS2010.12.08
// 用戶版本2012/03/17 16:00
// 版權(quán)所有 www.tumamayizhan.com QQ 1145508240
// 更改聲明TradeBlazer Software保留對TradeBlazer平臺
//每一版本的TrabeBlazer公式修改和重寫的權(quán)利
//------------------------------------------------------------------------