Поиск условий входа в рынок с помощью поддержки, сопротивления и ценового действия – [PRO VSA EA] Best Forex Expert Advisors 2018

Поиск условий входа в рынок с помощью поддержки, сопротивления и ценового действия

content

introduction

describes the methodology of trade the Forex and commodity markets, as well as on the stock market. In addition, it contains examples of MQL4 code that you can use when you create an adviser working on the described principles.

the key components of the system are price action (price action) and identifying support and resistance levels. From these components completely up to the entrance to the market. It also explains the essence of control price levels (reference price levels) and discusses effective ways to identify them. MQL4 code examples contain options to minimize the risk. The risk is reduced due to the fact that output levels, as well as stop levels are located relatively close to the entry points.

methodology provides the added benefit of allowing a larger volume of transactions regardless of account size. Finally, this article describes the ways to define target levels of profit with the relevant MQL4 code needed for an effective exit in different conditions.

1. Support and resistance

looking at any price chart (regardless of the market or the timeframe) you make sure of two things. Firstly, the market price never lingers at the same level for a long time. After a while, you will see that it has changed much. Any price on the chart can be used as a monitoring level.

However, some prices are, as such, are more efficient than other. We will return to this topic below. Secondly, on any chart is the price at which the market trend changes. Price may relate to a certain level several times and come back almost immediately. This support and resistance levels, familiar to any trader. Support-this is the level below which the price falls. Resistance is a price level above which does not grow.

these levels are also known as peaks and troughs (tops and bottoms). Probability of trend reversal when they touch the price is particularly high, which makes them ideal candidates for the role of reference levels. Level, located about halfway between support and resistance, can also be used as a checklist. Call it middle level (midpoints).

at any point you can select graphics support, resistance and middle level (fig. 1).

fig. 1. Support, resistance and middle level

Figure. 1. Support, resistance and middle level

Lower purple line indicates the level of support at a price $1.09838. The top red line indicates the resistance at 1.10257.

the black line on the 1.10048 is the middle level. The exact definition of “support” and “resistance” is subjective and depends upon your rules for market entry and exit. You can open a position at a specific price or at a certain price range. It all depends on your trading style and goals.

Accordingly, the distance between the support and resistance levels can vary, because they are exclusively used for determining the conditions of entry into the market.

Figure. 2. Price support and resistance ranges

Figure. 2. Price support and resistance ranges

in Fig. 2 presents four different support and resistance range at minute chart.

some of them wider, some already. As already mentioned, the price levels stand out subjective. But the principle is always the same — on the peaks and cavities (as well as halfway between) short-term trends.

figures 3-6 support and resistance ranges are presented long and short time periods on minute charts.

Figures 3 and 4 show the bull market, figures 5 and 6 is bearish.

Figure. 3. wide bull market

Figure. 3. wide bull market

Figure. 4. Narrow bull market

Figure. 4. Narrow bull market

Figure. 5. A broad bear market

Figure. 5. A broad bear market

Figure. 6. A narrow bear market

Figure. 6. A narrow bear market

these monitoring price levels constitute areas where the expected price effect of certain types. The emergence of such price action on the chart indicates the suitable moment to trade.

2. The search for effective market entry conditions on the price action

there are many double candlestick patterns (patterns) that can be used as effective for transactions. In this article we will describe three of them. Track these patterns must be near target levels of support and resistance. All examples are provided using minute candles. We use this timeframe, since the system implies a precise definition of entry points and the short distance to the stop-loss.

each of the three described patterns consists of two minute candles. When one of these models appears near the control price level (support, resistance, or median), market entry occurs strictly on the costs of opening the next (third) minute candle. Examples are listed after the description of each of the patterns.

1 Pattern consists of candle, one of the shadows which is longer than the body, and the second candlestick which closes beyond the first away from the shadow of the first candle. Under the shade refers to the vertical line indicating the price range between the maximum and the price of opening/closing of the candle (the upper shadow) or between the minimum price and opening/closing (shadow). First candle pattern can be a doji (Doji).

Figure. 7. The bullish pattern 1

Figure. 7. The bullish pattern 1

Figure. 8. Medvezhiy pattern 1

Figure. 8. Medvezhiy pattern 1

Figure 7 depicts a bullish pattern in Figure 8 is bearish.

These patterns are similar to model svechnuju “Hammer,” but they are not specific, because pattern can contain any combination of ascending or descending candles, as well as a doji.

in Figure 9 shows the bullish trend, starting with the specified pattern.

Figure. 9. The bullish trend

Figure. 9. The bullish trend

2 Pattern consists of two candlesticks with approximately equal in length.

