Questions from Beginners MQL4 MT4 MetaTrader 4 - page 248

 
makssub #:

Thank you very much for your replies. I have implemented some of your suggestions.
I wrote a function that finds the right tick.
I have written a function that calculates the profit of all closed orders after the required order tick of the selected function. All I have to do now is to correct it according to your recommendations and add a check by time etc.

The only thing that confuses me now is that it does not calculate it correctly. If TP comes out 0.02 as a result of the test, it calculates and writes 0.1300 in Comment. Please advise what is wrong with it?

Tick and ticket are different things, a tick is a new coming price of trades... It's better not to get confused right away.

TP and SL close at the price levels and the price more or less. The price is discrete and so is the price of stop levels. If it does not go beyond the levels, the order lives, if it does, it closes. In the tester 4 ticks are modelled, there are less of them than in the real situation and therefore the gap between the tick prices is wider.

Errors and the trading course are better to be written either to the journal, but there is much unnecessary information there - you should find the necessary lines, or to the file. There will not be unnecessary things in the file.

 
Valeriy Yastremskiy #:

Tick and ticket are different things, a tick is a new come deal price... It's best not to get confused right away.

TP and SL close at price levels and price more or less. The price is discrete and so is the price of stop levels. If it does not go beyond the levels, the order lives, if it does, it closes. In the tester 4 ticks are modelled, there are less of them than in the real situation and therefore the gap between the tick prices is wider.

Errors and the trading course are better to be written either to the journal, but there is much unnecessary information there - you should find the necessary lines, or to the file. There will not be unnecessary things in the file.

I would like to display it in the log today. If anything, I'll ask questions again.

 
Good afternoon.

What is the difference between a function and an operator?

Why "if()" is an operator, and"Alert()" is a function, if both have brackets after their names? I'm studying the mql4 tutorial, but I don't understand signs and properties
 
Ivan Butko #:

What is the difference between a function and an operator?

I have never asked myself this question, but I do know that there are only a dozen operators in all programming languageshttps://www.mql5.com/ru/docs/basis/operators

and the rest are either built-in libraries or user-defined functions whose syntax looks like ()

S : in theory all libraries are written from operators..... at least that's how it used to be in C. MQL is a wrapper on some compiler, now it's like LLVM and ready libraries plugged in that give you the embedded functions .... but it's just a thought, in principle it doesn't matter, it can cope with the tasks

 
Ivan Butko "Alert()" a function, if both have brackets after the name? I'm studying the mql4 tutorial, but I don't understand signs and properties

"if" is directly translated into the assembler as a command, while "Alert" is a function that sends notifications.

 
Taras Slobodyanik #:

"if" is directly translated into the assembler as a command, while "Alert" is a function that sends notifications.

hmm... And switch or new are also translated into an assembler command?

;)


the programming primer's the best place to look, there in the preface and in the first chapters they usually write something on this topic, you'll need to look for a primer for school kids, it'll be there for sure


UPD: and if memory serves, if will be replaced by assembler XOR / CMP and then JNE / JNZ ... i.e., for comparison and flag transitions, not quite the same assembler command, though not the point

 
Ivan Butko "Alert()" a function if both have brackets after their names? I'm studying the mql4 tutorial, but I don't understand signs and properties

differences only in the semantics of the particular language. In this sandbox, it is common to call an if operator. As long as you're making puppets here, so be it :-)

Actually it's the same thing. I know languages where there are no "operators", only functions around...and vice versa (not used in practice, but there are some)

 
Igor Makanu #:

hmm... are switch or new also translated into an assembler command?

;)


in general, you should consult a programming primer, in the preface and in the first chapters they usually write something on this subject, you'll have to look for any primer for schoolboys, it will be exact there


UPD: and if memory serves, if will be replaced by assembler XOR / CMP and then JNE / JNZ ... i.e. for comparison and for flag switches, not quite the same assembler command, though not the point.

If memory serves me correctly from BASIC operators are simple one action, and functions are more complex, several actions.

That's historically a good explanation)

 
Igor Makanu #:

UPD: and if memory serves, if will be replaced by assembler XOR / CMP and then JNE / JNZ ... i.e. for comparison and for flag passes, not quite the same assembler command, though not the point

That's the point, you can translate operators into assembler without using functions, with simple CPU commands.

And anything more complicated, anything that requires complex procedures to be called, that's functions.

And those that are even more complex are classes-structures.

 

if nothing else, you need to read Wiki ))))

Operator (programming)

and there is a link to a related article

Operator (programming)

Reason: