Experts: ExMachina SafeScalping

 

ExMachina SafeScalping:

ExMachina Safe Scalping is a professional-grade Expert Advisor built for conservative breakout scalping on Gold (XAUUSD), Silver (XAGUSD), and Forex majors.

ExMachina SafeScalping

Author: William Jefferson Mukam Tatsinke

 
        TREND_MODERATE = 1, // Moderate Trends Only
        TREND_STRONG = 2        // Strong Trends Only
};

enum ENUM_SL_MODE
{
        SL_FIXED_POINTS = 0, // Fixed Points
        SL_ATR_BASED = 1         // ATR Based
};

//+------------------------------------------------------------------+
//| INPUT PARAMETERS                                                 |
input double InpRiskPercent = 1.0;                      // Risk % per Trade
input double InpMaxDrawdownPct = 10.0;          // Max Drawdown % (pause)

input string _s2_ = "=== SL / TP ===";           // ────────────────────
input ENUM_SL_MODE InpStopLossMode = SL_FIXED_POINTS; // Stop Loss Mode
input int InpStopLossPoints = 225;               // (Fixed) Stop Loss (points)
input double InpSlAtrMultiplier = 1.5;           // (ATR) SL Multiplier
input int InpTakeProfitPoints = 250;             // Take Profit (points)
input bool InpUseBreakeven = true;               // Use Breakeven
input int InpBreakevenStart =Dynamic stop loss suggestions.x 100;               // BE Trigger (points)
input int InpBreakevenOffset = 10;               // BE Offset (points)

input string _s3_ = "=== EMA TREND ===";                                // ────────────────────
input int InpEmaFast = 150;                                                             // Fast EMA Period
double g_dayBalance = 0;
datetime g_dayStart = 0;
bool g_ddPaused = false;
double g_currentSlPoints = 0; // Current SL in points for the new trade

//+------------------------------------------------------------------+
//| INIT                                                             |
int OnInit()
{
        // Validate
        if ((InpStopLossMode == SL_FIXED_POINTS && InpStopLossPoints <= 0) || InpTakeProfitPoints <= 0)
        {
                Print("ERROR: SL and TP must be > 0");
                return INIT_PARAMETERS_INCORRECT;
        if (atr <= 0)
                return;

        // --- Calculate dynamic SL for this tick ---
        if (InpStopLossMode == SL_ATR_BASED)
        {
                g_currentSlPoints = atr * InpSlAtrMultiplier;
        }
        else
        {
                g_currentSlPoints = InpStopLossPoints;
        }
        if (g_currentSlPoints <= 0) return;

        // --- SIGNAL GENERATION (6 conditions) ---
        int signal = GetSignal(emaF, emaS, rsi, atr, c1, c2);
        if (signal == 0)

        // --- EXECUTE ---
        double lot = CalcLot(g_currentSlPoints);
        if (lot <= 0)
                return; // Insufficient margin

        if (marginNeeded > 0 && marginNeeded >= g_acc.FreeMargin() * 0.9)
                return;

        if (signal == 1) // BUY
                OpenBuy(lot, (int)g_currentSlPoints, InpTakeProfitPoints);
        else if (signal == -1) // SELL
                OpenSell(lot, (int)g_currentSlPoints, InpTakeProfitPoints);
}

//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| LOT CALCULATION                                                  |
//+------------------------------------------------------------------+
double CalcLot(double slPts)
{
        double lots = InpFixedLots;


Dynamic stop loss suggestions.