Babi Ngepet
- Experts
- Taufiqurrachman Assauqi
- Version: 1.0
BabiNgepet.mq5 - Martingale Scalping Expert Advisor
BabiNgepet.mq5 is an Expert Advisor (EA) developed for MetaTrader 5 (MT5) that implements a Martingale scalping strategy. This EA is designed to open and manage trades automatically, aiming to recover losses by increasing lot sizes on subsequent trades in a series.
Key Features and Functionality:
- Martingale Strategy: The core of this EA is a Martingale approach. When a series of trades is in negative floating profit and the price moves a specified distance against the initial entry, the EA opens new trades in the same direction (or reverse, if configured) with an increased lot size.
- Scalping Focus: The strategy appears to aim for smaller profits, as indicated by the TakeProfit parameter, which is set to 15 pips by default.
- Dynamic Lot Sizing: The EA calculates and normalizes lot sizes based on the broker's minimum, maximum, and step volumes to ensure compliance and avoid trading errors.
- Profit Target Management: The EA monitors the total floating profit of all positions opened by it. Once the SecureProfitMartingaleTarget is reached, all active positions are closed to secure the profit, and the Martingale series is reset.
- Initial Trade Entry: When no positions are open, the EA looks for potential entry points by identifying the highest high and lowest low within a specified FindHighLowBackBars range. It then places an initial buy order if the current price is above the calculated "buy price" (lowest low minus one point) or a sell order if the current price is below the calculated "sell price" (highest high plus one point).
- Trade Series Limit: A MaxTradesInSeries parameter is in place to limit the number of consecutive trades opened within a Martingale series, acting as a safeguard against excessive exposure.
- Time-Based Trading Control:
- Day of Week Control: Users can enable or disable trading for specific days of the week (Monday to Friday) via input parameters.
- Forbidden Dates: The EA allows users to specify particular dates on which trading should be prohibited, offering an additional layer of control for avoiding high-impact news events or holidays.
- Margin Check: Before opening any trade, the EA performs a margin check to ensure sufficient free margin is available in the account, preventing "not enough money" errors.
- Volume Limit Check: The EA includes a check to ensure that the trading volume does not exceed the broker's maximum allowed volume.
- Magic Number: Trades opened by this EA are assigned a unique MagicNumber (defaulting to 6969), allowing the EA to specifically manage only its own positions.
Input Parameters:
The EA provides several customizable input parameters categorized into:
- General Parameters:
- MagicNumber : Unique identifier for the EA's trades.
- InitialLot : The starting lot size for a new series of trades (fixed at 0.03).
- TakeProfit : The target profit in pips for initial trades.
- FindHighLowBackBars : Number of past bars to look back for finding high and low prices for initial entry.
- Martingale Strategy:
- ReverseMartingale : A boolean to determine if subsequent Martingale trades should be in the same direction ( false ) or the opposite direction ( true ) of the previous trade in the series.
- LotMultiplier : The factor by which the lot size is increased for subsequent Martingale trades.
- SecureProfitMartingaleTarget : The total floating profit (in account currency) at which all positions in a Martingale series will be closed.
- DistanceMartingalePips : The price distance in pips that the market must move against the last opened trade to trigger another Martingale trade.
- MaxTradesInSeries : The maximum number of trades allowed within a single Martingale series.
- Time Strategy:
- AllowMonday to AllowFriday : Boolean flags to enable or disable trading on specific weekdays.
- ForbiddenDates : A comma-separated string of specific dates (e.g., "2024.01.10,2024.02.28") on which trading is not allowed.
Disclaimer: As with any automated trading system, it's crucial to understand the risks involved, especially with Martingale strategies which can lead to significant drawdowns if not properly managed or if market conditions are unfavorable. Thorough backtesting and risk management are highly recommended before using this EA on a live account.