Thursday, May 26, 2011

Bid-TrailingStop

Hello dear readers. I got some algorithms of experts in the following editions I will always exercise some of them. In the same message, I'd like to talk about parts of the initial code which are identical in all experts. Someone will say that every individual is an expert, someone that in all this is very general, but true, that some moments absolutely identical. It's free check marzhi, restricting trade expert time (trading sessions or limit in days of the week), trejlingstop, etc. For these fragments of code experts, also has speech.

15.1 Limitation DTS
For the work of experts in DTS limitations 2, this limitation is not particularly experts, and in general to work through the DTS is more precise.
1st Restrictions on free marzhu: If FreeMargin <1000 then Exit;
2nd 10 second tajmaut, after opening the position: if ((CurTime-LastTradeTime) <10
15.2 Possible checks
At the beginning of an expert it is possible to do check
1st Correct exposure stops If StopLoss <10 * point or StopLoss> 100 * then exit point;
2nd Check the quantity of bars of history (as a test of history) If Bars <200 then exit;
3rd To play one position it is possible to use the design of a kind If TotalTrades <1, then {Or if TotalTrades = 1 then exit;
4th For starters trejlinga If TrailingStop> 0, then {
15.3 Checks and limitations of time
Sometimes it is necessary to test an expert in any certain intervals of history, conditions may look as follows:
If Year <> 2003 Then Exit; With this limitation, testing expert will take place only in 2003
If Volume> = 2004 and Month> 2 then exit; testing experts before a certain date, in this case by the end of February 2004.
Terms of checks on time of day.

If Hour <10 h or> 19 then exit; trade will be made with an interval of 10 to 19 during the MT.
If minute = 10 then {action came 10 minutes every hour during the MT.
If Seconds = 10 then {is the same in seconds.
As in MT is possible to do the test of time during the day, for this purpose, a function on Sunday. It can accept values ��from 1 to 7, according to the days of the week, only the numbering starts with the revival. That is 1 week, 2-Monday, etc.
If DayOfWeek = 3 Then exit; Expert will not work on Tuesday.
15,4 Trejlingstopy
Certainly it makes no sense to write new trejlingstop for each expert, can be inserted in the code of an expert as requested.

If TrailingStop> 0, then
{
for CNT = 1 TotalTrades
begin
/ * If a long position? * /
If the word (CNT, VAL_TYPE) = OP_BUY then / * of a long position * /
{
If / * is the profit of this transaction more than
level trejling stop? * /
If (Bid-ORD (CNT, VAL_OPENPRICE))> (TrailingStop * Point) then
{
/ * The position has a profit of more value to stop trejling
Then check whether it is possible to prepare the station? * /
If the word (CNT, VAL_STOPLOSS) <(Bid-TrailingStop * Point) then
{
/ * IIA? Eiaai noiieinn Acting Bid-Trailing Stop * /
ModifyOrder (ORD (CNT, VAL_TICKET), word (CNT, VAL_OPENPRICE),
Bid-TrailingStop * Point, ORD (CNT, VAL_TAKEPROFIT), red);
Exit;
};
};
};
/ * Yoi EI? Ioeay iiceoey? * /
If the word (CNT, VAL_TYPE) = OP_SELL then
{
/ * Anou ee i? Ioeo o yoie naaeee aieuoa? Acting
o? iaaiu o? aeeeia noiia? * /
If (ORD (CNT, VAL_OPENPRICE)-Ask)> (TrailingStop * Point) then
{
/ * The position has a profit of more value to stop trejling
Then check whether it is possible to prepare the station? * /
If the word (CNT, VAL_STOPLOSS)> (Ask + TrailingStop * Point) or
Word (CNT, VAL_STOPLOSS) = 0, then
{
/ * We draw in noiieinn * /
ModifyOrder (ORD (CNT, VAL_TICKET), word (CNT, VAL_OPENPRICE),
Ask + TrailingStop * Point, ORD (CNT, VAL_TAKEPROFIT), red);
Exit;
};
};
};
end;
};

I am convinced that because it will be complex preparations, the process of writing experts can only improve and become a little simpler.
The next release will write an expert or indicator algorithm would seem to me interesting.

No comments:

Post a Comment

Popular Posts

Powered by Blogger.