[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 346

[Deleted]  
apologies
[Deleted]  
Stepan241 >> :

At the beginning of the script you write

#property show_inputs

extern double Lot=0.1

After that, when the script is attached to the symbol window, a dialog box will appear.

I understand. But that's not what I need. With these commands a dialog box will appear - with general EA settings and current script settings, and I asked if there is no such function, which could be used to output DO ONLY with the script settings at once.

[Deleted]  
Can you tell me how to make all open orders close at the specified time?
 
JackaLrus писал(а) >>

I understand. But that's not what I need. With these commands a dialog box will appear - with general EA settings and current script settings, and I asked if there is no such function, which could be used to output DO ONLY with script settings at once.

Only MetaEditor then.

 
vik-777 >> :
Could you please advise how to close all open orders at a specified time?

if (HourTime[0]=12)_CloseAllOrder

See the _CloseAllOrder function on the previous page or the page before

[Deleted]  
Stepan241 >> :

if (HourTime[0]=12)_CloseAllOrder

for the _CloseAllOrder function itself, see last page or the page before

Thank you, the function is very handy

 

Dear Experts,

Please advise what is the reason for this result:

gist:

int start()
{
//----
double c;
int q;
c=0.3/0.1;
q=c;
Print("c=",c," q=",q);
//----
return(0);
}

it prints "c=3 q=2"

question: how does it get two out of three?

the thing is, if I replace 0.3 with 0.4 or any other fraction, it solves the problem as intended

for example

int start()
{
//----
double c,v;
int q,w;
c=0.3/0.1;
v=0.4/0.1;
q=c;
w=v;
Print("c=",c," q=",q," v=",v," w=",w);
//----
return(0);
}

"c=3 q=2 v=4 w=4"

Question: how does it get two out of three?

try to compile, maybe my computer can't count (just silly...)

 
mukata >> :

Dear Experts,

Please advise what is the reason for this result:

gist:

int start()
{
//----
double c;
int q;
c=0.3/0.1;
q=c;
Print("c=",c," q=",q);
//----
return(0);
}

it prints "c=3 q=2"

question: how does it get two out of three?

the thing is, if I replace 0.3 with 0.4 or any other fraction, it solves the problem as intended

for example

int start()
{
//----
double c,v;
int q,w;
c=0.3/0.1;
v=0.4/0.1;
q=c;
w=v;
Print("c=",c," q=",q," v=",v," w=",w);
//----
return(0);
}

"c=3 q=2 v=4 w=4"

Question: how does it get two out of three?

Try to compile it, maybe my computer doesn't know how to calculate (it's silly...)


It's not nonsense, just a common rounding error when working with real numbers.

In the first case for example c equals 2.999999999, the output is rounded, i.e. 3, but when assigning to an integer type the fractional part is discarded.

 
splxgf >> :

This is not nonsense, common rounding errors when dealing with real numbers.

In the first case, for example, c equals 2.99999999999...

how can 2.99999999 be 2.9999? 0.3/0.1=3 exactly, it's not like I'm dividing 1 by 3 and it should be 0.33333...

but when assigning to an integer type, the fractional part is discarded.

An integer type is assigned a value c, with is clearly equal to three, without any fractional parts. There's nothing to discard...

The answer is 100% wrong.

any other options?

 
mukata >> :


I don't see how 2.9999 can be 2.9999? 0.3/0.1=3 even, it's not like I'm dividing 1 by 3 and it should be 0.33333...


This only appears to be exactly, while the machine representation can take different values. I.e. 2.9999, 3 or 3.00000001


To get rid of such misunderstandings, MQL has the NormalizeDouble() function