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.
Download “MQL5 Simple Sell Trade Expert Advisor from MQL5 Tutorial”SimpleSellTrade.txt – Downloaded 492 times – 367 B