一個(gè)簡單日內(nèi)30分鐘高低點(diǎn)突破系統(tǒng)bt源碼[開拓者公式]
- //------------------------------------------------------------------------
// 簡稱: a_1fenrn4
// 名稱: a_1fenrn4
// 類別: 公式應(yīng)用
// 類型: 用戶應(yīng)用
// 輸出: www.tumamayizhan.com QQ 511411198
//------------------------------------------------------------------------
Params
// Numeric nYestCloseInput(2210);
Vars
String FileName("d:\\log\\log.txt");
Numeric Offset(3);
Numeric OffsetMargin(0);
Bool bUp(false);
Bool bDown(false);
Numeric lots(1);
Numeric length(10);
NumericSeries MyPrice;
NumericSeries myExitPrice;
Bool SendOrderThisBar(False);
Bool bStart(False);
Numeric i(0);
Numeric nHighPrice(0);//全局變量的1
Numeric nLowPrice(0);//全局變量的0
Numeric nDuoZhiS(0);//全局變量的5
Numeric nKongZhiS(0);//全局變量的6
Numeric nYestClose(0);//全局變量的7
BoolSeries bDuoStoped(false);
BoolSeries bKongStoped(false);
Begin
/*
FileAppend(FileName,"Bartime="+DateTimeToString(Date+Time)
+" currentTime= "+TimeToString(currentTime)
+" MarketPosition="+Text(MarketPosition)
+" CurrentDate="+DateTimeToString(CurrentDate)
);
*/
OffsetMargin=Offset*MinMove*PriceScale;
//1
//If(Time==0.090000) //商品
If(Time==0.091500) //股指
{
//每天初始化開倉條件
bDuoStoped=false;
bKongStoped=false;
}// www.tumamayizhan.com
//2、當(dāng)走完length,即10個(gè)周期k線時(shí)才判斷高低點(diǎn)
//If(Time==0.091000) 商品
If(Time==0.094500)
{
nHighPrice=High[1];
for i=1 To 30
{
If(High[i] > nHighPrice)
nHighPrice = High[i];
}
SetGlobalVar(1,nHighPrice);
nLowPrice=low[1];
for i=1 To 30
{
If(low[i] < nLowPrice)
nLowPrice = low[i];
} // www.tumamayizhan.com
SetGlobalVar(0,nLowPrice);
}
//3、當(dāng)超過length,即30個(gè)周期k線時(shí)才啟動實(shí)際的程序運(yùn)行
If(Time>=0.094500)
{
bStart=True;
nHighPrice=getGlobalVar(1);
nLowPrice=getGlobalVar(0);
FileAppend(FileName,"10日最高價(jià)="+Text( nHighPrice)
+" 10日最低價(jià)="+Text(nLowPrice)
);
Commentary("10日最高價(jià)="+Text(nHighPrice));
Commentary("10日最低價(jià)="+Text(nLowPrice));
}
FileAppend(FileName,"昨天收盤價(jià)="+Text(CloseD(1))
);
//4、開倉操作
If(!bDuoStoped and MarketPosition<>1 and High>nHighPrice and OpenInt>OpenInt[1] and Time>=0.0945 and bStart)//從11:21開始啟動自動交易
{
MyPrice = Max(Open,nHighPrice)+OffsetMargin;
Buy(Lots,MyPrice);
SendOrderThisBar = true;
FileAppend(FileName,"<<<<<<<<買入開倉Buy entry"+TimeToString(Time)
+"多單價(jià)格:"+Text(MyPrice)
+" 目前持倉量:"+Text(OpenInt)
+" 前一個(gè)持倉量:"+Text(OpenInt[1])
);
//設(shè)置止損條件
SetGlobalVar(5,0);
}
If(!bKongStoped and MarketPosition<>-1 and low<nLowPrice and OpenInt>OpenInt[1] and Time>=0.0945 and bStart)
{
MyPrice = Min(Open,nLowPrice)-OffsetMargin;
SellShort(Lots,MyPrice);
SendOrderThisBar = true;
FileAppend(FileName," >>>>>>>賣出開倉Sell entry"+TimeToString(Time)
+"空單單價(jià)格:"+Text(MyPrice)
+" 目前持倉量:"+Text(OpenInt)
+" 前一個(gè)持倉量:"+Text(OpenInt[1])
);
//設(shè)置止損條件
SetGlobalVar(6,0);
}
//5、正常平倉操作
If(MarketPosition == 1) // 有多倉的情況
{
If(High<High[1] and Low<Low[1])//創(chuàng)新低
{
nDuoZhiS=getGlobalVar(5);
SetGlobalVar(5,nDuoZhiS+1); //多單止損
FileAppend(FileName,"<<<<<<<<多倉止損條件判斷"+TimeToString(Time)
+"nDuoZhiS:"+Text(nDuoZhiS)
+" 更新后是getGlobalVar(5):"+Text(getGlobalVar(5))
);
}
//If(Low < nTodayAP)
If(getGlobalVar(5)==3)
{
//myExitPrice = max(Low,Low[1] - OffsetMargin);
myExitPrice = Low;
myExitPrice = IIF(myExitPrice > Open, Open,myExitPrice); // 大跳空的時(shí)候用開盤價(jià)代替
Sell(0,myExitPrice); // 數(shù)量用0的情況下將全部平倉 www.tumamayizhan.com
bDuoStoped=True;
FileAppend(FileName,"<<<<<<<<多倉賣出平倉"+TimeToString(Time)
+"多單價(jià)格:"+Text(myExitPrice)
+" getGlobalVar(5):"+Text(getGlobalVar(5))
);
}
}Else If(MarketPosition ==-1) // 有空倉的情況
{
//低點(diǎn)轉(zhuǎn)折
If(High>High[1] and Low>Low[1])//創(chuàng)新低
{
nKongZhiS=getGlobalVar(6);
SetGlobalVar(6,nKongZhiS+1); //多單止損
FileAppend(FileName,"<<<<<<<<空倉止損條件判斷"+TimeToString(Time)
+"nDuoZhiS:"+Text(nKongZhiS)
+" 更新后是getGlobalVar(6):"+Text(getGlobalVar(6))
);
}
//If(High > nTodayAP)
If(getGlobalVar(6)==3)
{
//myExitPrice = Min(High,nTodayAP + nTodayAP);
myExitPrice = High;
myExitPrice = IIF(myExitPrice < Open, Open,myExitPrice); // 大跳空的時(shí)候用開盤價(jià)代替
BuyToCover(0,myExitPrice); // 數(shù)量用0的情況下將全部平倉
bKongStoped=True;
FileAppend(FileName,"<<<<<<<<空倉買入平倉"+TimeToString(Time)
+" 價(jià)格:"+Text(myExitPrice)
+" getGlobalVar(6):"+Text(getGlobalVar(6))
);
}
}
//6、尾盤多空全部平倉 QQ 511411198
If((Date[-1]!=InvalidInteger and Date!=Date[-1]) Or (Date[-1]==InvalidInteger and Date<CurrentDate))
{
Sell(0,Close-Offset*MinMove*PriceScale);
BuyToCover(0,Close+Offset*MinMove*PriceScale);
FileAppend(FileName,"******************歷史尾盤平倉");
}
//Else If(Date==CurrentDate and Time==0.1455 and CurrentTime>=0.1459)//5分鐘周期 www.tumamayizhan.com QQ 1145508240
Else If(Date==CurrentDate and Time==0.1514 and CurrentTime>=0.151430)//1分鐘周期
{
FileAppend(FileName,"******************今天尾盤平倉");
Sell(0,Close-Offset*MinMove*PriceScale);
BuyToCover(0,Close+Offset*MinMove*PriceScale);
}
End
有思路,想編寫各種指標(biāo)公式,程序化交易模型,選股公式,預(yù)警公式的朋友
可聯(lián)系技術(shù)人員 QQ: 1145508240 進(jìn)行 有償 編寫!(不貴!點(diǎn)擊查看價(jià)格!)
相關(guān)文章
-
沒有相關(guān)內(nèi)容