開拓者真實波動率軌道突破策略 適用15M,30M 指數合約 等

量化交易者發表於2024-06-01

//適用軟體:交易開拓者
//公式名稱:波動率軌道突破策略
//資料週期:15M,30M等
//資料合約:指數合約
//交易合約:主力合約
//適合品種:商品期貨

Params
Numeric Length1(300);
Numeric Length2(100);
Numeric N(2);
Numeric Fund(20000);

Vars
NumericSeries Midline(0);
NumericSeries upBand(0);
NumericSeries downBand(0);
NumericSeries Lots(0);
NumericSeries Myprice(0);

Begin
If(!CallAuctionFilter()) Return;

Midline= Average((High + Low + Close)/3,Length1);
upBand = Midline+ N*AvgTrueRange(Length2);
downBand = Midline - N*AvgTrueRange(Length2);

//PlotNumeric("Midline",Midline,0,Blue);
//PlotNumeric("upBand",upBand,0,Yellow);
//PlotNumeric("downBand",downBand,0,White);

Lots=max(1,intpart(Fund/(O*ContractUnit*BigPointValue*0.1)));
If(MarketPosition <> 1 and close[1]>= upBand[1] and close[2]<upband[2])
{
Myprice=open;
Buy(lots,Myprice);
}

If(MarketPosition <> -1 and close[1] <= downBand[1] and close[2]>downband[2])
{
Myprice=open;
SellShort(lots,Myprice);
}

If(MarketPosition == 1 and BarsSinceEntry >= 1 and C[1]<= Midline[1] )
{
Myprice=open;
Sell(0,Myprice);

}

If(MarketPosition == -1 and BarsSinceEntry >= 1 and C[1] >= Midline[1])
{
Myprice=open;
BuyToCover(0,Myprice);
}
End

相關文章