Advertisement IC Markets

How to set stop loss and take profit when scalping

Discuss 1-minute to 15-minute price action setups, fading intraday momentum, key support/resistance zones, and proven short-term trading methodologies.
FTtrader
Posts: 954
Joined: Mon Aug 03, 2026 2:43 pm

Re: How to set stop loss and take profit when scalping

Post by FTtrader »

MT4: The OrderSend Framework

If you're still running your edge on MT4, the math remains identical, but the routing is passed through the legacy OrderSend syntax.

Code: Select all

//+------------------------------------------------------------------+
//|                 Pro_Bracket_Execution_MT4.mq4                    |
//+------------------------------------------------------------------+
#property strict

extern double RiskPercent = 1.0;       // Account Risk per Trade (%)
extern int    AtrPeriod   = 14;        // ATR Length
extern double SlMult      = 1.0;       // Stop Loss (ATR Multiplier)
extern double TpMult      = 2.0;       // Take Profit (ATR Multiplier)

void ExecuteBracket(int direction) {
    // MT4 simplifies ATR calls natively
    double volatility = iATR(_Symbol, 0, AtrPeriod, 1);
    
    double sl_price, tp_price, entry_price;
    int cmd;
    
    // Calculate precise structural boundaries
    if (direction == OP_BUY) {
        entry_price = Ask;
        sl_price = entry_price - (volatility * SlMult);
        tp_price = entry_price + (volatility * TpMult);
        cmd = OP_BUY;
    } else {
        entry_price = Bid;
        sl_price = entry_price + (volatility * SlMult);
        tp_price = entry_price - (volatility * TpMult);
        cmd = OP_SELL;
    }
    
    // Core Position Sizing Math
    double tick_value = MarketInfo(_Symbol, MODE_TICKVALUE);
    double tick_size  = MarketInfo(_Symbol, MODE_TICKSIZE);
    double lot_step   = MarketInfo(_Symbol, MODE_LOTSTEP);
    
    double risk_money = AccountEquity() * (RiskPercent / 100.0);
    double sl_ticks   = MathAbs(entry_price - sl_price) / tick_size;
    double lot_size   = risk_money / (sl_ticks * tick_value);
    
    // Normalize lot size to prevent broker rejection
    lot_size = MathFloor(lot_size / lot_step) * lot_step;
    
    // Route to the broker server immediately
    int ticket = OrderSend(_Symbol, cmd, lot_size, entry_price, 3, sl_price, tp_price, "Pro_Bracket", 0, 0, clrBlue);
}
Recommended broker for automated trading & scalping IC Markets
FTtrader
Posts: 954
Joined: Mon Aug 03, 2026 2:43 pm

Re: How to set stop loss and take profit when scalping

Post by FTtrader »

Concrete desk rule: If your execution logic doesn't mathematically normalize the final lot size against the broker's minimum LOTSTEP, the server will instantly reject your order right when the market is moving the fastest.
Mechanize the math, compile it, and stop manually negotiating with your trades.
FTtrader
Posts: 954
Joined: Mon Aug 03, 2026 2:43 pm

Re: How to set stop loss and take profit when scalping

Post by FTtrader »

Now we’re talking my language. If you're serious about algorithmic execution and pure spot trading, MT4 and MT5 are ancient history.

After 26 years, I can tell you that bridging software and legacy C++ wrappers are liabilities when you’re pushing high volume. cTrader is the actual sweet spot for this. It runs natively on C# (.NET), which means you have an enterprise-grade, object-oriented environment to build out your risk logic. Plus, true A-book spot brokers favor cTrader because it's built for direct market access (DMA), completely bypassing the synthetic prop firm nonsense.

Because my edge relies entirely on raw price action and structural liquidity sweeps on the 15-minute and daily charts, I don't want lagging indicators cluttering my execution loop. I want a clean, brutal logic block: identify the sweep, calculate the dynamic ATR bounds, size the position to the penny, and fire the hard brackets straight to the server.

Here is the professional-grade C# framework for cAlgo. It leverages cTrader's native Symbol.NormalizeVolumeInUnits() method to ensure your lot sizing strictly adheres to broker limits—meaning zero rejected tickets when the market is moving fast.
FTtrader
Posts: 954
Joined: Mon Aug 03, 2026 2:43 pm

Re: How to set stop loss and take profit when scalping

Post by FTtrader »

cTrader C# cAlgo: Pro Bracket Execution Framework

Code: Select all

