Algorithm
Failed to provide a reader sent me the following pictures, and asked for it, at its sole discretion to write expert.
Well try this all the words to describe.
Conditions at the entrance to Long. Price discovery of the day below the maximum price for the period, the maximum price achieved in the Asian session. The minimum price for the period reached for the European session, and below the opening price. Sign implemented at the beginning of the session for the American sample reached the maximum price. Stoploss minimum-price day.
The condition for entry into shorts. Price discovery of the day above the minimum prices for the period reached the Asian session. The maximum price for the period reached for the European session, and it is above the opening price. Sign implemented at the beginning of the session for the American sample reached the lowest price. Stoploss-the maximum price of the day.
Login time in hours for GMT, is available for management (external variable).
Since specific purpose we do not, for the goal we get trite treylingstopom. Since purse will be just under the stoploss already made a profit.
That's the simplest algorithm we have. It can be much harder, but I did not set that goal, because those who are interested in it, will have that opportunity.
Conclusion
When tested on the history of painting is quite good. But there are some but. First 40 transactions for 1 year and 3 months, of course even more so that we are not any filters applied. And secondly for this year and 3 months of history, we have a strong upward trend, It is therefore advisable to take into account only the short position.
/ * [[
Name: = Sessiy
Author: = forextimes.ru
Link: = www.Fxtest.ru
Lots: = 1.00
Stop Loss: = 0
Take Profit: = 1000
Trailing Stop: = 30
]] * /
Define: USAhour (13) / / time for which we take the beginning session of the United States, that is starting to sell
var: cnt (0), i (0), MaxH (0), MinL (0), op (0), MaxHi (0), MinLi (0);
if hour = USAhour and TotalTrades = 0 then (/ / if the time has come, and the U.S. session open positions but there is no beginning.
op = o [USAhour]; / / so define the opening price of the day, ie, price discovery in the 0 to GMT
MaxH = h [1] / / initially for a maximum cost of the day are the maximum price of the last bar
MinL = l [1] / / beginning at the lowest price of the day are the minimum price the last bar
for i = USAhour DownTo 1 (/ / loop searches for the real minimum and maximum prices of period
if h [i]> MaxH then (MaxH = h [i]; MaxHi = i;); / / in variable MaxH put the maximum price at its MaxHi index
if l [i]
(SetOrder (op_buy, lots, ask, 3, MinL, bid + takeprofit * point, blue); exit;);
/ / Above to verify the conditions on entry, on the conditions we have detailed above
);
for cnt = 1 to TotalTrades
begin
/ * This is long position? * /
If Ord (cnt, VAL_TYPE) = OP_BUY then / * long position * /
(
/ * Is there any profit from this deal more than the trailing stop? Checking Bid, as the position BUY * /
If (Bid-Ord (cnt, VAL_OPENPRICE))> (TrailingStop * Point) then
(
/ * position is greater than the value of profit trailing stop, is it possible to put a stop better than it was before? * /
If Ord (cnt, VAL_STOPLOSS) <(Bid-TrailingStop * Point) then ( / * Change the stoploss 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; ); ); ); / * This is a short position? * / If Ord (cnt, VAL_TYPE) = OP_SELL then ( / * Is there any profit from this deal more than the trailing stop? Checking Ask, because the position SELL * / If (Ord (cnt, VAL_OPENPRICE)-Ask)> (TrailingStop * Point) then
(
/ * Position is greater than the value of profit trailing stop, is it 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
(
/ * 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;
No comments:
Post a Comment