程式碼分析.11

2022/01/01閱讀時間約 3 分鐘
在ADX、DMI,這指標同時處理波動度與方向力道大小程度,不愧是指標中的第一名首選濾網 !
以下先介紹計算流程與公式
步驟1,前後兩根K棒的多空力道大小,分為上述六種狀態
步驟2,評估多空力道移動總距離的方法
步驟3,分子採用離差概念,分母取總距離,在取其平均值
{DMI-ADX}
Input:DMILen(7),ADXLen(7),ADXExit(30),Trade(10000),Lot(100);
Vars:BuySetup(false),SellSetup(false),BuyPrice(0),SellPrice(0),DPlus(0),DMin(0),ADXVal(0),ExitSPrc(0),ExitLPrc(0);
DPlus = DMIPlus(DMILen);
DMin = DMIMinus(DMILen);
ADXVal = ADX(ADXLen);
If DPlus>DMin AND ADXVal Crosses Over DMin and MarketPosition <> 1 then begin
BuyPrice = High;
BuySetup = true;
ExitLPrc = Low;
End;
If ADXVal<DMin or MarketPosition = 1 then BuySetup = False;
If DPlus < DMin AND ADXVal Crosses Over DPlus and MarketPosition <> -1 then begin
SellPrice = Low;
SellSetup = true;
ExitSPrc = High;
End;
If ADXVal < DPlus or MarketPosition = -1 then SellSetup = False;
If BuySetup then Buy 1 Contracts next bar at BuyPrice stop;
If SellSetup then SellShort 1 Contracts next bar at SellPrice stop;
If MarketPosition = 1 then Begin
BuySetup = false;
sell next bar at ExitLPrc Stop;
End;
If MarketPosition = -1 then begin
SellSetup = True;
Buytocover next bar at ExitSPrc stop;
End;
{ADX Exit Strategy}
If (ADXVal[1]>=ADXExit and ADXVal<ADXVal[1]) then Begin
If MarketPosition=1 and BarssinceEntry>1 then sell this bar at close;
If MarketPosition=-1 and BarsSinceEntry>1 then buytocover this bar at close;
End;
If DPlus<DMin and BarsSinceEntry>1 then sell next bar at Lowest(Low,3) stop;
If DPlus>Dmin and BarsSinceEntry>1 then buytocover next bar at Highest(High,3) stop;
為什麼會看到廣告
Piemann
Piemann
Piemann 只是一位中年大叔 !
留言0
查看全部
發表第一個留言支持創作者!