開(kāi)拓者飛天創(chuàng)富系統(tǒng)策略源碼[開(kāi)拓者公式]
(一)思路:1.同時(shí)交易四個(gè)品種,每個(gè)品種動(dòng)用總資金的10%。
2.以連續(xù)合約發(fā)出信號(hào),交易主力合約,連續(xù)合約為data0,現(xiàn)主力合約為data1,下一個(gè)主力合約為data2;
3.總資金以A_CurrentEquity 表達(dá)是否正確;
4.盤中達(dá)到止損,立即以止損價(jià)止損;
5.開(kāi)盤跳空越過(guò)止損價(jià),立即以開(kāi)盤價(jià)止損,但不能因集合競(jìng)價(jià)出現(xiàn)廢單;
(二)程序代碼:
//------------------------------------------------------------------------
// 簡(jiǎn)稱: FTCF
// 名稱: 飛天創(chuàng)富
// 類別: 公式應(yīng)用
// 類型: 用戶應(yīng)用
//------------------------------------------------------------------------
Params
Numeric m(7);
numeric P(1.5);
numeric n(0.1);
Vars
NumericSeries a;
NumericSeries b;
NumericSeries e;
numeric entrylots;
NumericSeries dtzf;
NumericSeries ktdf;
Begin
a=(3*c+l+o+h)/6;
b=(20*a+19*a[1]+18*a[2]+17*a[3]+16*a[4]+15*a[5]+14*a[6]+13*a[7]+12*a[8]+11*a[9]+10*a[10]+9*a[11]+8*a[12]+7*a[13]+6*a[14]+5*a[15]+4*a[16]+3*a[17]+2*a[18]+a[20])/210;//來(lái)源 www.kzuj.com.cn
e=average(b,m);
dtzf=c/Close[NthCon(CrossOver(b,e),1)]-1;
ktdf=1-c/Close[NthCon(CrossOver(e,b),1)];
//多頭開(kāi)倉(cāng)
if(crossover(b,e) and MarketPosition!=1 and ktdf<n and data1.v>data2.v and CurrentTime>=0.145955)
{
entryLots= (A_CurrentEquity *0.1)/(data1.C*ContractUnit*MarginRatio);
entryLots = IntPart(entryLots );
data1.Buy(entryLots,data1.C);
}
if(crossover(b,e) and MarketPosition!=1 AND ktdf>=n and data1.v>data2.v and CurrentTime>=0.145955)
{
entryLots= (A_CurrentEquity*0.05)/(data1.C*ContractUnit*MarginRatio);
entryLots = IntPart(entryLots );
data1.Buy(entryLots,data1.C);
}
if(crossover(b,e) and MarketPosition!=1 and ktdf<n and data1.v<data2.v and CurrentTime>=0.145955)
{
entryLots= (A_CurrentEquity *0.1)/(data2.C*ContractUnit*MarginRatio);
entryLots = IntPart(entryLots );
data1.BuyToCover(0,data1.c);
data2.Buy(entryLots,data2.C);
}
if(crossover(b,e) and MarketPosition!=1 AND ktdf>=n and data1.v<data2.v and CurrentTime>=0.145955)
{
entryLots= (A_CurrentEquity *0.05)/(data2.C*ContractUnit*MarginRatio);
entryLots = IntPart(entryLots );
data1.BuyToCover(0,data1.c);
data2.Buy(entryLots,data2.C);
}
//多頭開(kāi)倉(cāng)結(jié)束
//空頭開(kāi)倉(cāng)
if(Crossover(e,b) and MarketPosition!=(-1) and dtzf<n and data1.v>data2.v and CurrentTime>=0.145955)
{
entryLots= (A_CurrentEquity * 0.1)/(data1.C*ContractUnit*MarginRatio);
entryLots = IntPart(entryLots );
data1.SellShort(entryLots,data1.c);
}//來(lái)源 www.chengxuhuajiaoyi.com
if(Crossover(e,b) and MarketPosition!=(-1) and dtzf>=n and data1.v>data2.v and CurrentTime>=0.145955)
{
entryLots= (A_CurrentEquity* 0.05)/(data1.C*ContractUnit*MarginRatio);
entryLots = IntPart(entryLots );
data1.Sellshort(entryLots,data1.c);
}
if(Crossover(e,b) and MarketPosition!=(-1) and dtzf<n and data1.v<data2.v and CurrentTime>=0.145955)
{
entryLots= (A_CurrentEquity * 0.1)/(data2.C*ContractUnit*MarginRatio);
entryLots = IntPart(entryLots );
data1.Sell(0,data1.c);
data2.SellShort(entryLots,data2.c);
}
if(Crossover(e,b) and MarketPosition!=(-1) and dtzf>=n and data1.v<data2.v and CurrentTime>=0.145955)
{
entryLots= (A_CurrentEquity * 0.05)/(data2.C*ContractUnit*MarginRatio);
entryLots = IntPart(entryLots );
data1.Sell(0,data1.c);
data2.Sellshort(entryLots,data2.c);
}
//空頭開(kāi)倉(cāng)結(jié)束
//多頭止損
If(marketposition==1 and data1.l<=A_BuyAvgPrice*(1-p/100) and date>lastEntryDate AND currenttime>0.090000)
{
data1.Sell(0,A_BuyAvgPrice*(1-p/100));
}
If(marketposition==1 and data1.o<=A_BuyAvgPrice*(1-p/100) and date>lastEntryDate AND currenttime>0.090000)
{
data1.Sell(0,o);
}
//多頭止損結(jié)束
//空頭止損
If(marketposition==(-1) and data1.h>=A_sellAvgPrice*(1+p/100) and date>lastEntryDate AND currenttime>0.090000)
{
data1.BuyToCover(0,A_sellAvgPrice*(1+p/100));
}
If(marketposition==(-1) and data1.o>=A_sellAvgPrice*(1+p/100) and date>lastEntryDate AND currenttime>0.090000)
{
data1.BuyToCover(0,o);
}
//空頭止損結(jié)束
End
//------------------------------------------------------------------------
// 編譯版本 GS2010.12.08
// 用戶版本 2013/01/29 13:58
// 版權(quán)所有
// 更改聲明 TradeBlazer Software保留對(duì)TradeBlazer平臺(tái)
// 每一版本的TrabeBlazer公式修改和重寫的權(quán)利
//------------------------------------------------------------------------
有思路,想編寫各種指標(biāo)公式,程序化交易模型,選股公式,預(yù)警公式的朋友
可聯(lián)系技術(shù)人員 QQ: 262069696 進(jìn)行 有償 編寫!(不貴!點(diǎn)擊查看價(jià)格!)
相關(guān)文章
-
沒(méi)有相關(guān)內(nèi)容