日內(nèi)轉(zhuǎn)向加倉交易系統(tǒng)模型TB源碼[開拓者公式]
//------------------------------------------------------------------------
// 簡(jiǎn)稱: DayChangeTrenchV1
// 名稱: 日內(nèi)轉(zhuǎn)向加倉交易系統(tǒng)模型TB源碼
// 類別: 公式應(yīng)用
// 類型: 用戶應(yīng)用
//------------------------------------------------------------------------
Params
Bool bInitStatues(false); // 初始化標(biāo)志,修改初始倉位時(shí)需設(shè)置為True
Numeric InitMyRealMp(0); // 初始化當(dāng)前倉位,正數(shù)表示多單,負(fù)數(shù)表示空單
Numeric FirstGrid(30); // 第一筆交易的間距,最小跳動(dòng);
Numeric AddGrid(5); // 加倉間距,最小跳動(dòng)
Numeric TotalGrids(10); // 最大交易次數(shù)
Numeric TrailingGrid(30); // 移動(dòng)止損間距,最小跳動(dòng)
Numeric EveryLots(1); // 每次開倉手?jǐn)?shù)
Numeric OffSet(1); // 委托價(jià)偏差,默認(rèn)買賣價(jià)偏差為1個(gè)滑點(diǎn)
Numeric ExitOnCloseMins(14.58); //收盤平倉時(shí)間
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保留對(duì)TradeBlazer平臺(tái)
//每一版本的TrabeBlazer公式修改和重寫的權(quán)利
//------------------------------------------------------------------------
有思路,想編寫各種指標(biāo)公式,程序化交易模型,選股公式,預(yù)警公式的朋友
可聯(lián)系技術(shù)人員 QQ: 1145508240 進(jìn)行 有償 編寫!(不貴!點(diǎn)擊查看價(jià)格!)
相關(guān)文章
-
沒有相關(guān)內(nèi)容