2022-01-05|閱讀時間 ‧ 約 3 分鐘

程式碼分析.18

波動度壓縮後,等待突破訊號,是提高勝算的好構想, 以下是內困型態發生後的突破策略程式碼
{Inside Day Breakout Failure} Input:RngAvg(3); Vars:DayRangeAvg(0),LongEntryPrice(1),ShortEntryPrice(-1); Vars:InsideDay(False),PlacedOrder(False);
InsideDay = High of Data2High[1] of Data2 and Low of Data2Low[1] of Data2; DayRangeAvg = Average(TrueRange of Data2,RngAvg) of Data2;
If Date[0]Date[1] then begin PlacedOrder = False; LongEntryPrice = -1; ShortEntryPrice = -1; End;
If InsideDay then begin If PlacedOrder = False and Low Low of Data2 then begin LongEntryPrice = High of Data2; PlacedOrder = True; End;
If PlacedOrder = False and High High of Data2 then begin ShortEntryPrice = Low of Data2; PlacedOrder = True; End;
If PlacedOrder and LongEntryPrice-1 then Buy next bar at LongEntryPrice stop; If PlacedOrder and ShortEntryPrice-1 then SellShort next bar at ShortEntryPrice stop;
Sell next bar at Low of Data2 - DayRangeAvg*0.5 stop; BuyToCover next bar at High of Data2 + DayRangeAvg*0.5 stop;
分享至
成為作者繼續創作的動力吧!
© 2024 vocus All rights reserved.