Advertisement IC Markets

Heat Maps of Your Performance by Day and Hour

Document your personal trading journey. Track daily equity curves, review winning and losing streaks, share trade screenshots, and get constructive feedback.
PTScalper
Site Admin
Posts: 4805
Joined: Mon Jul 20, 2026 1:28 pm

Re: Heat Maps of Your Performance by Day and Hour

Post by PTScalper »

2. MetaTrader 5 (MQL5) Implementation

In MQL5, we use the CTrade library for execution. The architecture remains the same: the state of the time window dictates the strictness of the stop modification.

Code: Select all

#include <Trade\Trade.mqh>
CTrade trade;

input double StandardTrailPips = 10.0;
input double AggressiveTrailPips = 3.0;

void OnTick()
{
    bool allowed = IsTradingAllowed();
    
    // Always manage open positions
    ManageTrailingStops(allowed);
    
    // Gatekeeper for new entries
    if(!allowed) return;
    
    // Entry logic...
}

void ManageTrailingStops(bool isTradingAllowed)
{
    double activeTrail = isTradingAllowed ? StandardTrailPips : AggressiveTrailPips;
    double point = SymbolInfoDouble(_Symbol, SYMBOL_POINT);
    double trailDistance = activeTrail * 10 * point; // Assuming 5-digit broker

    for(int i = PositionsTotal() - 1; i >= 0; i--)
    {
        ulong ticket = PositionGetTicket(i);
        if(PositionGetString(POSITION_SYMBOL) != _Symbol) continue;
        
        double currentStop = PositionGetDouble(POSITION_SL);
        double currentTakeProfit = PositionGetDouble(POSITION_TP);
        long type = PositionGetInteger(POSITION_TYPE);
        
        if(type == POSITION_TYPE_BUY)
        {
            double currentBid = SymbolInfoDouble(_Symbol, SYMBOL_BID);
            double newStop = currentBid - trailDistance;
            
            if(currentStop == 0 || newStop > currentStop)
            {
                trade.PositionModify(ticket, newStop, currentTakeProfit);
            }
        }
        else if(type == POSITION_TYPE_SELL)
        {
            double currentAsk = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
            double newStop = currentAsk + trailDistance;
            
            if(currentStop == 0 || newStop < currentStop)
            {
                trade.PositionModify(ticket, newStop, currentTakeProfit);
            }
        }
    }
}
Preserve your own money. Scale with the market's money. Exponential growth is the ultimate key.
Recommended broker for automated trading & scalping IC Markets
PTScalper
Site Admin
Posts: 4805
Joined: Mon Jul 20, 2026 1:28 pm

Re: Heat Maps of Your Performance by Day and Hour

Post by PTScalper »

Critical Edge Cases for Scalpers

When tightening stops programmatically during low-liquidity periods, you must engineer around spread widening.

The Spread-Out Trap: On Raw ECN accounts, spreads during the midday chop might hover near 0.0 pips, but on Friday afternoons (or during the 23:59 server rollover), spreads can artificially widen by 2 to 5 pips as liquidity providers pull their quotes.

The Solution: If you set your AggressiveTrail to 2 pips, the widened spread alone will trigger your Stop Loss instantly, resulting in horrible slippage. Your aggressive trail distance must always be structurally larger than the maximum expected spread of that time block.
Preserve your own money. Scale with the market's money. Exponential growth is the ultimate key.
PTScalper
Site Admin
Posts: 4805
Joined: Mon Jul 20, 2026 1:28 pm

Re: Heat Maps of Your Performance by Day and Hour

Post by PTScalper »

Instead of a fixed pip distance, an alternative approach for the Soft Close is a Fractal or Candle-Based Trail. Rather than trailing by 3 pips, you program the bot to trail the Stop Loss to the High/Low of the previous M5 or M15 candle once the lockout begins. This allows the trade to breathe technically while strictly preventing it from reversing the current micro-trend.
Preserve your own money. Scale with the market's money. Exponential growth is the ultimate key.
Post Reply