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

 
Hm, can someone help me?
 
Chiripaha:

Here, just in code of Pr0t0tip (well, and nickname - got tired to retype : )) ) These variables extern int sl=100; (etc.) are mapped. So you need to declare a variable, then it will appear in owl settings, then its value can be changed and optimized.

I know that. But external variables do not work inside a user function. they declare their own variables. that's the problem.

And I can't get rid of the function. there's a modification of order....

 
solnce600:
And above that there is only START and NOTHING else

Ahhhhhhhh - here we go... I put it in the wrong place - I should have put a variable behind a bracket:

int start()
  {
   bool have = true;

   for(int i=0;i<10;i++)
     {
      if(Low[i]<=Low[i+1])
       {
        have=false; 
        break;
       } 
     } 

   if(have)
    {
     OrderSend(Symbol(),OP_SELL,0.1,Bid,1,Ask+1500*Point,Ask-1510*Point,"jfh",123 );// действия если условие соблюдено 
    }

   return(0);
  }

And there were extra ones at the bottom and another curly bracket. You were not following the margins and a single structure (style) of your text. When you write everything correctly, all mistakes (inconsistencies) are visible. Be careful when writing code. - It shouldn't swear.

 

That's weird. I'm getting this error from your code

'bool' - semicolon expected C:\Documents and Settings\User\My Documents\FxClub\TeleTRADE\experts\dot.mq4 (33, 4)

Actually on bool have = true;

 
Exactly. Or else there was a logical twist-else,or-or the function finishes its work by giving out zero, or what???
 
Chiripaha:

Ahhhhhhhh - there, found it... Wrong place - I should have put the variable behind the bracket:

And there was an extra one at the bottom of else and another square bracket. You're writing without respecting the margins. When you put everything correctly, all the errors (inconsistencies) are immediately visible. Be careful with how you write your code. - It shouldn't be a scolding.


Thank you very much...... what would I do without you..... God bless you ..... and the rest you will buy on the profits....
 
lottamer:

I know that. But external variables do not work inside a user function. they declare their own variables. that's the problem.

And I can't get rid of the function. it modifies the order....

Why doesn't it work? - If you take any global variable into a user function, it will work as declared inside. But the data of the internal variable are visible only to this function - further its action is limited. And the values of the global(extern) variable are visible to the entire program. This is the difference. But in case of an external - again, extern - , the variable will also appear in settings. - This is a textbook. Reread it, it helps. : )) Of course, when declaring an external variable, it must be referenced inside the function to this global variable. And make sure that the names are not identical. Otherwise, you will declare both external and internal with the same name. - Although, it can be done this way, but it seems the function will take the value of the internal variable - I do not remember exactly. This is where you have to go through a textbook. Do it yourself, if you want to experiment. I usually give different names to avoid confusion and that's it.
 
Chiripaha:
Why doesn't it work? - If you take any global variable into a custom function, it will work just like the one declared inside. The data of the internal variable is only visible to this function - further its action is limited. And the values of the global(extern) variable are visible to the entire program. This is the difference. But in case of an external - again, extern - , the variable will also appear in settings. - This is a textbook. Reread it, it helps. : )) Of course, when declaring an external variable, it must be referenced inside the function to this global variable. And make sure that the names are not identical. Otherwise, you will declare both external and internal with the same name. - Although, it can be done this way, but it seems the function will take the value of the internal variable - I do not remember exactly. This is where you have to go through a textbook. Do it yourself, if you want to experiment. I usually give different names to avoid confusion and that's it.


Thanks so much...thought if the inside is not visible on the outside, then the outside is not visible on the inside either...
 

Hello. I have written a simple EA (trying to learn it myself). The robot only opens trades to sell, but does not want to buy. I understand I did not spell the buy conditions correctly or did not divide them properly. I am asking for help. Here it is:

extern int tp=100;

extern int sl=100;

extern int H=14;

extern int M=00;

double ma1, ma2;

int start()

{

ma1=iMA (NULL,0,18,0,MODE_SMA,PRICE_CLOSE,0);

ma2=iMA (NULL,0,36,0,MODE_SMA,PRICE_CLOSE,0);

if (OrdersTotal ()==0 && iStochastic (NULL,0,50,30,3,0,1,MODE_MAIN,4)<iStochastic (NULL,0,50,30,3,0,1,MODE_SIGNAL,4) && ma1<ma2)

OrderSend ("EURUSD", OP_SELL,0.1,Bid,0,Ask+sl*Point,Ask-tp*Point,",123,Red);

if (OrdersTotal ()==0 && iStochastic (NULL,0,50,30,3,0,1,MODE_MAIN,4)>iStochastic (NULL,0,50,30,3,0,1,MODE_SIGNAL,4) && ma1>ma2)

OrderSend ("EURUSD", OP_BUY,0.1,Ask,0,Bid+sl*Point,Bid-tp*Point,",123,Red);

}

return (0);

 
Pr0t0tip:
Hm, can someone help me?

Let's have a look - I'm not very experienced. But we'll give it a try... : ))

Meanwhile, you should learn to use the button SRC - it allows you to insert the code correctly, beautifully and clearly. So those who will help you (now and in the future), it would be easier to read it. You may break your eyes if you do. : ))

Reason: