Whale RSI and SMA
- Experts
- Mustafa Ozkurkcu
- 버전: 1.0
This Expert Advisor is a reversal-style system that combines a 50-centered RSI extreme filter with a 200 SMA proximity rule. It evaluates signals only on a new bar of the selected timeframe and uses closed-bar data (shift=1) to reduce noise and avoid “in-bar” flicker.
How the Strategy Works
On every new candle (for InpTF ), the EA follows this logic:
-
Compute RSI thresholds around 50
A single parameter creates both buy/sell levels:-
BuyLevel = 50 − InpRSIThresholdDist
-
SellLevel = 50 + InpRSIThresholdDist
Example: Dist = 20 → BuyLevel = 30, SellLevel = 70
-
-
Require price to be near the 200 SMA
The distance between the last closed candle’s close and the SMA must be within a maximum range:-
Distance (points) = abs(close1 − sma1) / _Point
-
Must be ≤ InpMaxDistPoints
If the distance is also ≤ InpAggroDistPoints, the trade is considered Aggressive and uses a tighter SL buffer.
-
-
Optional confirmation filters
-
EMA Trend Filter (optional)
If enabled:-
Longs require close1 > ema1
-
Shorts require close1 < ema1
-
-
Volume Filter (optional)
If enabled, the last closed bar’s tick volume must be at least:-
avg_tick_volume(lookback) * InpVolMultiplier
-
-
-
One-position rule (per symbol + magic)
If there is already an open position on the same symbol with the same InpMagic , the EA will not open a new one. -
Stop/Target calculation + broker rule normalization
-
SL is set using last closed bar’s high/low plus a buffer.
-
TP is either Risk/Reward based or Bollinger Middle based (with fallback).
-
SL/TP are then adjusted to comply with StopsLevel / FreezeLevel / Spread plus InpExtraStopBufferPts .
-
Entry Rules
BUY (Long) Conditions
A Buy is triggered when all are true:
-
RSI(shift=1) < BuyLevel
-
abs(close1 − sma1) in points ≤ InpMaxDistPoints
-
If EMA filter is enabled: close1 > ema1
Stop-Loss (SL)
-
SL = low1 − SL_Buffer(points)
Take-Profit (TP)
-
If InpUseRRTP = true :
-
risk = entry − SL
-
TP = entry + risk * InpRR
-
-
Else (BB middle mode):
-
TP = BB_Middle
-
If BB_Middle is not valid (≤ entry), it falls back to RR TP.
-
SELL (Short) Conditions
A Sell is triggered when all are true:
-
RSI(shift=1) > SellLevel
-
close1 < sma1 (explicit in the code)
-
(sma1 − close1) in points ≤ InpMaxDistPoints
-
If EMA filter is enabled: close1 < ema1
Stop-Loss (SL)
-
SL = high1 + SL_Buffer(points)
Take-Profit (TP)
-
If InpUseRRTP = true :
-
risk = SL − entry
-
TP = entry − risk * InpRR
-
-
Else (BB middle mode):
-
TP = BB_Middle
-
If BB_Middle is not valid (≥ entry), it falls back to RR TP.
-
Input Parameters (All Variables Explained)
Timeframe / Core Indicators
-
InpTF: Signal timeframe used for all calculations (default: M5).
-
InpRSIPeriod: RSI period (default: 14).
-
InpSMAPeriod: SMA period (default: 200).
RSI Threshold Logic (Centered at 50)
-
InpRSIThresholdDist: Distance from 50 to define extremes.
-
BuyLevel = 50 − dist
-
SellLevel = 50 + dist
Notes: The EA clamps the value into [0, 50] .
-
SMA Distance + Aggressive vs Cautious SL Buffer
-
InpMaxDistPoints: Maximum allowed distance from SMA (points).
-
InpAggroDistPoints: If distance is within this tighter band, trade is Aggressive.
-
InpSLBufferAggroPts: SL buffer (points) used in Aggressive mode.
-
InpSLBufferCautPts: SL buffer (points) used in Cautious mode.
Optional EMA Trend Filter
-
InpUseEMAFilter: Enable/disable EMA trend filter.
-
InpEMAPeriod: EMA period (default: 50).
Optional Volume Filter (Tick Volume)
-
InpUseVolumeFilter: Enable/disable tick volume confirmation.
-
InpVolLookback: Bars used to compute average tick volume (closed bars).
-
InpVolMultiplier: Required multiplier vs average (e.g., 1.2 = 20% above average).
Take-Profit Mode
-
InpUseRRTP:
-
true → Risk/Reward TP
-
false → Bollinger middle TP (fallback to RR if invalid)
-
-
InpRR: Risk/Reward ratio (default: 2.0).
-
InpBBPeriod: Bollinger Bands period (default: 20).
-
InpBBDeviation: Bollinger deviation (default: 2.0).
Trading / Execution / Safety
-
InpLots: Requested lot size (normalized to symbol min/max/step).
-
InpSlippagePoints: Max slippage (points).
-
InpMagic: Magic number to track EA positions.
-
InpExtraStopBufferPts: Extra safety buffer (points) added to broker minimum stop distance.
The EA effectively enforces:
min_stop_distance = max(StopsLevel, FreezeLevel) + Spread(points) + InpExtraStopBufferPts
Notable Operational Behavior
-
Runs only once per new bar on InpTF (no tick-by-tick entries).
-
Uses closed-bar signals ( shift=1 ) for RSI/MA/candle values.
-
One open position at a time per symbol and InpMagic .
-
Broker-rule compliant stops: SL/TP are adjusted to meet minimum distances; if not possible, the trade is skipped.
-
Trade comments label entries as Aggro or Caut depending on SMA distance.