using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class ProBracketExecutionSpot : Robot
    {
        // =========================================================================
        // INPUTS: Risk Management & Bracket Parameters
        // =========================================================================
        [Parameter("Account Risk per Trade (%)", Group = "Risk Management", DefaultValue = 1.0, MinValue = 0.1, Step = 0.1)]
        public double RiskPercent { get; set; }

        [Parameter("ATR Length", Group = "Execution Parameters", DefaultValue = 14)]
        public int AtrPeriod { get; set; }

        [Parameter("Stop Loss (ATR Multiplier)", Group = "Execution Parameters", DefaultValue = 1.0, Step = 0.1)]
        public double SlMult { get; set; }

        [Parameter("Take Profit (ATR Multiplier)", Group = "Execution Parameters", DefaultValue = 2.0, Step = 0.1)]
        public double TpMult { get; set; }

        private AverageTrueRange _atr;

        protected override void OnStart()
        {
            // Initialize ATR for dynamic structural breathing room
            _atr = Indicators.AverageTrueRange(AtrPeriod, MovingAverageType.Simple);
        }

        // =========================================================================
        // ORDER ROUTING & POSITION SIZING (HARD EXITS ONLY)
        // =========================================================================
        public void ExecuteBracket(TradeType direction)
        {
            // Lock in volatility from the last closed candle
            double volatility = _atr.Result.Last(1); 
            
            // 1. Calculate capital at risk
            double riskMoney = Account.Equity * (RiskPercent / 100.0);
            
            // 2. Calculate exact stop and target distances in native pips
            double slDistancePips = (volatility * SlMult) / Symbol.PipSize;
            double tpDistancePips = (volatility * TpMult) / Symbol.PipSize;
            
            // 3. Core Position Sizing Math
            // Volume = Risk / (SL pips * Pip Value)
            double rawVolume = riskMoney / (slDistancePips * Symbol.PipValue);
            
            // 4. Normalize to prevent broker rejection (The crucial step)
            double normalizedVolume = Symbol.NormalizeVolumeInUnits(rawVolume, RoundingMode.Down);
            
            // 5. Route instantly to the order book with hard brackets attached
            ExecuteMarketOrder(direction, SymbolName, normalizedVolume, "Pro_Bracket", slDistancePips, tpDistancePips);
        }

        protected override void OnBar()
        {
            // Placeholder for your 15m/Daily raw price action triggers.
            // Example: If (BullishLiquiditySweep) ExecuteBracket(TradeType.Buy);
        }
    }
}
PropScalpDesk
Posts: 364
Joined: Sat Sep 19, 2026 7:50 pm

Re: How to set stop loss and take profit when scalping

Post by PropScalpDesk »

FTtrader wrote:MT5: The CTrade Framework MT5 uses an object-oriented architecture, so we utilize the standard library's CTrade class to handle the execution routing seamlessly. Code: Select all //+------------------------------------------------------------------+ //| Pro_Bracket_Execution_MT5.mq5 | //+------------------------------------------------------------------+ #property strict #include <Trade\Trade.mqh> input double RiskPercent = 1.
Stops and targets on scalps must clear spread and noise. I set invalidation first in price structure, then check if R still makes sense after typical slip.

If it does not, I skip — I do not shrink the stop until it “fits.”

Do you fix R and reject fat setups, or adjust targets to keep a habit of clicking?

I also log refused tickets so flat time counts as work — otherwise the desk invents activity.

Boring survival beats a clever recovery that spends the week’s DD band.

Topic note from my sheet for t=14: keep risk unchanged until the sample says otherwise.
LondonNewsTrader
Posts: 80
Joined: Mon Sep 21, 2026 9:30 am

Re: How to set stop loss and take profit when scalping

Post by LondonNewsTrader »

FTtrader wrote:MT5: The CTrade Framework MT5 uses an object-oriented architecture, so we utilize the standard library's CTrade class to handle the execution routing seamlessly. Code: Select all //+------------------------------------------------------------------+ //| Pro_Bracket_Execution_MT5.mq5 | //+------------------------------------------------------------------+ #property strict #include <Trade\Trade.mqh> input double RiskPercent = 1.
The sizing maths is right, and flooring to the lot step avoids the usual volume rejections. A few failure cases I'd guard against before using it live.

CopyBuffer is called straight after iATR creates the handle. On the first call the indicator often hasn't calculated yet, CopyBuffer returns -1, and atr[0] reads from an empty array, which stops the EA with an array out of range error. Creating the handle in OnInit, as the comment suggests, and checking the return value fixes both.

After MathFloor, lot_size can end up below SYMBOL_VOLUME_MIN, or zero, on a small account with a wide ATR. Clamp it between minimum and maximum volume, and skip the trade if the minimum would exceed your risk.

A buy stop is triggered on the bid, yet the distance is measured from the ask. With a 1 × ATR stop on M1 that matters: when the spread widens around a release, a big chunk of the distance is just spread. I'd enforce a minimum of a few times the current spread, never less than SYMBOL_TRADE_STOPS_LEVEL.

For the opener's style of many positions a day with mental stops, an EA like this works better as a catastrophic backstop far beyond the mental level than as the primary exit.
Post Reply