Stochastic Protector

Stochastic Protector
Download ALL MT5 experts (1568)
YouTube Video Thumbnail



Similar MetaTrader Tools

Stochastic Protector

Info

The Stochastic Protector is a Expert Advisor for MetaTrader 5 that the ea supports three distinct closing modes: - crossing mode - closes positions when %k and %d cross in overbought or oversold zones. - Entering Mode - closes positions when %D enters overbought or oversold zones.

Usage

This tool is typically used for automated trading on major forex pairs and gold.

Platform

This Expert Advisor works exclusively on MetaTrader 5 (both build 600+ and newer versions).

Setup

Place the downloaded file in MQL5/Experts folder via File ? Open Data Folder in MetaTrader 5.


How to Install and Use Stochastic Protector

1. Installation: Open the "File" menu, select "Open Data Folder," navigate to MQL/Experts, paste your file, and restart the terminal.

2. Activation: Drag the EA from the Navigator onto a chart, ensure "Allow live trading" is checked in the Common tab, and verify the AutoTrading button is green.

3. Optimization: Right-click your chart, choose "Expert List," click "Properties" to adjust inputs, and save your preferred setup as a set file for future use.

4. Maintenance: Regularly check the "Experts" tab in the terminal window to monitor trade logs and potential execution errors.

Frequently Asked Questions

Q: Why is my EA not opening trades? A: Check the "AutoTrading" button, ensure "Allow live trading" is enabled, and verify your broker allows automated trading on your account type.

Q: Can I run multiple EAs on one chart? A: No, each chart can only host one active EA; however, you can open multiple charts for different currency pairs to run several EAs.

Q: What does the "smiley face" icon mean? A: A smiley face in the top-right corner of the chart indicates the EA is successfully running; a frowny face means it is disabled.

What this tool does

The EA supports three distinct closing modes: - Crossing Mode - closes positions when %K and %D cross in overbought or oversold zones.

Typical Use Case

This Expert Advisor excels in automated trading and technical analysis on MetaTrader 5.

Compatible Platform & Setup

This Expert Advisor works on MetaTrader 5. Place the file in the MQL5/Experts folder and restart the terminal.

Description & Settings

Related: trade signals based on 3 black crows/3 white soldiers + stochastic - another powerful expert for MetaTrader 5 traders.

The EA supports three distinct closing modes: - Crossing Mode - closes positions when %K and %D cross in overbought or oversold zones. - Entering Mode - closes positions when %D enters overbought or oversold zones. - Exiting Mode - closes positions when %D exits overbought or oversold zones.

Also recommended: trade signals based on dark cloud cover/piercing line + stochastic - similar expert with strong performance on MetaTrader 5.

Additionally, positions can be filtered for closure by their profit state, providing granular control over which trades to exit. An optional Test Mode enables basic entry functionality for demonstration or research purposes.

The source code is fully open and can be used to develop custom position management strategies, add new filters, and test trading hypotheses.

Parameters - Stochastic Parameters: - InpKPeriod — %K Period for the Stochastic oscillator. Default is 14. - InpDPeriod — %D Period (signal line) for the Stochastic oscillator. Default is 3. - InpSlowing — Slowing factor for the Stochastic oscillator. Default is 3. - InpOverSold — Oversold level. Default is 20. - InpOverBought — Overbought level. Default is 80. - Stoch_price_field — Price field used for Stochastic calculation. Default is STO_CLOSECLOSE.

- EA Parameters: - Stoch_Zone_Mode — Closing mode. Available modes: Crossing, Entering, Exiting. Default is Crossing. - InpPosistionState — Profit state filter. Available modes: Loss, Profit, Profit_and_Loss. Default is Loss. - InpTimeframe — Timeframe for Stochastic calculation. Default is PERIOD_CURRENT.

- Test Mode Parameters: - TestMode — Enable or disable Test Mode entry functionality. Default is false. - OffSet — Offset value for midline (50) crossovers. Default is 20. Example: Offset = 20 triggers entries above 30 or below 70.

Closing Modes Explanation - Crossing Mode closes BUY positions when %K crosses below %D while %D is above Overbought (80). Closes SELL positions when %K crosses above %D while %D is below Oversold (20). - Entering Mode closes SELL positions when %D drops below Oversold (entering oversold). Closes BUY positions when %D rises above Overbought (entering overbought). - Exiting Mode closes SELL positions when %D rises above Oversold (exiting oversold). Closes BUY positions when %D drops below Overbought (exiting overbought).

Position State Filter - Loss closes only positions with negative floating profit. - Profit closes only positions with positive floating profit. - Profit_and_Loss closes all positions regardless of profit status.

Test Mode Behavior When TestMode is enabled, the EA monitors the %D line relative to the midline (50) using the configurable OffSet. A BUY order (0.01 lots) is opened when %D crosses above (50 - OffSet). A SELL order (0.01 lots) is opened when %D crosses below (50 + OffSet). This routine only executes when no positions are currently open. Test Mode entries use a fixed lot size of 0.01 with no Stop Loss, Take Profit, or magic number filtering.

Important Notes The EA evaluates the Stochastic indicator on each tick. The indicator runs on a user-selectable timeframe, independent of the chart timeframe. Position closures are executed only on the current chart symbol. Positions on other symbols are ignored. The InpPosistionState filter applies globally to all positions on the symbol. For example, selecting Profit will close all profitable positions that match the Stochastic condition.

Test Mode entries use a fixed lot size of 0.01 and do not include Stop Loss or Take Profit. Test Mode and the core closing logic operate simultaneously when enabled. The EA will both close positions based on Stochastic signals and open new positions under Test Mode conditions. The tradable flag is set during Test Mode executions but does not affect the core closing logic. The EA does not include money management, trailing stops, or breakeven functionality. The EA was created for researching position management strategies and should not be considered a ready-to-trade system without additional validation and out-of-sample testing in 2026.

You may also like: mq l5 wizard: trade signals with bullish/bearish engulfing and stochastic confirmation - excellent alternative for expert users on MetaTrader 5.

Source Code

#property copyright "RobotFX"
#property version   "1.0"
#property description "This code is educational. Feel free to use, modify and upgrade as you wish. Visit ROBOTFX.ORG for professional trading tools"
#include <Trade\Trade.mqh>
CTrade Trade;
enum ENUM_POSITION_STATE
  {
   Loss,
   Profit,
   Profit_and_Loss

.......

Leave your opinion, ask a question, share some knowledge

Limitations & Risk Warning

  • This tool is provided for educational and testing purposes only.
  • Past performance does not guarantee future results.
  • Trading involves substantial risk of loss. Use on a demo account first.
  • Results may vary depending on market conditions, broker, and settings.
  • We recommend thorough backtesting and forward testing before using with real funds.
© ROBOTFX Free educational tools by RobotFX. Use entirely at your own risk; we are not liable for any financial losses incurred.