Descrição
Angora Trading System — BB + RSI Range Grid cBot
--------------------------------------------------
OVERVIEW
Anatolia Trading System is a mean-reversion cBot. It looks for price stretched to the edge of the Bollinger Bands while RSI confirms an overbought or oversold condition, and it trades the move back toward the middle band. The ADX indicator decides whether the market is ranging or trending, so the bot only trades when conditions suit this approach. An optional ATR-based grid can add positions to the basket when price moves against the first entry. Every leg shares one basket stop loss, which is sent to the broker with each order.
The bot was designed and tested on BTCUSD,US30, XAUUSD, EURUSD, GBPUSD and USDJPY M15. It works on any symbol and timeframe, but you should backtest and adjust the parameters for each instrument.
INDICATORS USED
- Bollinger Bands: entry zones (upper and lower band) and the exit target (middle band or opposite band).
- RSI (Relative Strength Index): confirms overbought and oversold conditions for entries and grid additions.
- ADX with +DI / -DI (Directional Movement System): identifies the market regime (range or trend) and trend direction, and triggers the trend-break exit.
- ATR (Average True Range): scales everything to current volatility, including grid spacing, basket stop distance, band width filter, target distance filter and spread filter.
All signals use closed bars only, so they do not repaint.
HOW IT TRADES
1) Market regime (ADX)
- ADX below "ADX Max Entry" (default 25) = RANGE. The bot trades band reversals in both directions.
- ADX between "ADX Max Entry" and "Trend ADX Max" (default 25-45) = TREND, if Trend Aligned Mode is on. The bot trades pullbacks in the trend direction only: it buys the lower band in an uptrend (+DI > -DI) and sells the upper band in a downtrend (-DI > +DI).
- ADX above "Trend ADX Max" = no new entries (extreme or parabolic move).
- In RANGE mode, entries are skipped while ADX is rising quickly, because a new trend may be starting.
2) Entry signal
- ReEntry mode (default): the previous bar touched or closed outside a band, and the last bar closed back inside it. RSI must be oversold (buy) or overbought (sell) on one of the last two bars.
- Touch mode: a bar touching the band plus the RSI condition is enough.
- Filters: minimum Bollinger Band width (avoids squeezes and pre-breakout conditions), minimum distance to the target (the move must be large enough to cover costs), spread, session and the account guards.
3) Grid (optional)
- When price moves against the basket by "Grid Step" x ATR, the bot adds a new leg in the same direction, up to "Max Grid Levels" legs in total. Closed legs also count toward this limit.
- A grid addition requires RSI to still be near the extreme zone and ADX to stay below the grid limit. In trend mode, DI must still point in the basket direction.
- All legs share one basket stop loss placed beyond the last possible grid level. It is sent with every order, so no position is ever open without a stop loss.
- No grid additions are made once profit protection is active.
4) Exits
- Target: price reaches the middle band (or the opposite band) and the basket profit is at least "Min Basket Profit at Target".
- Profit protection: break-even lock and a trailing profit floor (see below).
- Basket max loss (in R), plus the basket stop loss on the broker side.
- Soft time exit (close at break-even or better after N bars) and hard time exit (close after N bars).
- Trend-break exit: closes a losing basket when ADX rises above the threshold and DI turns against the basket.
WHAT IS "R"?
The bot measures risk and profit in R:
- 1R (basket) = the total amount lost if all grid levels are filled and the basket stop loss is hit.
- Rp (protection) = the risk of the first leg down to the basket stop loss. Profit protection thresholds use Rp by default, so they stay sensible when the grid is enabled. With the grid off, R and Rp are the same.
PARAMETERS
[Trading]
- Use Fixed Volume: ON = every leg uses "Fixed Volume per Leg". OFF = position size is calculated from "Basket Risk %".
- Fixed Volume per Leg (lots): lot size of each leg when fixed volume is on. Default 0.01.
- Basket Risk %: percent of equity lost if every grid level fills and the basket stop is hit (1R). Used when fixed volume is off. Default 2.
- Max Volume per Leg (lots): hard cap on the size of any single leg. Default 1.0.
- Loss Cooldown (bars): number of bars to wait after a losing basket. Default 4.
- Max Slippage (pips): above 0, orders are sent as market range orders with this slippage limit. 0 = normal market order.
- Label / Auto Label Suffix: position label. With the suffix on, the label becomes Label_Symbol_Timeframe, so several instances can run without interfering.
[Bollinger & RSI]
- BB Period / BB Std Dev / BB MA Type: Bollinger Band settings. Defaults 20 / 2.0 / Simple.
- RSI Period: default 14.
- RSI Oversold (BUY) / RSI Overbought (SELL): RSI thresholds in RANGE mode. Defaults 30 / 70.
[Entry]
- Entry Mode: ReEntry (default) or Touch.
- Min Band Width (xATR): the bands must be at least this many ATRs apart. Default 2.0.
- Min Target Distance (xATR): the distance from entry to the target must be at least this many ATRs. Default 0.8.
- Allow Buy / Allow Sell: enable or disable each direction.
[Trend Mode]
- Use Trend Aligned Mode: allows trend-direction pullback entries when ADX is above the range threshold. Default ON.
- Trend ADX Max: no new entries above this ADX value. Default 45.
- Trend Min DI Spread: minimum difference between +DI and -DI needed to confirm the trend direction. Default 5.
- Trend RSI Oversold / Overbought: looser RSI thresholds for pullbacks. Defaults 40 / 60.
- Trend Grid Step Mult: multiplies the grid step for trend baskets. Default 1.5.
- Trend Max Grid Levels: maximum legs for a trend basket. Default 3.
[ADX & ATR]
- ADX Period: default 14.
- ADX Max Entry: the RANGE / TREND threshold. Default 25.
- ADX Slope Lookback / ADX Max Rising Slope: skips RANGE entries if ADX rose more than this amount over the lookback. Defaults 3 bars / 3.0 (0 = off).
- ATR Period: default 14.
[Grid]
- Use Grid: enable or disable grid additions. Default ON.
- Grid Step (xATR): adverse distance between grid legs. Default 1.0.
- Max Grid Levels: maximum legs per basket, including the first entry. Default 4.
- Grid Volume Mult: lot multiplier per level. 1.0 = equal lots (recommended). Values above 1.3 trigger a martingale warning.
- Stop Buffer (xATR): distance of the basket stop beyond the last grid level. Default 1.5.
- Grid Add Requires RSI / Grid Add RSI Buffer: a grid leg is only added while RSI is within the threshold plus this buffer. Defaults ON / 10.
- Grid Max ADX: no grid additions above this ADX value (range baskets). Default 30.
- Grid Min Add Interval (sec): minimum time between grid attempts. Default 60.
[Exit]
- Exit Target: MiddleBand (default) or OppositeBand.
- Min Basket Profit at Target (R): the target exit only fires if the basket profit is at least this much. Default 0.05.
- Basket Max Loss (R): closes the basket at this loss. Default 1.0 (0 = off).
- Soft Time Exit (bars): after this many bars, closes as soon as the basket is at break-even or better. Default 32.
- Hard Time Exit (bars): always closes after this many bars. Default 96.
- Use Trend Break Exit / Trend Break ADX: closes a losing basket when ADX reaches this level and DI is against the position. Defaults ON / 35.
[Profit Protection]
- Use Profit Protection: default ON.
- Protection R Base: FirstLeg (default, recommended with the grid) or FullBasket.
- BE Trigger / BE Lock (R): once peak profit reaches the trigger, a minimum profit equal to the lock is secured. Defaults 0.75 / 0.1.
- Trail Start / Trail Keep Fraction: once peak profit reaches Trail Start, the bot keeps this fraction of the peak. The floor only moves up. Defaults 2.0 / 0.5.
- Move Broker SL To Floor: converts the protected profit into a price and moves every leg's stop loss there, so the profit is protected on the broker side as well. Default ON.
- Use Partial TP / Partial TP (R) / Partial Close Fraction: closes part of the basket at a given profit. Default OFF.
- Fixed TP (R): closes the whole basket at a fixed profit, regardless of the bands. 0 = off.
[Market Filters]
- Max Spread (pips) / Max Spread (xATR): skips entries and grid additions when the spread is too wide. Defaults off / 0.2 x ATR.
- Use Session Filter / Session Start / End Hour (UTC): trade only within the given hours. Default OFF.
- Block Weekend Entries / Friday Cutoff Hour: optional weekend protection.
[Account Guard]
- Max Daily Loss (% equity) / Close Positions On Daily Limit: stops new entries for the rest of the day and can close open positions. Defaults 5% / ON.
- Max Drawdown (% peak equity) / Stop Bot On Max Drawdown: closes everything and can stop the bot. Defaults 20% / ON.
- Max Trades Per Day: 0 = unlimited.
- Max Total Risk (% equity): cap on total open risk down to the stop loss. Default 3%. Always applied when sizing by risk percent.
- Apply Risk Cap In Fixed Mode: also applies the cap above when fixed volume is on. Default OFF.
[Log]
- Log Level: Quiet, Normal or Verbose.
- Print CSV Trade Lines: prints one CSV line per completed basket, for easy analysis.
RESTART SAFETY AND REPORTING
- After a restart or reconnection, the bot rebuilds the open basket (direction, legs, stop, realized profit) from position comments and trade history.
- When the bot stops, it prints a statistics summary: trades, win rate, profit factor, average win and loss, maximum drawdown and losing streak, plus results grouped by exit reason (for example RANGE/target, TREND/profit-lock).
GETTING STARTED
1. Start in a backtest on your symbol and timeframe with the default parameters, using tick data and a period of at least 3-6 months.
2. Check the "STATS BY REASON" lines in the log to see which exits make or lose money.
3. Keep the grid conservative: equal lots (Grid Volume Mult = 1.0) and 3-4 levels.
4. Keep risk per basket (or fixed lot) at a level where the daily loss guard is not reached by normal trades.
5. Forward-test on a demo account before trading live.
RISK DISCLAIMER
Trading leveraged products such as CFDs and cryptocurrencies carries a high level of risk and may not be suitable for all investors. Grid and averaging strategies can increase losses during strong trends. Past performance, including backtest results, does not guarantee future results. Use this cBot at your own risk and only with capital you can afford to lose.
