Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 297

 
Dmitriy Voevodkin:

work with the history of transactions via

OrdersHistoryTotal()

OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)


Thank you for your reply. I understand that if an order has closed, it has to be selected from the history (as the last order in the history), but I don't know how to set this condition (after we have found it), if it closed at Take Profit, then... and if it closed at Stop Loss, then...?

 

Good day, I have a question like this.... I thought for some reason that function Init () in EA starts not only at the moment of attaching or compiling EA, but also during break of connection, or more precisely after reconnection. Can you tell me how to start init() function after connection is restored????

 
Please advise on what is the correct way and where to put parentheses. Is bool specified correctly? What is its difference from external bool? (or something like this)

"
Bool Volumes

If (Volume [1 ]> Volume [2]) f=true; else f=false ;
If (f) trade; else do not trade
"
Files:
 
Tigerfreerun:
Please advise us on the correct way and where to put parentheses. Is bool specified correctly? What is its difference from external bool? (or something like this)

"
Bool Volumes

If (Volume [1 ]> Volume [2]) f=true; else f=false ;
If (f) trade; else do not trade
"

place cursor on Volume and press F1.

Volume is an operator.

The variable bool f;

Basically, you can put cursor on any operator and press F1 - everything is described there in details.
 
Dmitriy Voevodkin:

place the cursor on Volume and press F1.

Volume is an operator.

The bool variable is f;

In principle, you can put the cursor on any operator and press F1 - everything is described there in details.
The question was about brackets, where to put "{,}" I don't understand this algorithm of bracket arranging. I wrote everything exactly as you said and 4 errors with the word "global scope"
 
Mihail Marchukajtes:

Good day, I have a question like this.... I thought for some reason that function Init () in EA starts not only at the moment of attaching or compiling EA, but also during break of connection, or more precisely after reconnection. Please advise how to start init() function after connection is restored????


You cannot start Init, it is started automatically once when you start the indicator/expert, like DeInit.

As an alternative, you can make a static boolean variable and use it together withIsConnected(). And when the connection is restored at the arrival of a new tick, it must be launched first, some initialization function of its own. ButIsConnected() should be applied not inOnCalculate(), but in OnTimer().

 
Dmitriy Voevodkin:

place the cursor on Volume and press F1.

Volume is an operator.

The bool variable is f;

Basically, you can put cursor on any operator and press F1 - everything is described there in details.
Screenshot of the error
Files:
 
Tigerfreerun:
Screenshot of the error

First time I've seen a screenshot like this =)

Don't you have the possibility to make a screenshot with Windows internal means?

 

By code.

Make a simple return if the volume is low, i.e. interrupt execution of further code

if(Volume[0] < 1000) return;
 
Tigerfreerun:
Screenshot of the error

MQL syntax is broken. In this case there is an extra semicolon after bool Volume and the compiler also wants brackets (), but I already wrote you that this is logic in this case, not code for Expert Advisor.

Reason: