JS-MA-Day
Download scriptThis script is an automated trading system designed for the MetaTrader 5 platform. Its primary objective is to manage and execute trades based on moving average trends, while incorporating sophisticated risk management and trade protection features.
Core Trading Logic
The system monitors price action by comparing a Moving Average (MA) against the daily opening prices. It looks for specific "crossover" or trend-reversal patterns:
- Buy Signals: Triggered when the moving average is trending upwards relative to previous days and moves above the current day's opening price.
- Sell Signals: Triggered when the moving average is trending downwards relative to previous days and moves below the current day's opening price.
The logic also includes a Signal Reversal toggle, which allows the user to flip these conditions (e.g., making a bull signal act as a bear signal).
Key Management Features
The script is built with several "safety" layers to ensure it operates within professional trading boundaries:
- Dynamic Risk & Lot Sizing: Users can choose between fixed trade sizes (Lots) or a risk-based model. If risk is enabled, the system automatically calculates the correct position size based on a percentage of your account equity, ensuring you don't over-leverage on any single trade.
- Hard Limits: You can define a maximum number of simultaneous positions to prevent the bot from opening too many trades at once.
- Trade Protection (Trailing Stop): The script includes an active trailing stop mechanism. As a trade moves into profit, the system automatically adjusts the "Stop Loss" price to lock in gains while allowing the trade room to continue growing.
- Time Management: There is a configurable "Close Hour." Once this time is reached, the bot can be instructed to close all active positions automatically to avoid holding trades overnight or during high-risk periods.
- Order Integrity: Before any trade is placed, the script performs several validation checks. It confirms that the requested volume is valid for the specific currency pair and verifies that there is sufficient free margin in the account to execute the order without failing.
User Experience & Monitoring
To keep the user informed, the script provides detailed feedback via a print log. It reports:
- Success or failure of every trade request.
- Specific error codes from the broker (e.g., "insufficient funds" or "invalid volume").
- The exact prices, volumes, and result descriptions for every action taken.
In summary, this is a trend-following automated system that prioritizes risk calculation and profit protection by combining moving average analysis with automated trailing stops and time-based exit rules.
ÿþ/ / + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
/ / | J S - M A - D a y . m q 5 |
/ / | w s f o r e x @ l i s t . r u |
/ / | h t t p : / / w s f o r e x . r u / |
/ / + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
# p r o p e r t y c o p y r i g h t "