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

 
Sysmart:

Isn't there someone who can tell you?

Why did you paste the code with a picture? Do you think someone will retype the code from a picture and help you?

If you paste the whole code as a code instead of a picture, then there will be many more people willing to help...

 
SanAlex:

what is your problem? what do you want to get out of your function?

I may understand it, then we can look for a solution together.

The catch is that the expression produces = 0

numPosOr= 4;

numStepCount= 1;

iK = (numPosOr - numStepCount) / numPosOr;

But logically it should be so,

at the beginning we count in brackets:

(numPosOr - numStepCount)= 4-1 = 3

then according to the formula:

3 / 4 = 0.75 - this is how the result should look like.

Why does it count = 0?

 
Sysmart:

The problem is that the expression outputs = 0

numPosOr= 4;

numStepCount= 1;

iK = (numPosOr - numStepCount) / numPosOr;

But logically it should be so,

at the beginning we count in brackets:

(numPosOr - numStepCount)= 4-1 = 3

then according to the formula:

3 / 4 = 0.75 - this is how the result should look like.

Why does it count = 0?

You haven't shown the types of variables.
 
Sysmart:

The problem is that the expression outputs = 0

numPosOr= 4;

numStepCount= 1;

iK = (numPosOr - numStepCount) / numPosOr;

But logically it should be so,

at the beginning we count in brackets:

(numPosOr - numStepCount)= 4-1 = 3

then according to the formula:

3 / 4 = 0.75 - this is how the result should look like.

Why do I get = 0?

You have already been written several times to bring all code, if you have iK int type, it's ok to get 0 What type is your variable?

 
Sysmart:

The problem is that the expression outputs = 0

numPosOr= 4;

numStepCount= 1;

iK = (numPosOr - numStepCount) / numPosOr;

But logically it should be so,

at the beginning we count in brackets:

(numPosOr - numStepCount)= 4-1 = 3

then according to the formula:

3 / 4 = 0.75 - this is how the result should look like.

Why does it count 0?

 double numPosOr = 4;

 double numStepCount = 1;

 double iK = (numPosOr - numStepCount) / numPosOr;


   Alert("iK = ",iK); //  =0.75

or

 int numPosOr = 4;

 int numStepCount = 1;

 double iK = (double)(numPosOr - numStepCount) / numPosOr;


   Alert("iK = ",iK); //  =0.75
 
Sysmart:

The problem is that the expression outputs = 0

numPosOr= 4;

numStepCount= 1;

iK = (numPosOr - numStepCount) / numPosOr;

But logically it should be so,

at the beginning we count in brackets:

(numPosOr - numStepCount)= 4-1 = 3

then according to the formula:

3 / 4 = 0.75 - this is how the result should look like.

Why do I get = 0?

Complex arithmetic - when there is no physical understanding of it.

What or why it is needed? may be in some places, need to prescribe a real figure, and then get, his final result?

 

Good day to all.
I recently started learning mql5. I was told here that when testing an EA in MT5, opening and closing orders are done on history with real historical floating spreads, which were at those moments in real trading.

There is no such thing in mql4. But we have the (int)MarketInfo("EURUSD",MODE_SPREAD) function that returns the value of spread when testing. Although it didn't return the real spread value, but the one I set in the settings.
Q
: What function can be used to display the actual value of floating spread in the tester when an EA is opening and closing orders?
Thank you for your help.

Как протестировать торгового робота перед покупкой
Как протестировать торгового робота перед покупкой
  • www.mql5.com
Покупка торгового робота в MQL5 Маркете имеет одно большое преимущество перед всеми другими подобными предложениями -  вы можете устроить комплексную проверку предлагаемой автоматической системы прямо в терминале MetaTrader 5. Советник перед покупкой можно и нужно тщательно прогнать во всех неблагоприятных режимах во встроенном тестере торговых...
 
Hi all!

I'm taking my first steps in MQL5 and I stumbled over a global variable.
Can you tell me how to change it from inside a block?

Or, if it's not possible, how to make "checkboxes" for EA logic?
 

Happy Economist Day everyone!

I have not found among standard functions of MT4 for work with arrays - function which finds first empty row (or value) in array (or with value "0")

What I mean:

Array [2] [7]

1-2

3-4

8-10

2-5

12-7

0-0

0-0

I need a function to determine if the first unfilled/zero value is in line [5].

ArrayMinimum for some reason I can't find minimum "0".


Array search is the only option for this task in MT4.

Thank you!

 
SanAlex:

I would like to ask the experts - is such a template for an expert correct or is it better to organise the logic in another way?

It would be good to comment at the beginning of the functions, what do they do. It's a bit hard to read)