Expert Advisors • Indicators • Scripts • Libraries

MQL.RobotFX.org is the biggest collection of MetaTrader expert advisors (MT5 & MT4), indicators, scripts and libraries that can be used to improve trading results, minimize risks or simply automate trading tasks

MetaTrader 5 Script | Smart Stockastic MA

MetaTrader Experts, Indicators, Scripts and Libraries

Advanced Stochastic EA

A Smart Trend-Following Expert Advisor with Stochastic Confirmation

🔹 Key Features

 Dual-Strategy System: Combines trend-filtering (200 MA) and stochastic crossover signals for high-probability trades.
 Partial Close Management: Locks profits by closing 50% of position at predefined levels ( PartialCloseLevel1 ).
 Flexible Risk Control: Fixed stop-loss (300 pts) and take-profit (500 pts) with adjustable lot size.
 New Bar Detection: Executes trades only at the start of new candles to avoid false signals.
 Magic Number Isolation: Prevents conflict with other EAs or manual trades.

📊 Input Parameters

Parameter Description
StochasticPeriodK Main period for %K line (default: 14).
StochasticPeriodD Smoothing period for %D line (default: 3).
UseTrendFilter Enables/disables 200 MA trend filter (default: true).
StopLossPoints SL in points (default: 300).
TakeProfitPoints TP in points (default: 500).
FixedLotSize Lot size per trade (default: 0.1).
UsePartialClose Enables profit-taking at PartialCloseLevel1 (default: true).
MagicNumber Unique EA identifier (default: 2024).

🎯 Advantages Over Manual Trading

  1. Eliminates Emotional Decisions: Strictly follows stochastic crossovers + MA trend rules.

  2. Automated Profit-Taking: Partially closes trades at 30+ profit points (scalping-friendly).

  3. Adaptable to Market Conditions: Works in trending and ranging markets (thanks to stochastic).

  4. Lightweight & Efficient: No heavy indicators or complex calculations.

⚙️ How It Works

  1. Entry Signals:

    • Buy: %K crosses %D upward + price above 200 MA (if trend filter enabled).

    • Sell: %K crosses %D downward + price below 200 MA.

  2. Exit Signals:

    • Closes trades at TP/SL or partially at PartialCloseLevel1 .

📈 Recommended Settings

  • Timeframe: M30-H1 (balanced speed/accuracy).

  • Pairs: EURUSD, GBPUSD, XAUUSD (volatile but trending).

  • Risk Management: Start with 0.1 lots on a demo account.

🚀 Why Choose This EA?

"It merges the reliability of trend-following with the precision of stochastic reversals—ideal for traders who want automation without over-optimization."


58971