Thursday, May 26, 2011

Stoploss - ceiling price of the day

Good day dear readers! Today we will write a very interesting expert. His algorithm is based on time, is more accurate in trading sessions.
17.1 Algorithm

Not presented a reader sent me the following numbers and ask them the discretion to write expert.


So we'll try it to describe words.

Entry into debt. The cost of opening day is less than the ceiling price for that period, the ceiling price is reached for the Asian session. The floor price for the period was made for the European session, and it is lower than the cost of opening. Admission is conducted in early U.S. session break of as much as possible the price. Stoploss-a floor price of day.

Condition for entry into the blinkers. The cost of opening day is greater than a floor price for the period, scored for the Asian session. The ceiling price for the period was made for the European session, and it is higher than the cost of opening. Admission is conducted in early U.S. session, the breakdown of the achieved minimum price. Stoploss - ceiling price of the day.

Time of entry in hours during the MT, is available for regulation (in an external variable).

The specific goal of us is not present, so we will get banal trejlingstopom. Since we will simply draw in stoploss in already made a profit.

Here is a basic algorithm turned out. It can be complicated strong, but I did not put this purpose by those who will interest, will have such an opportunity.
17.2 Expert


/ * [[
Name: = Sessiy
Author: = forextimes.ru
Link: = www. Fxtest.ru
Many: = 1.00
Stop Loss: = 0
Take Profit: = 1000
Trailing Stop: = 30
]] * /





Define: USAhour (13), / / ��time that we accept the early U.S. session,
/ / T.e start trading
var: CNT (0) I (0), MaxH (0), MinL (0), OP (0), MaxHi (0), MinLi (0);

If h = USAhour and TotalTrades = 0, then
{/ * If the time has come to the U.S. session
and open positions are not present, but it began: * /
op = o [USAhour] / * so we determine the cost of opening day
te price of the opening of GMT in 0 * /
MaxH = h [1]; / * is not primarily a ceiling price of the day we accept ceiling
last price bar * /
MinL = L [1]; / * is not primarily for a floor price of the day we accept a floor
price in the last bar * /

for i = 1 USAhour DownTo
{/ / The cycle we are realistic minimum and highest prices of the period

if h [i]> MaxH then
{MaxH = h [i]; MaxHi = i;
}, / * The variable MaxH will put a ceiling price in its index MaxHi

if l [i] <MinL then
{MinL = l [i]; MinLi = i;
}, / * The variable MinL put floor price, MinLi its index * /

if op> MinL and
MinLi <(USAhour-1) and
MinLi> (USAhour-6) and
hour <19 and
proposal <MinL then
{SetOrder (op_sell, lots, bid, 3, MaxH +5 * point
Ask-takeprofit * point, red);
exit;
};

if op <MaxH and
MaxH <(USAhour-1) and
MaxHi> (USAhour-6) and
hour <19 and
Ask> MaxH then
{SetOrder (op_buy, very, ask, 3, MinL, service + * takeprofit point, blue);
exit;
};

/ * Do a check on the conditions of entry above statements
More detailed conditions above * /
};

for CNT = 1 TotalTrades
begin
/ * What is long position? * /
If the word (CNT, VAL_TYPE) = OP_BUY then / * of a long position * /
{
/ * Is this transaction profit of more than level trejling
stop? We check the purchase offer as position * /
If (Bid-ORD (CNT, VAL_OPENPRICE))> (TrailingStop * Point) then
{
/ * Iiceoey profit has more than worth trejling stop, whether it
possible to put a stop better than it was before? * /
If the word (CNT, VAL_STOPLOSS) <(Bid-TrailingStop * Point) then
{
/ * We changed the stoploss level supply-Trailing Stop * /
ModifyOrder (ORD (CNT, VAL_TICKET), word (CNT, VAL_OPENPRICE),
Bid-TrailingStop * Point, ORD (CNT, VAL_TAKEPROFIT), red);
Exit;
};
};
}, / * Not a short position? * /
If the word (CNT, VAL_TYPE) = OP_SELL then
{Do / * is the profit of this transaction more than level
trejling stop? Ask how we check the position of Sales * /
If (ORD (CNT, VAL_OPENPRICE)-Ask)> (TrailingStop * Point) then
{/ * The position has profit more than worth trejling stop,
Is it possible to put a stop better than it was
earlier? * /
If the word (CNT, VAL_STOPLOSS)> (Ask + TrailingStop * Point) or
Word (CNT, VAL_STOPLOSS) = 0, then
{/ * We changed stoploss level for Ask + Trailing Stop * /
ModifyOrder (ORD (CNT, VAL_TICKET), word (CNT, VAL_OPENPRICE),
Ask + TrailingStop * Point, ORD (CNT, VAL_TAKEPROFIT), red);
Exit;
};
};
};
end;

17.3 Conclusion


The testing histories of the picture turns out, quite well. But is it a bit, though. First, 40 transactions for 1 year and 3 months, certainly not enough and everyone did not apply filters. Second, this year and 3 months of history have a strong upward trend, so it is more expedient to consider only short positions.

No comments:

Post a Comment

Powered by Blogger.