The concept behind this Expert Advisor is that in a sideways market, a grid methodology works best.
By placing BUY-LIMIT and SELL-LIMIT orders at specific intervals, the likelihood of BUY and SELL (LIMIT) being opened alternately is very high.
By employing a trailing-stop instead of a take-profit, the Expert Advisor protects its profit, as well as if the market turns into trending mode it maximizes its profit potential.
The AntiFragile Expert Advisor trading rules are as follows:
Rule No 1 When the Expert Advisor is started, if TradeLong is set to TRUE, and if there are no pending orders (open positions may exist), then the Expert Advisor places Number Of Trades number of BUY-LIMIT orders at equal intervals of SpaceBetweenTrades points below the current Bid price.
Rule Number2. Similarly if Trade Shortis to TRUE, it places an equal number of SELL-LIMIT orders at equal intervals of Space Between Trades points above the current Ask price.
RuleNumber3. The stop-loss of each of these orders is set to StopLoss points.
Rule Number4. There is no take-profit since profitable orders are tracked using trailing-stop as specified by the TrailingStop points.
Rule Number5. During the course of the execution of the Expert Advisor, if there are no BUY-LIMIT pending orders, but if SELL-LIMIT pending orders exist, then these SELL-LIMIT pending orders will be deleted.
Similarly, if there are no SELL-LIMIT pending orders, but if BUY-LIMIT pending orders exist, then these BUY-LIMIT pending orders will be deleted.
Rule Number6. Once all pending orders are triggered (or deleted), the Expert Advisor starts to place new orders as specified in Rule step 1 onwards.
Rule Number7. An open position is closed by the Expert Advisor when its initial stop-loss is hit, or its trailing stop-loss is hit.