[ARCHIVE!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Can't go anywhere without you - 4. - page 570

 
7Konstantin7:

Please tell me what's wrong, I'm new to mql.

I put TimeBar_t = Minute(); I can't decide if I am missing brackets or ;

int Minute( )
Returns current minute (0,1,2,...59) of last known server time at program start (in process of program execution this value does not change).
Note: when testing, the last known server time is simulated.
So your condition will only hold at start time.
 
xant:

rigonich,

to be precise (OrderProfit()+OrderCommission()+OrderSwap()

So, how do I take information from closed orders?

I select orders using OrderSelect() and MODE_HISTORY from the closed ones, but how can I select the necessary ones?

If I can take from the history those that closed after my condition, then of course I will take and summarise what I need. But I don't understand how to do that, unfortunately.


What do you need? For example, remember the opening date of the first order on the instrument by your EA and select all those opened after it, reset the value of the variable after closing by conditionand remember the new (current) value.
 
xant:

Please advise.

In my EA, the exit calculation is based on accumulated profit. For example, if at some point in time equity=balance, then the EA will close all trades when the current equity exceeds this very initial one. It will close all trades no matter how many of them there are.

It is simple in the tester, as there is one currency pair.

However, trading is realistically effected with several currencies and each one has to be considered separately. For example: If there are no open trades on some currency pair, then the variable==0. And we should trace closed trades at this symbol as well and wait until the accumulated profit exceeds the loss from open orders of this symbol by the specified value.

I cannot find in the tutorial a function that may be used to separate the accounting of accumulated profits for different currencies. Please advise. Thank you.


https://www.mql5.com/ru/forum/131859/page3#434223 here, and alsohttps://www.mql5.com/ru/forum/131859/page3#434222
 
Help me write a condition to open a position.

I can't write an additional condition to open a position according to my idea.

If I close any position with TP or SL it should reopen with the opposite position.

Example: If a Sell position, say SL, is closed, it will reopen a Sell position together with it and Buy

Here are 2 conditions from the Expert Advisor:

condition to buy

if (BUY)
{
if (takeprofit!=0) TP = NormalizeDouble(Ask + takeprofit*Point,Digits); else TP=0;
if (stoploss!=0) SL = NormalizeDouble(Ask - stoploss*Point,Digits); else SL=0;
if(NumberOfPositions(Symbol(),OP_BUY,Magic)<MaxOrders)OPENORDER ("Buy");
}

sell condition

if (SELL)
{
if (takeprofit!=0) TP = NormalizeDouble(Bid - takeprofit*Point,Digits); else TP=0;
if (stoploss!=0) SL = NormalizeDouble(Bid + stoploss*Point,Digits); else SL=0;
if(NumberOfPositions(Symbol(),OP_SELL,Magic)<MaxOrders)OPENORDER ("Sell");
}

Who understands this, please help me to write additional condition
Files:
sellbuy_4.mq4  3 kb
 
Your condition does not fit(( it opens orders indefinitely as long as the deposit is sufficient
 
rigonich:

To shift to the left -- F12, to the right -- I don't know.

RigonichThanks, that's a great tip! Just what I need!
 
Oh, great, thanks everyone!
 
Man, is it really that difficult with the condition ((( like a small advisor.
 

I have not done anything with it, it still does not work ((((

It worked only if the price goes in one direction then it opens and if the price turns around it does not open((

Files:
trudnyaga.mq4  5 kb
 
Frostr:
Help me write a condition to open a position.

I can't write an additional condition to open a position according to my idea.

If I close any position with TP or SL, I want it to open a new position with the opposite value.

Example: if a Sell position was closed by SL, it will reopen a Sell position together with it and Buy.

Here are 2 conditions from the EA:

Buy condition

if (BUY)
{
if (takeprofit!=0) TP = NormalizeDouble(Ask + takeprofit*Point,Digits); else TP=0;
if (stoploss!=0) SL = NormalizeDouble(Ask - stoploss*Point,Digits); else SL=0;
if(NumberOfPositions(Symbol(),OP_BUY,Magic)<MaxOrders)
}

Sell condition

if (SELL)
{
if (takeprofit!=0) TP = NormalizeDouble(Bid - takeprofit*Point,Digits); else TP=0;
if (stoploss!=0) SL = NormalizeDouble(Bid + stoploss*Point,Digits); else SL=0;
if(NumberOfPositions(Symbol(),OP_SELL,Magic)<MaxOrders)
}

Who understands this, please help me to write additional conditions

I'm sorry, but in the attached files you have a compiled file, not the source file. You can't view it. Please send the file with the .mq4 extension