Mastering Open Close Strategy with MetaTrader 5: Your Go-To EA Guide

Mike 2018.11.20 21:45 17 0 0
Attachments

Meet the Minds Behind the Tool

The brilliant mind behind this concept is Ilnaz, while the coding wizard is barabashkakvn.

This Expert Advisor (EA) is designed to analyze the first two candles in the market for trading signals.

How to Open and Close Trades: A Quick Example for SELL

Let’s break down the conditions for opening a trade. First and foremost, ensure you have no open positions in the market.

      //--- buy
      if((rates[1].open>rates[2].open) && (rates[1].close<rates[2].close))
        {
         double lot=TradeSizeOptimized();
         OpenBuy(lot,0.0,0.0);
         return;
        }
      //--- sell
      if((rates[1].open<rates[2].open) && (rates[1].close>rates[2].close))
        {
         double lot=TradeSizeOptimized();
         OpenSell(lot,0.0,0.0);
         return;
        }

If you do have an open position, it's crucial to check the closing conditions.

      if(rates[1].open<rates[2].open && (rates[1].close<rates[2].close))
        {
         ClosePositions(POSITION_TYPE_BUY);
         return;
        }
      if(rates[1].open>rates[2].open && (rates[1].close>rates[2].close))
        {
         ClosePositions(POSITION_TYPE_SELL);
         return;
        }
List
Comments 0