Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 973
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello.
Please help me to understand. When checking the operation of a simple array (assigning a value);
a[0][2]=91.49999999993754;
Print("a[0][2]=",a[0][2]);
H= 1/(1+exp(-a[0][2]));
a[0][2]=H;
Print(" 1/(1+exp(-a[0][2]))=",1/(1+exp(-a[0][2])), " H=",H," a[0][2]=",a[0][2]);
I get the result:
2019.09.21 13:21:44.328 2011.01.03 14:54:20 W EURUSD,H4: a[0][2]=91.4999999999993754
2019.09.21 13:21:44.328 2011.01.03 14:54:18 W EURUSD,H4: 1/(1+exp(-a[0][2]))=0.7310585786300049 H=1.0 a[0][2]=1.0
How so ?
Hello.
Please help me to understand. When checking the operation of a simple array (assigning a value);
a[0][2]=91.49999999993754;
Print("a[0][2]=",a[0][2]);
H= 1/(1+exp(-a[0][2]));
a[0][2]=H;
Print(" 1/(1+exp(-a[0][2]))=",1/(1+exp(-a[0][2])), " H=",H," a[0][2]=",a[0][2]);
I get the result:
2019.09.21 13:21:44.328 2011.01.03 14:54:20 W EURUSD,H4: a[0][2]=91.4999999999993754
2019.09.21 13:21:44.328 2011.01.03 14:54:18 W EURUSD,H4: 1/(1+exp(-a[0][2]))=0.7310585786300049 H=1.0 a[0][2]=1.0
How so ?
This is a hard example to reproduce, but I suspect that because of the type conversion you get a different result than you expect.
Experiment with this code:
then with this:
и
and do a forum search for "real numbers", in short, the C-conversion is a bit confusing at first ;)
You've shown a bunch of examples using int variables.
My variables are all double.
So, converting the variables to the same format won't work.
You've shown a bunch of examples using int variables.
My variables are all double.
So the variable conversion to the same format won't work.
a[0][2]=91.49999999993754;
Print("a[0][2]=",a[0][2]);
H= 1/(1+exp(-a[0][2]));
a[0][2]=H;
Print(" 1/(1+exp(-a[0][2]))=",1/(1+exp(-a[0][2])), " H=",H," a[0][2]=",a[0][2]);
I get the result:
2019.09.21 13:21:44.328 2011.01.03 14:54:20 W EURUSD,H4: a[0][2]=91.4999999999993754
2019.09.21 13:21:44.328 2011.01.03 14:54:18 W EURUSD,H4: 1/(1+exp(-a[0][2]))=0.7310585786300049 H=1.0 a[0][2]=1.0
How so ?
You have integer constants as well as the example itself is not reproducible - no variable types, well in general - my "pile of examples" can be calculated without PC, your example... just tell me what e^(-91.49999) is.
Okay, forget it. I can't help you.
It's a shame that " can't help"...
The question is not how much e^(-91.49999). The question is why a variable of type double = H, is incorrectly written
computed earlier number of type double =0.7310585786300049 , but it's written 1.0 (incidentally double).
If you try to use my code in the tester, I think your MT4 will display the same thing.
If so, you simply cannot use MQL4 for work and it is dangerous!
Too bad... "can't help"...
I helped, help doesn't mean do it for me or I won't read it anyway, and I care about the result!
If so, MQL4 simply cannot be used for work and is dangerous!
The behaviour of MQL4 / MQL5 in calculation of mathematical expressions is the same as in C++. You can go to any C++ forum with your question, maybe an asset will help you there
Your question has moved from help/explain/teach to discussion of MT platform, don't like it, you received it for free?
... In ancient times lack of understanding of physical processes caused panic fear in people, thunder or earthquake... at first it caused panic and speculation, then came religion ))))
You should not have been so angry.
If I have hurt your personal feelings, I sincerely apologise.
I am not discussing or judging MT4 at all. I simply suggested that you run
I just offered to run the code I sent you in the tester of MT4 and if all variables (H,a[0][2])
are defined as double and the result is the same as for me, I have a question:
What is the problem? I addressed it to you.
Once again : I'm sorry... "can't help"...
Goodbye.
that all variables (H,a[0][2])
are defined as double
Once again - do you have constants in your mathematical expression? - my example also has constant 5 ... then I wrote 5.0 - it's not the same for the compiler! and then I explicitly brought the integer constant 5 to the type double ---> for the compiler it will be the same as the example above 5.0
Your question is repeated regularly on the forum, although I may not see what your question is - you have a "heavy formula" and not obvious variables - remove unnecessary from examples - arrays and exponent - then you'll see what the issue is, although if you remove all unnecessary, you will most likely find where you got not what you expected - I usually do ;)
HH: and the exponent to the power of minus 91.49 - is not a very small number? type double has great accuracy, but to the hundredth power and taking into account the minus sign - in my opinion, this expression will lose accuracy, I do not want to google, but the first thing I scrolled through this Wiki
Thank you for your patience!
Tried this :
A=91.49999999993754;//a[0][2]=91.49999999993754;
Print("A=",A);
H= 1/(1+exp(-A));
//A=H;
Print("1/(1+exp(-A))=",1/(1+exp(-A)), " H=",H," a[0][2]=",a[0][2]);
Result:
2019.09.21 16:14:17.691 2011.01.04 22:29:51 W EURUSD,H4: A=91.4999999999993754
2019.09.21 16:14:17.690 2011.01.04 22:29:50 w EURUSD,H4: 1/(1+exp(-A))=1.0 H=1.0 a[0][2]=0.0
I will try to find out why 1/(1+exp(-91.49999999993754))=1.0.
Please understand me. I am busy now with tuning and training the neural network. The code itself is crude and even I myself get confused in it... :)
I notice that the network repeats errors. And the main mistake is in calculating the sigmoid. IT SHOULDN'T BE =1.
Thank you for your patience!
Tried this :
A=91.49999999993754;//a[0][2]=91.49999999993754;
Print("A=",A);
H= 1/(1+exp(-A));
//A=H;
Print("1/(1+exp(-A))=",1/(1+exp(-A)), " H=",H," a[0][2]=",a[0][2]);
Result:
2019.09.21 16:14:17.691 2011.01.04 22:29:51 W EURUSD,H4: A=91.4999999999993754
2019.09.21 16:14:17.690 2011.01.04 22:29:50 w EURUSD,H4: 1/(1+exp(-A))=1.0 H=1.0 a[0][2]=0.0
I will try to find out why 1/(1+exp(-91.49999999993754))=1.0.
Please understand me. I am busy now with tuning and training the neural network. The code itself is crude and even I myself get confused in it... :)
I notice that the network repeats errors. And the main mistake is in calculating the sigmoid. IT SHOULDN'T BE =1.
So you won't find anything, that's what I decided to check, you have to look for where the bug or inaccuracy in the code is:
2019.09.21 16:53:01.516 tst_template EURUSD,H1: 4. e = 1.828331349163451e-40
2019.09.21 16:53:01.516 tst_template EURUSD,H1: 3. H = 1.0
2019.09.21 16:53:01.516 tst_template EURUSD,H1: 2. a = 1.0
2019.09.21 16:53:01.516 tst_template EURUSD,H1: 1. a = 91.49999999993754