10.1. Questions from the letter
Letter sent Sergei Matyuha Eugene and his friends, Paul, Andrew and Dmitry from Moscow. I would like again to thank these people for their interest to the magazine, and specifically to the category.
"... 1. As part of the learning of writing experts, indicators and experts working on the basis of indicators is it possible to create such an indicator which would indicate to the results of the expert.
For example, you can be right in the schedule of prices to show the line (line segments) from the opening to the closure order with mixing such as the size of bid or ask them for illustration colored in different colors may be added, and sections StopLoss-s belonging to particular order (just very well have seen purse StopLoss).
2. And in a separate window (not in the schedule of prices) could show the account balance or percentage of profit for example, using histograms, but easily could be identified (for small-scale time-frame) in which periods of trend expert works most effectively.
But I do not know whether it is in principle .... "
Unfortunately this can be done. Custom Indicators are built at once, ie all elements of the array determined by the indicator. A tool built into the MT models pass prices to historical data, to assess the capacity of the MTS. Therefore, the indicator can not be used as a tool for debugging, although of course it would be very convenient. It remains to be satisfied with yield curve. I hope the new version of the MT record of the testing will be increased and introduced new ways of debugging.
/ * [[
Name: = expert10
Author: = forextimes
Link: = fxtest.ru
Lots: = 1.00
Stop Loss: = 20
Take Profit: = 1000
Trailing Stop: = 20
]] * /
var: cnt (0), f1 (0), f (0);
if TotalTrades = 0 then (
if f1 = 0 then (f1 = 1; f = 2; SetOrder (op_buy, lots, ask, 3, bid-stoploss * point, bid + TakeProfit * point, blue); exit;);
if f = 1 then (f = 2; SetOrder (op_buy, lots, ask, 3, bid-stoploss * point, bid + TakeProfit * point, blue); exit;);
if f = 2 then (f = 1; SetOrder (op_sell, lots, bid, 3, ask + stoploss * point, ask-TakeProfit * point, red); exit;);
);
for cnt = 1 to TotalTrades
begin
/ * This is long position? * /
If Ord (cnt, VAL_TYPE) = OP_BUY then / * long position * /
(
/ * First check - is there any profit from this deal more than the trailing stop? check the Bid, as the position BUY * /
If (Bid-Ord (cnt, VAL_OPENPRICE))> (TrailingStop * Point) then
(
/ * Yes, the position has a profit greater than the value of trailing foot (eg 30 points). Now you'll want to check if it's possible to put a stop better than it was before? * /
If Ord (cnt, VAL_STOPLOSS) <(Bid-TrailingStop * Point) then
(
/ * Change the stop-loss at the level of Bid-Trailing Stop * /
ModifyOrder (Ord (cnt, VAL_TICKET), Ord (cnt, VAL_OPENPRICE),
Bid-TrailingStop * Point, Ord (cnt, VAL_TAKEPROFIT), Red);
Exit; / * do it - get out. * /
);
);
);
/ * This is a short position? * /
If Ord (cnt, VAL_TYPE) = OP_SELL then
(
/ * First check - is there any profit from this deal more than the trailing stop? check the Ask, because the position SELL * / If (Ord (cnt, VAL_OPENPRICE)-Ask)> (TrailingStop * Point) then
(
/ * Yes, the position has a profit greater than the value of trailing foot (eg 30 points). Now you'll want to check if it's possible to put a stop better than it was before? * /
If Ord (cnt, VAL_STOPLOSS)> (Ask + TrailingStop * Point) or
Ord (cnt, VAL_STOPLOSS) = 0 then / * sine qua! * /
(
/ * Change to the level of stoploss Ask + Trailing Stop * /
ModifyOrder (Ord (cnt, VAL_TICKET), Ord (cnt, VAL_OPENPRICE), Ask + TrailingStop * Point, Ord (cnt, VAL_TAKEPROFIT), Red);
Exit;
);
);
);
end;
/ * End * /
10.2. The algorithm is an expert
The algorithm was also sent an expert Sergey Matyuhoy. Here it is:
1. Each subsequent order is the opposite direction (when closed it will buy sell and vice versa).
2. Warrants have no TakeProfit-s.
3. Closure is only through StopLoss.
4. StopLoss must be purse.
It requires, I think, only two variables, this value StopLoss and some variable that is determined to step through which to pull StopLoss (I still write about "some" because me and my friends are also working on the FOREX little understood by the example of TrailingStop and the principle of its operation in 6 release, but he could not suited for this purpose). "
The first entry is carried out randomly. In this case the purchase.
if f1 = 0 then (f1 = 1; f = 2; SetOrder (op_buy, lots, ask, 3, bid-stoploss * point, bid + TakeProfit * point, blue); exit;);
Variable f1 is a flag, because it becomes equal to 1 transition on the condition no longer occurs and a random purchase of only 1 time. We must each discover the opposite position from the last, so we have another flag f. If f = 1, the position is long past, when f = 2 is short.
In letters to the authors are having problems with treling footsteps. Perhaps in the past editions of the algorithm, I was given was not clear. In the expert was inserted algorithm trailing foot of the expert
Since in the algorithm, it was pointed out that on take profits should not be, take a profit in your exhibits 1000 points, ie obviously unattainable.
Expert in the first test proved unprofitable, but it may be possible to find the working configuration.
In the next issue we will write a new expert or indicator. If you, dear readers, something interesting, be sure to write.
Company «Fxtest»
Halhalyan Arthur
Technical support for traders
artur@fxtest.ru
Halhalyan Arthur
Technical support for traders
artur@fxtest.ru
No comments:
Post a Comment