With indicator-based exits you have a few solid options for the loss side. Here are three approaches, from simplest to most robust:
1. Opposite signal as stop loss
The simplest: if you entered long because RSI was oversold + price below lower BB, close at loss when RSI reaches overbought + price hits upper BB (i.e. the opposite entry condition fires while you're underwater). The logic mirrors your TP but without the profit check:
bool stopRSI = (type == POSITION_TYPE_BUY && bid < open && RSI_Value >= RSI_AboveLevel) || (type == POSITION_TYPE_SELL && bid > open && RSI_Value <= RSI_BelowLevel);
Problem: the opposite signal might take a long time to fire, so you sit in a deep loss waiting.
2. BB middle band as dynamic stop
The Bollinger middle band (which is just the SMA) works well as a "reversal failed" level. If you bought at the lower band expecting a bounce, and price closes below the middle band going the wrong way, the reversal thesis is broken:
double BB_MiddleBand = fBands(rSymbol, SelectedTimeFrame, BollingerBands_Period, BollingerBands_deviation, 0, PRICE_CLOSE, MODE_MAIN, 1); bool stopBB_Mid = (type == POSITION_TYPE_BUY && bid < open && bid <= BB_MiddleBand) || (type == POSITION_TYPE_SELL && bid > open && bid >= BB_MiddleBand);
This gives you a dynamic stop that adapts to volatility (since BB width changes with ATR), which is the main advantage over a fixed pip stop.
3. ATR-based maximum loss (recommended as safety net)
Regardless of which indicator exit you use, you should always have a hard maximum loss per trade. Use ATR so it adapts to the instrument's volatility:
int atr_handle = iATR(rSymbol, SelectedTimeFrame, 14); double atr_buf[]; CopyBuffer(atr_handle, 0, 1, 1, atr_buf); double maxLoss = atr_buf[0] * 2.0; // 2x ATR as absolute max bool stopATR = (type == POSITION_TYPE_BUY && (open - bid) >= maxLoss) || (type == POSITION_TYPE_SELL && (ask - open) >= maxLoss);
This acts as your emergency exit. Even if the BB middle band hasn't been hit yet, if price moves 2x ATR against you, something unexpected happened and you get out.
My suggestion: combine #2 and #3. Use the BB middle band as your primary indicator-based stop, and keep the ATR stop as a hard ceiling that never gets exceeded. Check both on every tick and close on whichever triggers first.
One more thing, I noticed a small bug in your TP code:
(type == POSITION_TYPE_SELL && bid < open & bid <= BB_LowerBand_SupportLine)
That single & should be && . The single & is a bitwise AND, not a logical AND. It might work in some cases but will produce unexpected results with doubles. Easy fix but can cause weird behavior.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello,
I am using simple RSI + BollingerBands to find reversal and take a trade. i am not using any Take Profit or StopLoss defined directly in Order or defined in Point/Pips instead i am using Indicator to calculate When to close trade in profit (Take Profit similar) but the problem is i am confused about when to close the trade in loss (Stop Loss Similar).
Entry :
Take Profit (With Indicator) :
Take profit working amazing.
StopLoss (With Indicator) : ??? - I am unable to understand this part. when should i close the trade at loss?. Need suggestion.