2022年2022年量化经典DualThrust交易系统源代码及改进模型源代码 .pdf
dual thrust系统原形Inputs:K1(.5),K2(.5),Mday(1),Nday(1);Vars:BuyRange(0),SellRange(0);Vars:BuyTrig(0),SellTrig(0);Vars:HH(0),LL(0),HC(0),LC(0);If CurrentBar 1 Then Begin HH=Highest(High,Mday);HC=Highest(Close,Mday);LL=Lowest(Low,Mday);LC=Lowest(Close,Mday);If(HH-LC)=(HC-LL)Then Begin SellRange=HH-LC;End Else Begin SellRange=HC-LL;End;HH=Highest(High,Nday);HC=Highest(Close,Nday);LL=Lowest(Low,Nday);名师资料总结-精品资料欢迎下载-名师精心整理-第 1 页,共 6 页 -LC=Lowest(Close,Nday);If(HH-LC)=(HC-LL)Then Begin BuyRange=HH-LC;End Else Begin BuyRange=HC-LL;End;BuyTrig=K1*BuyRange;SellTrig=K2*SellRange;If MarketPosition=0 Then Begin Buy at Open of next bar+BuyTrig Stop;Sell at Open of next bar-SellTrig Stop;End;If MarketPosition=-1 Then Begin Buy at Open of next bar+Buytrig Stop;End;If MarketPosition=1 Then Begin Sell at Open of next bar-SellTrig Stop;名师资料总结-精品资料欢迎下载-名师精心整理-第 2 页,共 6 页 -End;Params Numeric K1(0.5);Numeric K2(0.5);Numeric Mday(1);Numeric Nday(1);Numeric lots(1);Numeric offset(0);Vars Numeric BuyRange(0);Numeric SellRange(0);Numeric BuyTrig(0);Numeric SellTrig(0);Numeric HH;Numeric LL;Numeric HC;Numeric LC;Numeric i_offset;Numeric BuyPosition;Numeric SellPosition;名师资料总结-精品资料欢迎下载-名师精心整理-第 3 页,共 6 页 -Begin If(CurrentBar 44*Max(Mday,Nday)/使用的是 5 分钟周期,其它的周期自己做相应修改 i_offset=offset*MinMove*PriceScale;HH=Highest(HighD(1),Mday);HC=Highest(CloseD(1),Mday);LL=Lowest(LowD(1),Mday);LC=Lowest(CloseD(1),Mday);If(HH-LC)=(HC-LL)SellRange=HH-LC;Else SellRange=HC-LL;HH=Highest(HighD(1),Nday);HC=Highest(CloseD(1),Nday);名师资料总结-精品资料欢迎下载-名师精心整理-第 4 页,共 6 页 -LL=Lowest(LowD(1),Nday);LC=Lowest(CloseD(1),Nday);If(HH-LC)=(HC-LL)BuyRange=HH-LC;Else BuyRange=HC-LL;BuyTrig=K1*BuyRange;SellTrig=K2*SellRange;BuyPosition=OpenD(0)+BuyTrig;SellPosition=OpenD(0)-SellTrig;PlotNumeric(BuyPosition,BuyPosition);PlotNumeric(SellPosition,SellPosition);If(MarketPosition=1)名师资料总结-精品资料欢迎下载-名师精心整理-第 5 页,共 6 页 -If(Low=SellPosition)SellShort(lots,Min(Open,SellPosition)-i_offset);Return;End 名师资料总结-精品资料欢迎下载-名师精心整理-第 6 页,共 6 页 -