Body both candles also have roughly similar opening and closing prices. As the length of the body, and prices do not necessarily have to match exactly. Bearish pattern of this type is shown in Figure 1. 10, Bull is in Figure 1. 11.

this type of Pattern is called “Tweezer”. Figure 12 shows a bearish trend, beginning with the model “Tweezers”.

Figure. 10. Medvezhiy pattern 2

Figure. 10. Medvezhiy pattern 2

Figure. 11. Bullish pattern 2

Figure. 11. Bullish pattern 2

Figure. 12. The bearish trend

Figure. 12. The bearish trend

3 Pattern is more common, as the first of its candles can be any, and the second is closed beyond the first. Figure 13 shows a bullish pattern in Figure 14 is bearish.

figure 15 shows the bullish trend, starting with the specified pattern.

Figure. 13. Bullish pattern 3

Figure. 13. Bullish pattern 3

Figure. 14. Medvezhiy 3 pattern

Figure. 14. Medvezhiy 3 pattern

Figure. 15. The bullish trend

Figure. 15. The bullish trend

when searching for these patterns for entering a position must take into account the distance between the potential entry price and immediate supervisory level of support or resistance. If the entry price is too far from the control level, from opening a position better to refrain, regardless of the pattern.

as mentioned, the entrance in the market occurs immediately when you see the next (third) minute candle. More such behavior is explained in the next section on the corresponding MQL4 code. Because in our case the price action is a key element in determining the conditions of entry into the market for open positions always uses market orders rather than deferred.

3. Mql4 code to set the conditions for the entry price action

now, when we describe the methodology for market entry, it is time to review the code to implement it.

the following code blocks can be used while developing expert advisors, based on price action and support/resistance levels. First, you must define variables. Some of them must consist of recent opening, closing prices, as well as the minimum and maximum prices for minute candlelight. Each of these four prices are determined at the current minute candle, as well as on the previous two using iOpen (), (), iHigh iLow () and iClose ().

because we are looking for a pattern of two fully formed candles, candle, appeared for two minutes before the current one, will be the first candle pattern (for example, left a candle on fig. 7). Let’s call such a candle Candle1. Accordingly, the next candle will be called Candle2 (right candle in Fig. 7).

the current candle (right from Candle2) is denoted as Candle3. Price action is tracked in real time, and EA should always follow the current and previous two candles.

double O1 =by NormalizeDouble (iOpen (SymbolPERIOD_M12),4);

the above code defines Candle1 opening price.

because the variable is expressed a fraction, the double data type is used. “O1” indicates the opening price of the first candlestick pattern. Data is provided using the iOpen (), while the Symbol () is used as the first parameter to work with the symbol of the current chart.

PERIOD_M1 indicates the minute timeframe, and the last parameter (in this case, equal 2) defines the offset from the current candle. A value of 0 would mean the current candle, 1 — previous and 2 — a candle before two subsequent.

O1 H1, L1 and C1 shall mean, respectively, the opening price (Open), high (High) and low (Low) and close (Close) candle Candle1. O2, H2, O3, C2 and L2, L3, C3, H3, mean the same thing in relation to candlesticks and Candle2 Candle3.

the following is an example of defining data variables.

double O1 =by NormalizeDouble (iOpen (SymbolPERIOD_M12),4);
 double H1 =by NormalizeDouble (iHigh (SymbolPERIOD_M12),4);
double L1 = NormalizeDouble(iLow (SymbolPERIOD_M12),4);
 double C1 =by NormalizeDouble (iClose (SymbolPERIOD_M12),4);

double O2 =by NormalizeDouble (iOpen (SymbolPERIOD_M11),4);
 double H2 =by NormalizeDouble (iHigh (SymbolPERIOD_M11),4);
double L2 = NormalizeDouble(iLow (SymbolPERIOD_M11),4);
double C2 =by NormalizeDouble (iClose (SymbolPERIOD_M11),4);

double O3 =by NormalizeDouble (iOpen (SymbolPERIOD_M10),4);
 double H3 =by NormalizeDouble (iHigh (SymbolPERIOD_M10),4);
double L3 = NormalizeDouble(iLow (SymbolPERIOD_M10),4);
 double C3 =by NormalizeDouble (iClose (SymbolPERIOD_M10),4);

now it is the turn of conditional expressions, particularly those that track the emergence of one of the three kinds of patterns.

1 Pattern, shown in Figure 7, is deemed to be established if the following expression is true.

if(C1 > = O1 & & L1 < O1 && ((O1-L1)>(C1-O1)) & & C2 > = O2 & & C2 > H1 & & L2 > L1)

this pattern requires adherence to six conditions. The first C1 > = O1, establishes that should be bubbling Candle1 candle or its opening price must be equal to the closing price. L1 < O1 stipulates that price minimum Candle1 must be below the opening price. The following condition States that the difference between the opening price and the minimum price it Candle1 exceed price difference Candle1 closing and opening. In other words, lower shadow Candle1 must be longer than the body.

