6.3 KiB
6.3 KiB
Thivyam Scalper Fx EA v3.00
Overview
Thivyam Scalper Fx v3.00 is a MetaTrader 5 Expert Advisor (EA) designed for advanced trend-following scalping on the M5 (5-minute) chart, with trade direction confirmed by a higher timeframe (default H1). This version introduces a modular codebase, enhanced visual feedback, improved risk management, and more robust trade/session controls.
Key Features
- Multi-Timeframe Trend Confirmation: Uses EMAs on higher and lower timeframes for robust trend bias.
- Modular Architecture: Core logic split into helper libraries for candles, indicators, drawings, trading, time, and miscellaneous functions.
- Dynamic & Fixed Lot Sizing: Supports both fixed and dynamic lot sizing based on account risk.
- Flexible Session Controls: User-defined trading hours with options to close trades or cancel pending orders at session end.
- Advanced Order Management: Batch-based tracking, trailing stop logic, breakeven management, and robust pending order handling.
- Visual Chart Feedback: Real-time display of Bid, Ask, Spread, ATR, and last candle size using chart labels and rectangles.
- Comprehensive Debugging: Extensive emoji-based logging and debug output for easier monitoring and troubleshooting.
Strategy Logic
1. Trend Confirmation (Higher Timeframe, e.g., H1)
- Indicators: 8-period EMA and 21-period EMA (Close).
- Sell Bias: EMA(8) < EMA(21) and price < EMA(8).
- Buy Bias: EMA(8) > EMA(21) and price > EMA(8).
- No trades if neither bias is confirmed.
2. Entry Setup (Lower Timeframe, e.g., M5)
- Indicators: 8, 13, and 21-period EMAs (Close).
- Trigger Bar: Price pulls back to touch EMA(8) but does not close beyond EMA(21).
- Sell Trigger: On sell bias, price touches EMA(8) but remains above EMA(21).
- Buy Trigger: On buy bias, price touches EMA(8) but remains below EMA(21).
- EMA Separation Filter: All three EMAs must be at least a user-defined number of points apart.
3. Trade Execution
- Pending Orders: On a trigger, pending orders are placed:
- Sell: Sell Stop orders below the lowest low of the last 5 candles, SL above the trigger bar high.
- Buy: Buy Stop orders above the highest high of the last 5 candles, SL below the trigger bar low.
- Take Profits: Multiple orders with different risk/reward targets and trailing logic.
- Order Expiry: All pending orders expire at the end of the trading day or as per user session settings.
4. Trade Management
- Trailing Stop: Trailing logic for selected orders based on recent price action.
- Breakeven Logic: SLs moved to breakeven after first TP is hit.
- Session Controls: Trading only during active hours; optional auto-close/cancel at session end.
Input Parameters
| Parameter Name | Description |
|---|---|
| HigherTF / LowerTF | Timeframes for trend confirmation and entries. |
| DynamicLotSize | Enable dynamic lot sizing based on account risk. |
| AccountRisk / MaxDailyRisk | Risk settings for dynamic lot sizing. |
| Lots | Fixed lot size per order. |
| Slippage | Maximum allowed slippage (points). |
| EntryPointOffset / SLPointOffset | Entry and stop offsets (points). |
| MaxActiveTrades / Orders | Maximum open trades and pending orders. |
| Take Profit Settings | TP levels for different order types. |
| TrailingSLcandleCount | Number of candles for trailing stop calculation. |
| MAsApartByPoints | Minimum EMA separation (points) for valid setup. |
| minSLPoints | Minimum stop loss distance (points). |
| Session Controls | Trading hours, auto-close/cancel at session end. |
| ShowRect / ShowSpread / ShowAtr / ShowLastCandleSize | Visual feedback options for chart overlays. |
| debugging | Enable detailed debug output. |
| MagicNumber | Unique EA identifier for trades. |
Visual Feedback
- Bid, Ask, Spread: Displayed as labels in the top right corner.
- ATR and Candle Size: Optional display for quick volatility and range reference.
- Rectangles and Arrows: Visual cues for trade triggers and order placement.
Changelog
v3.00
- Modularized Codebase: Split logic into helper libraries for maintainability and clarity.
- Enhanced Chart Overlays: Added multi-label display for Bid, Ask, Spread, ATR, and candle size.
- Improved Risk Controls: More flexible lot sizing and risk management options.
- Batch-Based Order Management: Robust tracking and handling of trade batches.
- Refined Trailing and Breakeven Logic: More reliable and configurable trailing stop and breakeven handling.
- Expanded Debugging: More detailed and emoji-rich logs for all major events and actions.
- Bug Fixes and Optimizations: Improved error handling, code structure, and performance.
Usage Notes
- Attach the EA to an M5 chart (or your chosen LowerTF).
- Ensure required timeframes are available in your MT5 terminal.
- Adjust input parameters to suit your risk and session preferences.
- For best results, use on a broker with low spreads and fast execution.
Disclaimer
This EA is provided for educational and research purposes. Live trading involves risk. Test thoroughly on a demo account before using with real funds.