程式碼分析.17

2022/01/04閱讀時間約 2 分鐘
拋物線SAR(Stop and Reverse),好用的出場概念,但是常常被搞錯認為是進場的邏輯,廢話不多說,請參考程式碼的出場部分
Input:ATRLength(10),ATRs(2.5);
Vars:WAvgPrice(0),Resistance(0),Support(0);
Vars:EntryATR(0),MP(0),StopPrice(0);
WAvgPrice=(High+Low+2*Close)*0.25;
Resistance=2*WAvgPrice-Low;
Support=2*WAvgPrice-High;
MP=MarketPosition;
If MP<>1 then Buy next bar at Resistance Stop;
If MP<>-1 then SellShort next bar at Support Stop;
{ Exit with ATR Profit Target }
If BarsSinceEntry=0 then EntryATR=AvgTrueRange(ATRLength)*ATRs;
If MP=1 and High>EntryPrice+EntryATR then Sell next bar at EntryPrice+EntryATR Stop;
If MP=-1 and Low<EntryPrice-EntryATR then BuyToCover next bar at EntryPrice-EntryATR Stop;
{ Exit with Parabolic SAR }
If MP=1 and MP[1]=0 then StopPrice=Low-Average(Range,4);
If MP=-1 and MP[1]=0 then StopPrice=High+Average(Range,4);
If MP=1 then begin
Sell next bar at StopPrice Stop;
StopPrice = StopPrice+(Low-StopPrice)/3;
End;
If MP=-1 then begin
BuyToCover next bar at StopPrice Stop;
StopPrice = StopPrice-(StopPrice-High)/3;
End;







為什麼會看到廣告
Piemann
Piemann
Piemann 只是一位中年大叔 !
留言0
查看全部
發表第一個留言支持創作者!