the fourth condition — closing price Candle2 exceed or equal the opening price. C2 > H1 requires Candle2 closed above maximum Candle1. And last, the minimum must be above a minimum Candle2 Candle1.

when all of these conditions is considered 1 pattern formed, so the following code opens a buy order.

the order has a volume of 0.1, 5 slippage, stoploss is 10 pipsam below the Bid price and take profit at 50 pips above the Bid price.

 
 if(C1 > = O1 & & L1 < O1 && ((O1-L1)>(C1-O1)) & & C2 > = O2 & & C2 > H1 & & L2 > L1) { 
   OrderSend(Symbol(), OP_BUY,0.1 Ask5Bid

10*PointBid + 50*Point);
   return;
  }

for opening of an order for sale conditions must be changed to match the bear pattern similar to that depicted in Figure 8. The ordersend() function parameters will also differ accordingly.

the necessary code snippet is shown below:

 
 if(C1 <= O1 && H1 > O1 & & ((H1-O1) > (O1-C1)) & & C2 < = O2 & & C2 < L1 & & H2 < H1) { 
   OrderSend(Symbol(), OP_SELL,Bid5+ Ask 10*PointAsk-50*Point);
   return;
  }

a similar code will be used for placing orders with the emergence of Patterns 2 and 3.

Bullish pattern 2 (“tweezers”) has the following conditions:

 
 if(C1 < O1 && C2 > O2 & & ((O1-C1) > (H1-O1)) & & ((O1-C1) > (C1-L1)) & & ((C2-O2) > (H2-C2)) & & ((C2-O2) > (O2-L2)) & & O2 <= C1 && O2 >= L1 & & C2 > = O1 & & C2 < = H1) { 
   Orde rSend(Symbol(), OP_BUY,0.1 Ask5Bid-10*PointBid + 50*Point);
   return;
  }

code bearish pattern 2:

 
 if(C1 > O1 & & C2 < O2 && ((C1-O1)>(H1-C1)) & & ((C1-O1) > (O1-L1)) & & ((O2-C2) > (H2-O2)) & & ((O2-C2) > (C2-L2)) & & O2 = C1 > & & O2 < = H1 & & C2 <= O1 && C2 >= L1) { 
   (OrderSendSymbol(), OP_SELL,0.1-Bid,5+ Ask 10*PointAsk-50*Point)
   return;
  }

Finally, pattern 3 requires compliance with the following conditions for buying and selling respectively:

 
 if(C1 > O1 & & ((C2-O2) > = (H2-C2)) & & C2 > O2 & & C2 > C1) { 
   OrderSend(Symbol() , OP_BUY,0.1 Ask5Bid-10*PointBid + 50*Point);
   return;
  }

 
 if(C1 < O1 && ((O2-C2)>= (C2-L2)) & & C2 < O2 & & C2 < C1) { 
   OrderSend(Symbol(), OP_SELL,0.1-Bid,5+ Ask 10*PointAsk-50*Point)
   return;
  }

some options orders, such as stop-loss and take-profit, can also be set as variables, rather than explicitly declared, as in the examples above.

4. The combination of support and resistance with price action

now it’s time to merge the code price action with an additional code, tracking monitoring support and resistance levels.

Adviser waits until price does not reach a certain level. Once the level is reached, the Adviser keeps track of types of price action, submitted patterns 1-3. It can be detected all three pattern, bullish or bearish, or only one, or some small number. The following code uses two variables, to check whether the price has reached a certain level. In this case, it is 1.09000 for EURUSD.

for this example describes a situation when the EURUSD trading below 1.09000 in the moment of triggering code.

 ref double=1.09000;
int refhit =0;

if(O2 < ref & & C3 > = ref) {refhit =1;
   return;
  } 

ref Variable denotes a tracked benchmark price level (support, resistance, or median). Refhit variable describes the current state of the market (whether controlling price level or not). Refhit can be set to 0 or 1. The default value of 0 means that control the price level has not been achieved.

under the conditions these variables monitor touch price control level. Add the specified variables to the code described above the price action.

the example EURUSD variables will track 3-tier pattern bovine overcoming 1.09000.

after adding variables 3 pattern looks like this:

  if (refhit ==1 & & C1 > O1 & & ((C2-O2) > = (H2-C2)) & & C2 > O2 & & C2 C1 > & & C1 > ref & & C2 > ref) { 
   (OrderSendSymbol(), OP_BUY,0.1 Ask5Bid-10*PointBid + 50*Point);
   return;
  }

