[ARCHIVE!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Can't go anywhere without you - 4. - page 207

 

why are there intermediaries? and what is the function of the FUN?

int Criterion;
int start() {
  Fun_Criterion(); 

  switch( Criterion)
   {
   /************/
   }
  return(0);
}
//-----------------------------
void Fun_Criterion() {
  if(MA_1 > Level_S_1 && Ma_2 <= Level_S_2 &&  MA_3 <= Level_S_3) Criterion=1;
  if(MA_1 < Level_R_1 && Ma_2 >= Level_R_2 &&  MA_3 >= Level_R_3) Criterion=2;
 }

And && are not in the right place...

 
The way I see it, it was the TRANSFERABLE PARAMETER))))), but I couldn't do without it))). Thanks, fixed it and it's working.
 
Aleksander:

dear... there's no need to write in such big letters here... you might break your eyes :-)

and this... before you ask questions... have you tried reading the Help in Metaeditor? All of it?...for starters...so you don't ask stupid questions about types and stuff like that....

===

Type of operation for OrderSend() function. Can be any of the following values:

Constant Value Description
OP_BUY 0 Buy
OP_SELL 1 Sell
OP_BUYLIMIT 2 BUY LIMIT pending order
OP_SELLLIMIT 3 Pending SELL LIMIT order
OP_BUYSTOP 4 Pending BUY STOP order
OP_SELLSTOP 5 Pending SELL STOP order
Dear Sir... there's no need to get cocky here... If something seems silly to you, don't bother answering... God willing, there are people without delusions of grandeur... This is a section for newbies and if people ask about something, it means they don't understand it... Further: if everything was clear in the Help and in the book, I wouldn't be here.
Now to the point: let's say we have 3 orders and all are market orders. Then with 3 iterations we won't hit block 4 in any of them. And after the last iteration we will immediately go to block 5, bypassing block 4. Block 5 contains the Tip variable, which is declared in block 4. But block 4 was not executed. So the Tip variable is not declared. So we use the variable before we declare it?

 
Why? The compiler has allocated memory space for the variable on the first pass... and accessing it won't cause an error...
 
Aleksander:
Why? The compiler allocated memory space for the variable during the first pass... and accessing it won't cause an error...


The following point is not clear: on the first pass (assuming that all 3 orders are market orders), we don't get to block 4, since the condition if(OrderType()<2) is met in block 3. Then the next iterator continue completes the current iteration and skips block 4, which is where the Tip variable is declared. It means that the Tip variable was not declared during the first iteration (i.e. the line declaring Tip variable was not executed)... And so it goes on for all 3 iterations. I.e. after the 3rd iteration we get to block 5, which uses Tip variable, i.e. it wasn't declared earlier (i.e. we have a string with its declaration, but since we've never gotten to block 4, we haven't declared this variable?)

 

I was referring to the compiler's traversal of the program text - having found a variable definition at any point in a function - the metacompiler declared that variable for use downstream - despite the fact that there was no actual reference to variable initialization... - that's the environment :-)

int start()  {
       int l=1;
       
       if (l == 2) {
          int kk=99;
          kk = 100;
       }
   }
   if (kk != 10) { Print("net kk takoi peremennoi = ", kk); }


Even though there was no input in the condition - the compiler allocated a memory location for the variable... although it did not initialize it... in Print it will be = 0

 
Aleksander:

I was referring to the compiler's traversal of the program text - having found a variable definition at any point in a function - the metacompiler declared that variable for use downstream - despite the fact that there was no actual reference to variable initialization... - that's the environment :-)


Even though there was no input in the condition - the compiler allocated a memory location for the variable... although it did not initialize it... in Print it will be = 0



So, if I understand correctly: compiler, unlike terminal (roughly speaking) does not execute loops, but just reads lines in a row and checks for errors... I.e. the main thing for it (which is the criterion of presence/absence of error) is that the line (position), where a variable was used, should come AFTER the line (position), where this variable was declared?
 
you could say so :-) if you make a declaration below - and access the variable above - the compiler will generate an error...
 
Aleksander:
you could say that :-) if you make a declaration below - and access the variable above - the compiler will generate an error...

Got it, thanks a lot... Any tips about GV variables?
 

what about them? - global at terminal level?

they store some time in a variable file :-) the access date, name and value of type double