Thursday, May 26, 2011

positions open for a pair

Hello dear readers. This week for me has come a lot of questions from you, so this lesson will be fully dedicated to answer your questions.
21.1 question-answer

Sirotkin Andrei sent two interesting questions.

... 1st I would want that professional traded on a pair, but could not play another hand. The expert input is performed under condition
If TotalTrades lower than 1, then {
But because I opened the manual position of other pair of entry into the professional can not be done (actually, if TotalTrades = 1) for a pair of which expert is attached.
What is it possible to do? ...

Answer:
/ * [[
Name: = test
Many: = 1.00
Stop Loss: = 0
Take Profit: = 0
Trailing Stop: = 0
]] * /
var: CNT (0), TT (0);

for CNT = 1 totaltrades
{If OrderValue (CNT, VAL_SYMBOL) = Symbol then
tt tt = 1;
};

if TT = 0, then {...

Thus, we count only the amount of positions open for a pair of expert who is registered. At the entrance is made subject to TT = 0 and the quantity of positions of other pairs can be anyone.

... 2nd Is it possible to do so expert will understand what transactions have opened it and what started me? It is necessary for the possibility of trade in professional and hands on a pair ...
Answer:
Special identifiers for open positions in MT are not present. For identification of the positions is convenient to use the size of Lot (those where DTS fractional sizes are supported). For example, you can manually Game 1 lotom then an expert on the same pair may be trading 1.1 or 0.9 Lot. MM will not strongly suffer from it, though, of course, this far-fetched for the decision, but left with nothing.
var: CNT (0), TT (0);
for CNT = 1 totaltrades {if OrderValue (CNT, VAL_SYMBOL) = symbol
OrderValue (CNT, VAL_LOTS) = much then TT = tt +1;};

Similar to the first case, but the elimination of open positions, also applies to the size of Lot.

Alexander A. asks.
... Whether I can close a portion of an open position, for example, after reaching certain profita? ...

Answer:
Yes it is possible, but not all DTS.
Code of experts will be about:

many = 0,5;
for CNT = 1 TotalTrades
{
If OrderValue (CNT, VAL_TYPE) <= OP_SELL and
OrderValue (CNT, VAL_SYMBOL) = Symbol then
{
If OrderValue (CNT, VAL_TYPE) = OP_BUY then
{
if (proposal-OrderValue (CNT, VAL_OPENPRICE))> 20 * point then
{
CloseOrder (OrderValue (CNT, VAL_TICKET), very tender, 3, Violet);
Exit;
};
};
If OrderValue (CNT, VAL_TYPE) = OP_SELL then
{If (OrderValue (CNT, VAL_OPENPRICE)-ask)> 20 * point then
{
CloseOrder (OrderValue (CNT, VAL_TICKET), much to ask, 3, Violet);
Exit;
};
};
};
};
};


CloseOrder (OrderValue (CNT, VAL_TICKET), very tender, 3, Violet);

In the given function parameter variable fourth lot, do not confuse the registered variable lot. The variable much earlier in the code of professional we also determine what part of the position to close. It is necessary to remember a time, using a campaign, it is necessary to limit the closing of the position once.

So far no issues with tajmaute. Dear readers before asking questions, I certainly recommend you to read through all the editions of the magazine.

To mark tajmauta (10 sec limit DTS) after opening the position, you need to use the following after the beginning of the expert.

If curtime-LastTradeTime lower than 11 then exit;

No comments:

Post a Comment

Powered by Blogger.