an additional condition refhit = 1 requires that the price has reached or broke the level specified by the variable ref. In this case, 1.09000. Remember that the market is trading below the level of 1.09000 to his achievements. Two new added conditions require that both candles 3 pattern, closed above ref variable equal to 1.09000.

Figure 16 shows the short-term trading range for EURUSD, consisting of support (1.07660) and resistance (1.07841).

Figure. 16. EURUSD

Figure. 16. EURUSD

at the far right of the screenshot you can see that the market is trading almost exactly midway between the two levels.

the Adviser will consider buying near the level of support (1.07660). As price did not always reach the resistance or support, the EA can use and nearby levels.

in this case, as an additional level of control supports 1.07690 (level 3 PIP spread exceeding support). Advisor monitors the emergence of bullish patterns 1-3.

double O1 =by NormalizeDouble (iOpen (SymbolPERIOD_M12),4);
 double H1 =by NormalizeDouble (iHigh (SymbolPERIOD_M12),4);
double L1 = NormalizeDouble(iLow (SymbolPERIOD_M12),4);
 double C1 =by NormalizeDouble (iClose (SymbolPERIOD_M12),4);

double O2 =by NormalizeDouble (iOpen (SymbolPERIOD_M11),4);
 double H2 =by NormalizeDouble (iHigh (SymbolPERIOD_M11),4);
double L2 = NormalizeDouble(iLow (SymbolPERIOD_M11),4);
double C2 =by NormalizeDouble (iClose (SymbolPERIOD_M11),4);

double O3 =by NormalizeDouble (iOpen (SymbolPERIOD_M10),4);
 double H3 =by NormalizeDouble (iHigh (SymbolPERIOD_M10),4);
double L3 = NormalizeDouble(iLow (SymbolPERIOD_M10),4);
 double C3 =by NormalizeDouble (iClose (SymbolPERIOD_M10),4);

double ref =1.07690;
int refhit =0;


 int start() {
 
 if(O2 < ref && C3>= ref) {refhit =1;
   return;
  } 
 
 if(refhit =1 & & C1 > = O1 & & L1 < O1 && ((O1-L1)>(C1-O1)) & & C2 > = O2 & & C2 > H1 & & L2 > L1 & & C1 > ref & & C2 > ref) { 
   OrderSend(Symbol(), OP_BUY,0.1Ask 5Bid-10*PointBid + 100*Point);
   return;
  }
 
 if(refhit =1 & & C1 < O1 && C2 > O2 & & ((O1-C1) > (H1-O1)) & & ((O1-C1) > (C1-L1)) & & ((C2-O2) > (H2-C2)) & & ((C2-O2) > (O2-L2)) & & O2 <= C1 && O2 >= L1 & & C2 > = O1 & & C2 <= H1 && C1 > ref & & C2 > ref) { 
   OrderSend(Symbol(), OP_BUY,0.1 Ask5Bid-10*PointBid + 100*Point);
   return;
  }
 
 if(refhit =1 & & C1 > O1 & & ((C2-O2) > = (H2-C2)) & & C2 > O2 & & C2 C1 > & & C1 > ref & & C2 > ref) { 
   OrderSend(Symbol(), OP_BUY,0.1

, Ask,5Bid-10*PointBid + 100*Point);
   return;
  }
 
return;
}

Figure. 17. EURUSD Reversal

Figure. 17. EURUSD Reversal

Figure. 18. Entry on EURUSD

Figure. 18. Entry on EURUSD

Figure. 19. Exit on EURUSD

Figure. 19. Exit on EURUSD

all codes bullish patterns call for the achievement of market 1.07690 and closing level candles and Candle1 Candle2 above it.

takeprofit levels were doubled compared to the previous examples. Figure. 17 indicates that the market turned down, briefly broke the 1.07690 level and reached 1.07670 before you turn up. As a result, the variable refhit has become equal to 1.

soon after turning up 3 pattern has emerged. 1.07740 level was opened buy position, as shown in Figure 1. 18. (at the opening Bid price was 1.07720 Candle3. Taking into account slippage allowed 5, a warrant was executed at a price 1.07740.) as you can see in Figure 19, from that moment began a strong bullish trend. Stop-loss level was not activated, the position was closed to take profit at the level of 1.08740.

Conclusion

as can be seen from the examples, the use of price action, together with support and resistance levels can be extremely effective in determining the conditions of entry.

Powered MQL4 code, of course, is not complete and only aims to simplify the creation of a full-fledged Adviser. The main purpose of the article was describing the trading methodology. Other patterns of price action can also be turned into code and implemented in the composition of the expert advisor. Good luck in all your shopping endeavors!

translation from English is produced by MetaQuotes Software Corp.
the original article: https://www.mql5.com/en/articles/1734

Leave a comment