Posts

​Hands-On Guide: Building an Automated Trade Journal and CSV Exporter in

 Keeping a meticulous trading journal is one of the most important habits of a successful systematic trader. However, manually writing down every entry, exit, profit, and loss in a spreadsheet is tedious and prone to human error. By writing a custom MQL5 function that automatically logs closed trade history directly into a structured CSV file, you can maintain a flawless performance journal effortlessly. In this hands-on tutorial, we will build a trade-logging script that tracks and exports closed order history in MetaTrader 5. --------------------------------------------------- 1. Why Automated Trade Journaling Matters Automated logging ensures: • Every single backtest or live execution is permanently recorded with exact timestamps. • You can easily import your CSV file into Microsoft Excel or Python pandas to analyze win rates, maximum drawdown, and profit factors offline. • You eliminate the emotional blind spots that come with manual record-keeping. ----------------------------...

​Hands-On Guide: Auto-Reconnecting WebSocket Streams in Python

 While REST APIs are great for periodic polling, real-time market tracking and streaming live tick data require WebSocket connections. However, network handshakes can drop unexpectedly due to mobile signal shifts or server heartbeats timing out. If your script doesn't handle disconnections automatically, it will crash and leave you blind to market movements. In this hands-on tutorial, we will build an auto-reconnecting WebSocket client loop in Python. --------------------------------------------------- 1. Why WebSockets Drop & How to Handle Them Unlike traditional HTTP request-response cycles, a WebSocket maintains a continuous persistent connection. When a drop occurs: • The socket raises a connection error or closed exception. • Instead of letting the script die, we wrap the connection inside a `while` loop combined with `try-except` blocks. • We implement an exponential backoff delay before attempting to reconnect so we don't spam the server. ----------------------------...

​Hands-On Guide: Automating Percentage Change Alerts with Python & Telegram

 Staring at price charts all day is exhausting and inefficient. Instead of manually monitoring assets for breakouts, you can write a lightweight Python script that calculates real-time percentage shifts and pushes instant alerts straight to your phone via Telegram when a threshold is breached. In this hands-on tutorial, we will build a percentage-change monitoring script optimized for mobile execution. --------------------------------------------------- 1. The Logic Behind Percentage Change Monitoring To catch sudden market momentum: • The script records a baseline reference price when it starts. • On every polling cycle, it compares the current market price against that baseline. • If the absolute percentage change exceeds your defined threshold (e.g., a 1.5% spike or drop), it triggers an instant Telegram notification and updates the baseline. --------------------------------------------------- 2. Complete Python Percentage Alert Script Open your terminal or development environme...

​Hands-On Guide: Building a Telegram Bot Command Listener in Python

 While receiving automated alerts on Telegram is great, being able to send commands *back* to your mobile scripts takes your automation to the next level. Imagine checking your account balance or stopping a running market scanner simply by typing a quick command inside your Telegram chat. In this hands-on tutorial, we will build a lightweight Python command listener using long-polling to control background scripts remotely. --------------------------------------------------- 1. How Telegram Long-Polling Works Instead of requiring a complex webhook server with a public IP address (which can be difficult to set up on a mobile device), our script uses a simple polling loop. It repeatedly asks Telegram’s servers if any new messages have arrived, parses the text command, and executes matching actions. --------------------------------------------------- 2. Complete Python Telegram Command Listener Script Open Termux or your preferred environment, create a new file named bot_listener.py, ...

​Hands-On Guide: Implementing Multi-Timeframe Trend Filters in

 Taking trades based purely on a single lower timeframe chart often leads to false breakouts caused by noisy market fluctuations. Professional algorithmic traders filter out bad signals by aligning their trades with the dominant trend of a higher timeframe (such as checking an H4 trend while trading on an M15 chart). In this hands-on tutorial, we will add a multi-timeframe Moving Average trend filter to our MQL5 Expert Advisor. --------------------------------------------------- 1. Why Multi-Timeframe Analysis Matters By verifying the broader market direction before executing a lower timeframe entry: • You prevent your EA from buying into a major downward trend or selling into a strong upward surge. • You drastically improve win rates by trading in harmony with institutional momentum. • It acts as an automatic filter during messy, choppy consolidation phases. --------------------------------------------------- 2. Implementing Higher Timeframe Checks in MQL5 Open your Expert Advisor...

​Hands-On Guide: Calculating Dynamic Lot Sizes Based on Account Equity in

One of the most dangerous mistakes beginner algorithmic traders make is hardcoding a fixed lot size (like 0.10 or 1.0) into their Expert Advisors. If your account equity changes or market volatility spikes, fixed lot sizing can expose your portfolio to uncontrolled drawdowns. Professional EAs calculate trade volume dynamically based on your account balance and a fixed risk percentage per trade. In this hands-on tutorial, we will build a dynamic lot-sizing function in MQL5 that calculates optimal trade volume based on your Stop Loss distance. --------------------------------------------------- 1. The Math Behind Risk-Based Lot Sizing To calculate safe position sizes automatically, our function accounts for three variables: • Account Equity: Total funds currently available in your trading account. • Risk Percentage: The maximum percentage of your equity you are willing to lose on a single trade (e.g., 1%). • Stop Loss Distance: The distance in points between your entry price and your Sto...

​Hands-On Guide: Exporting Python Market Data to CSV Files for Analysis

When running automated market scanners or price trackers, viewing terminal output in real time is helpful, but preserving that data for historical review, spreadsheet analysis, or offline testing is even better. Python's built-in CSV module allows you to save polled price data directly to structured files on your mobile device. In this hands-on tutorial, we will build a lightweight Python script that logs polled market metrics into a local CSV spreadsheet. --------------------------------------------------- 1. Why Store Data in CSV Format? Comma-Separated Values (CSV) is a universal data format. By saving your script's output to a CSV file: • You can transfer the log files easily to a desktop spreadsheet program (like Microsoft Excel or Google Sheets) for charting. • You maintain an offline historical record of market movements captured during your mobile scanner runs. • It requires zero external database setup, making it lightweight enough to run smoothly in Termux. ----------...