Mastering the Lock Strategy in MetaTrader 5: A Trader's Guide

Mike 2018.06.18 19:22 27 0 0
Attachments

Idea by: Igor.

MQL5 code by: Vladimir Karputov.

Imagine you step into the market with both Buy and Sell positions on an asset, with the currency sitting at 100. As the price climbs to 200, you find that your Buy position at 100 is in the green, while your Sell position is at a loss. By closing your Buy position, you pocket a profit of 100. However, the Sell position shows a loss of 100.

Using a grid trading strategy, your goal is to ensure profitability regardless of market direction. So, let’s say you enter another Buy and Sell transaction as the price dips back down to 100.

This new Sell position nets you +100, but the Buy position results in a -100. According to the rules, you can now close your Sell position, adding another 100 to your account. At this stage, your total profit stands at 200.

Your initial Sell position, which is still active, is now hovering between levels 200 and 100, putting it right at breakeven.

By tallying up the four transactions, you find the profits as follows: +100 from the first Buy, +100 from the second Sell, 0 from the first Sell, and -100 from the second Buy. Overall, you’re sitting pretty with a total profit of +100. Time to clear those orders and maybe treat yourself to a glass of champagne! And remember, for each subsequent double position (opening both Buy and Sell simultaneously), we ramp up the lot size based on Lot Exponential.

There are plenty of market movements that can turn these seemingly convoluted simultaneous buying and selling activities into profitable trades.

However, keep in mind that with this type of trading, there’s always the risk of “hanging” positions—those pesky trades that lead to significant losses and whose opening price is far removed from the current market price. To tackle these “hanging” positions, we’ve introduced two important parameters: Excess of Balance over Equity (when your balance exceeds your Equity) and Minimum Profit.

Always tread carefully, as two scenarios can unfold: the optimistic scenario

Lock Optimistic

and the pessimistic scenario.

Lock is pessimistic


Input Parameters

  • Lots - initial lot size;
  • Take Profit - your target profit point;
  • Lot Exponential - the ratio by which you increase your lot size;
  • Excess of Balance over Equity - when your balance exceeds your Equity;
  • Minimum Profit - the least profit you aim to achieve;
  • Magic Number - a unique identifier for your EA.
List
Comments 0