trading strategy heads or tails
Info
The trading strategy heads or tails is a Expert Advisor for MetaTrader 5 that the trading strategy “head or tail” belongs to the category of high-risk short-term trading approaches, primarily used on the stock market and forex. its name is due to the randomness of decision-making, similar to flipping a coin (“heads” — buy an asset, “tails” — sell).
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 trading strategy heads or tails
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 trading strategy “head or tail” belongs to the category of high-risk short-term trading approaches, primarily used on the stock market and forex.
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: Interactive Chart Trading Panel with Risk Management for MT5 - another powerful expert for MetaTrader 5 traders.
Also recommended: Trading Panel EA - Enhanced Trade Management - similar expert with strong performance on MetaTrader 5.
the trading strategy “head or tail” belongs to the category of high-risk short-term trading approaches, primarily used on the stock market and forex. its name is due to the randomness of decision-making, similar to flipping a coin (“heads” — buy an asset, “tails” — sell). this strategy is based solely on intuitive decisions or random signals and ignores fundamental market analysis factors.
how does the strategy work?
the strategy operates as follows:
instrument selection: the trader chooses a financial instrument (stock, currency, commodity).
decision-making: the decision to buy or sell is made randomly, for example, by flipping a coin or using another method to choose between two possible actions.
trade closure: the trade is automatically closed after a predetermined time or when a certain profit or loss level is reached.
this strategy does not require a deep understanding of market mechanisms and analytics, but it also does not involve a serious approach to risk management.
disadvantages of the strategy:
high risk level:
relying solely on luck significantly increases the probability of losses. the strategy ignores any objective indicators and recommendations, increasing the chances of capital loss.
lack of risk control:
since buying or selling occurs randomly, there is no possibility of rational capital management, risk assessment, or asset allocation.
impossibility of long-term success:
even if individual trades are profitable due to luck, in the long term, this strategy is more likely to lead to significant losses.
short-lived results:
positive outcomes are possible only under favorable market conditions and with a large number of small successful trades, which is rarely encountered in practice.
application of the strategy:
this strategy is more suitable for beginners who want to familiarize themselves with the principles of exchange platforms and try trading without deep knowledge of technical analysis. however, professionals rarely use this strategy, preferring scientifically based approaches that take into account price behavior, trading volume, and fundamental company indicators.
for experienced investors, this strategy represents more of an experimental method for testing hypotheses rather than a stable way to earn money.
thus, although the strategy is simple and accessible to every beginner, it carries significant risks and has almost no chance of providing stable income in the long term.
let's examine the main block of the random position opening signal:
if
((b + s) ==
0
)
// if there are no active positions
here, the condition checks for the absence of open positions. variable b represents the number of long ("buy") positions, and variable s represents the number of short ("sell") positions. if the sum of both is zero (b + s = 0), it means there are no open positions.
if
(::
mathrand
() %
2
==
0
)
// randomly choosing the direction of opening a position
inside the previous block, a random number is checked. the function
::mathrand()
generates a pseudo-random number from 0 to 32767 inclusive. this number is then divided by 2 (% 2) — if the remainder is 0, the next block is executed.
{ if
(trade.buy(lt))
// opening a long position (buy)
return
;
// terminating function execution
}
if the random number is even (remainder of division by 2 is 0), the trading robot opens a long position (purchase) with a volume of ilots. after successfully opening the position, the function execution is interrupted by the return operator.
else
// otherwise...
if
(trade.sell(lt))
// opening a short position (sell)
return
;
// terminating function execution
if the random number was odd (remainder of division by 2 is not zero), a short position (sale) with a volume of ilots is opened, and further execution of the function is also terminated.
final logic of the fragment:
it checks whether the trader has any open positions.
if there are no open positions, a random direction for the trade is chosen: either a purchase (long) or a sale (short).
the opened trade automatically stops further execution of the function.
thus, this code represents the simplest example of an algorithm that makes a decision to open a position on the market randomly.
for a detailed line-by-line analysis of the code, you can visit the blog post:
You may also like: Blue Moon EA: Advanced EMA Envelope Trading for MT5 - excellent alternative for expert users on MetaTrader 5.
Source Code
яю//+------------------------------------------------------------------+
#property copyright "RobotFX"
#property link "https://robotfx.org"
#property version "26.010" // Program version
#include <Trade\Trade.mqh> // Including Trade.mqh library
CTrade trade; // Object of class CTrade to manage trades
#include <Trade\PositionInfo.mqh> // Including PositionInfo.mqh library
CPositionInfo posit; // Object of class CPositionInfo to process positions
input double iLots = 0.01; // Input parameter for lot size (trade volume)
input int iTakeProfit = 450; // Input parameter for profit fixing level (Take Profit)
.......
⚠ 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.