- Introduction to Opening a Sell Trade in Early MQL5 (00:01 – 00:08) Discussing how to open a sell trade in the early days of MQL5, focusing on the netting mode which allowed only a single position per currency pair.
- Switching to Multiple Positions per Symbol in MQL5 (00:08 – 00:20) Explaining the shift in MQL5 that now allows multiple positions per symbol and the process to do so with a simple expert advisor.
- Creating a Simple Sell Trade Expert Advisor (00:20 – 00:32) Demonstrating how to create a simple sell trade expert advisor, including setting up the basic structure and deleting unnecessary lines.
- Importing MQH File and Setting Up a Sell Trade (00:32 – 00:49) Instructions on importing an MQH file for creating a CTrade object and setting up the parameters for a sell trade.
- Getting Bid Price and Account Details for Entry (00:49 – 01:00) Steps to retrieve the bid price and account details, including balance and equity, to determine the entry point for the trade.
- Executing the Sell Trade with Conditions (01:00 – 01:14) Executing a sell trade with the condition that the equity is equal to or greater than the account balance, using a specific lot size.
- Testing the Expert Advisor in Metatrader Strategy Tester (01:14 – 01:29) Compiling the code and testing the simple sell trade expert advisor in the Metatrader strategy tester for the year 2016.
- Observing the Trading Performance and Results (01:29 – 01:53) Watching the expert advisor trade in fast mode and observing its performance, leading to the conclusion of the test.
- Reviewing the Profit Results of the Test (01:53 – 02:05) Analyzing the results tab to review the total net profit achieved by the expert advisor during the test period.
This is how you would have opened a sell trade in the early days of MQL 5.
This is called the netting mode.
Netting mode means that you could only open a single position for a currency pair.
But now it is possible to have multiple positions per symbol.
So let’s do that was a simple EA!
Click on New, Expert Advisor, call it simple sell trade, continue and delete everything above the OnTick function. You can also delete these two comment lines and the first thing we need to do is to import an MQH file.
We do it with the include command, it’s the trade MQL file and it enables us to create a CTrade with the name trade.
To create a selling position we first need to know about the bit price, and this is how we can get the bit price in MQL 5.
To create an entry we will also need our account balance and the account equity.
And we want to enter a trade if the equity is equal or greater than the account balance.
To do that we will use Trade.Sell, let’s do it for ten micro lot, let’s compile that code.
Bring up the MetaTrader, go to the Strategy Tester and select the simple sell trade ex5 file.
We will trade the whole year 2016, and please enable the visible mode.
Let’s start it and now it starts to trade and if the equity becomes greater than the balance it will open several positions.
Okay I will switch to full speed now, let’s see how it performs.
And now it should be finished soon. Okay this is it.
Let’s click on the results tab as far as it comes up.
Here it is and we made total net profit of eleven thousand, two hundred and fifty seven bucks.