Download Long Short only EA based on CExpert for MetaTrader 5

Long Short only EA based on CExpert

Long Short only EA based on CExpert

This software component for MetaTrader 5 is built to enhance the capabilities of your trading environment. This Expert Advisor serves as automated trading software. It is utilized to monitor financial markets and execute trades based on predefined algorithmic rules, enabling precise position management without the need for constant manual oversight.

MT5 expert Pack 📂

How to Setup and Use Long Short only EA based on CExpert

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.

Description & Settings


Current Expert Advisor allows to choose opening only long/short (or both) positions based on an extension of the class.
Two different files are provided:

LongShortExpertModified.mqh:
This class extends default modifying the CheckOpen() and CheckReverse() methods in order to allow only the desired orders to be opened;

LongShortExpertMACD.mq5:
This EA is a simple modification over the embedded ExpertMACD.mq5 class, including the developed modified expert in order to only allow the desired order type according to an input parameter, and is supplied to clarify the expert use.
LongShortExpertModified
This class modifies the default CExpert class behaviour allowing only a certain type of order according to the following enum:
This enum will be used as an input parameter for the required final EA to determine which type of orders will be allowed, and is used internally to open only the desired orders and to process order reversals only if both position types are allowed (BOTH_POSITION enum value).
To do so, CheckOpen() and CheckReverse() methods are rewritten:
CheckOpen() is modified to only check long or short positions according to m_positions value:
CheckReverse() is modified to check position reversal only if both position types are allowed:
LongShortExpertMACD
This class provides a specific EA example of the previous class use, based on the default ExpertMACD EA included in the MQL5 distribution.
First of all, the concrete Expert class must be included, and the corresponding input parameter added. Also, the external expert is associated with the subclass, instead of the default CExpert:
After initiallizing the expert, the parameter must be set according to the input value:
No additional changes are required. The following figure shows the configuration parameters for the expert:

You May Also Like

RobotFX does not own any of the code provided on this platform. All tools are freely available on the internet; we simply index and re-offer them for download. We are not responsible for any financial losses that may occur. Trading responsibilities rely solely on the traders downloading and using the displayed Expert Advisors, indicators, and scripts. These tools are provided for educational purposes only and may require modification or optimization to align with a trader's specific strategy or needs.
© ROBOTFX - Best MetaTrader Expert Advisors & Indicators