(程式碼) Volatility Expansion


[LegacyColorValue = TRUE];

{ *****************************************************************************************
   
System : Volatility Expansion

*******************************************************************************************}


Input: LMult(1.2), SMult(1.8), ProfitPt(0), TrailBar(4);
Vars: BuyLevel(0), SellShortLevel(0);

{ Entry Orders }
Buy next bar at Open + Average(Range,4) * LMult Stop;
SellShort next bar at Open - Average(Range,4) * SMult Stop;

{ Exit at first Profitable Open }
If MarketPosition = 1 and Open next bar > EntryPrice + ProfitPt + Commission * CurrentContracts / BigPointValue then
Sell ("Long Profit")next bar at Open;
If MarketPosition = -1 and Open next bar < EntryPrice - ProfitPt - Commission * CurrentContracts / BigPointValue then
BuytoCover ("Short Profit") next bar at Open;

{ Trailing Stops }
If MarketPosition = 1 then
Sell next bar at Lowest( Low , TrailBar ) Stop;
If MarketPosition =-1 then
BuytoCover next bar at Highest( High , TrailBar ) Stop;

{ Stale Position Exit }
If BarsSinceEntry > 4 AND PositionProfit < 500 then Begin
Sell ("Long Too Long") next bar at Market;
BuytoCover ("Short Too Longt") next bar at Market;
End;