Sunday, February 15, 2009

Education MQL II. Lesson 12

Hello dear readers! Today we write the simplest proboynuyu system.



12.1. Algorithm



Probably many of you know what proboynye system. On the market there are times when it is most likely to assume that the price will go sharply up or down. For example, when ranok before leaving the serious news. All players are waiting, and after opening in the desired direction. But since most readers of these lines to receive the news with a delay, it makes sense to arrange deferred warrant of Perforation of current levels of consolidation.



The expert analyzes the maximum and minimum price (the shadows of candles) for a certain period (the period we will be able to customize), and exhibited delayed orders on both sides of the current price. This would warrant the type and . For greater efficiency, we will put a warrant only if the difference between the maximum and minimum price for a specified period of not more than our values (this value determines the width of the channel, news, many are waiting, the narrow channel).



Summarize the algorithm. If there are no open positions and put warrants. Find the maximum and minimum price for the period, calculates the difference between them. If the difference is less than the threshold, we found that 2 exhibits a warrant for the sample. Warrants presents with a small margin, for example, +5 points, though, make this value is also configurable as at different time frames margin will be different. After the operation one of the warrants, the second order is removed.



12.2. Expert

/ * [[

Name: = Proboy

Author: = fxtest.ru

Link: = forextimes.ru

Lots: = 1.00

Stop Loss: = 20

Take Profit: = 40

Trailing Stop: = 0

]] * /

Defines: HL (85), N (9), Zapas (5); / / HL-difference between the extreme prices, N-period, Zapas-supply in the form of deferred warrant

var: s (0), b (0), ho (0), lo (0), i (0), fl (0); / / s-the number of pending OP_sellSTOP b-the number of pending OP_BUYSTOP, i-variable-cycle

/ / Ho-max price period, lo-price period minimalnyya, fl-flag to be placed a second order



If ((CurTime-LastTradeTime) <11) then Exit; / / 10 seconds timeout until it has passed will be implemented by way of expert



if fl = 1 then / / as simultaneously to two orders can not be, OP_sellSTOP placed after 10 seconds, using the flag

(fl = 0, / / reset flag and the 2nd issue of a deferred

SetOrder (OP_sellSTOP, lots, lo-Zapas * point, 3, lo + StopLoss * Point, lo-TakeProfit * Point, red););



b = 0 / / reset variables to account

s = 0;

if TotalTrades = 1 then exit; / / if open, only 1 order that this warrant in the market goes



if totaltrades <> 0 then

for i = 1 to TotalTrades

Begin

IF OrderValue (i, VAL_TYPE) = OP_BUYstop then b = b +1; / / calculate the position in the cycle

if OrderValue (i, VAL_TYPE) = OP_SELLstop then s = s +1;

if (s + b) = 2 then exit; / / if 2 holds exit

end;

if TotalTrades <> 0 and (s + b) = 1 then / / if 1 still pending (it is unnecessary, because one has become played, discard it

(For i = 1 to TotalTrades

Begin

if (OrderValue (i, VAL_TYPE) = OP_sellSTOP) or (OrderValue (i, VAL_TYPE) = OP_buySTOP) then

DeleteOrder (OrderValue (i, VAL_TICKET), blue); / / Remove

end;

exit;);



if TotalTrades = 0 and (b + s) = 0 then (/ / finding the minimum, maximum price

ho = h [1];

lo = l [1];

for i = n DownTo 1

Begin

if h [i]> ho then ho = h [i];

if l [i]
end;

);

if TotalTrades = 0 and (b + s) = 0 and (ho-lo)
/ / Then put 2 orders



fl = 1;

SetOrder (OP_BUYSTOP, lots, ho + Zapas * point, 3, ho-StopLoss * Point, ho + TakeProfit * Point, blue); / / 1st of 2



);



12.3. Conclusion



Since this is the easiest proboyny algorithm, he certainly does not bring a decent profit, but in the nature of such systems exist in more complex ways. It makes sense to engage an expert only at specified times (before the news). You can also impose additional conditions on the length of shadows of candles inside the period, or (and) to control and in volume, but because Forex ticks on the volume, the specific improvements he will not.



The next issue I would like to dedicate your questions. I am sure that during the creation of its own experts you they arise. Please send all questions to me at the mail, I promise to answer all of the next issue.







Company

Halhalyan Arthur

Technical support for traders

artur@fxtest.ru

No comments: