Errors, bugs, questions - page 1035

 
A100:
Have you ever seen it output as "word Hello"?

Re-read carefully what I wrote to you. Calculation, not output.

This is an i += ++i +++ expression

 

Forum on trading, automated trading systems and trading strategy testing

Bugs, bugs, questions

MetaDriver, 2013.08.03 17:55

"

If you want to be sure you have an input on the right side of the screen.

For my purposes it is not always suitable, but in general case a lot of "weekend problems" would be removed.

ForExperts on trading, automated trading systems, and trading strategy testing.

Bugs, bugs, questions

MetaDriver, 2013.08.03 18:02

...

It would also be useful "command" programmatically forced zeroing of all prev_calculated for the selected symbol. With subsequent tick generation would be a good combo.

Gentlemen, is there anything in your plans on this subject?


 
TheXpert:

Re-read carefully what I wrote to you. Calculation, not deduction.


You are right to separate the moments: calculating function arguments, substituting those arguments and calculating the function itself. This script - shows that both the arguments are calculated from left to right and the expression itself from left to right:

int f( int x )  { Print( __FUNCTION__ + "(" + x + ")" ); return ( x ); }

void OnStart()
{
        int a = 0x0;
        int b = f(a+=1) << f(a+=2) << f(a+=3);
	Print( "b=" + b );
}
Результат:
f(1)
f(3)
f(6)
b=512
 
Can you please tell me the difference between extern and static, what is the global lifespan?
//Test.mqh
extern int e1;
static int s1;

#import "testLib.ex5"
        void f();
#import
//test.mq5
#include "Test.mqh"

void OnStart()
{
        e1 = 10;
        s1 = 10;
        f();
}

//testLib.mq5

#property library
#include "Test.mqh"

void f() export
{
        Print( "e1=" + e1 );
        Print( "s1=" + s1 );
}
Результат:
e1 = 0 //не понятно
s1 = 0 //нормально
Документация по MQL5: Стандартные константы, перечисления и структуры / Торговые константы / Свойства ордеров
Документация по MQL5: Стандартные константы, перечисления и структуры / Торговые константы / Свойства ордеров
  • www.mql5.com
Стандартные константы, перечисления и структуры / Торговые константы / Свойства ордеров - Документация по MQL5
 
Silent:
Not that?

Nope - using an uninitialised standard class there.

All my classes are self-written. And I do not understand - why inside the class method works fine, and in OnInit() - does not.

Upd: very interesting... ;-) If the Expert Advisor is run in MetaEditor under the debugger - everything works fine. Moreover, EX5 (1.5 times larger than usual) compiled under debugger also works fine. But as soon as EA is recompiled in normal mode - it starts glitching. Apparently, I'll have to open a new application in Service Desk.

 
A100:
Can knowledgeable people please tell me the difference between extern and static, what is the global lifetime?

In your case, you have decided that two sets of variables, independently described in two different files, merge into one representation. This is actually not the case.

By adding an mqh file, you explicitly define separate sets of variables in each include file. Roughly speaking, do not put variable definitions in the header files - they will be scoped.

 
I wanted to use one (single) variable in several modules, but don't know how. Took out .mqh.
10 //testLib.mq5
20 #property library
30 extern int e1;
40 void f() export
50 {
60         Print( "e1=" + e1 );
70 }
10 //test.mq5
20 extern int e1;        
30 #import "testLib.ex5"
40          void f();
50 #import
60 void OnStart()
70 {
80         e1 = 10;
90         f();
100 }

Output result: e1=0 did not change. Where did e1=10 go? If e1 is different in different modules, it means that static and extern functionality is identical? And if not, where is my error?
 
A100:
I wanted to use one (single) variable in several modules, but I don't know how. The output result: e1=0 did not change.
There is an extern memory class specifically for your case. Try
 
stringo:
There is an extern memory class specifically for your case. Try
Please give me an example - or point out an error in mine - In one module I assign e1 = 10, I call e1 in the second module, but it is zero there
 
A100:
I wanted to use one (single) variable in several modules, but I don't know how. Took away the .mqhP output: e1=0 did not change. Where did e=10 go? If e1 is different in different modules, it means that static and extern functionality is identical? And if not, where is my error?
Well, it sort of should be initialized only once. It is external.
Reason: