[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 81

 
artmedia70:

If I understood your curly braces correctly, then:




after executingPlaySound("alert.wav");; the following ifs will no longer be executed?

if (1<2) 
{
   if(2<3)
      {
      if (3<4) PlaySound("alert.wav");  
           { 
            if (X)....
                {
                    if (Y)
                }
            }
       }
}

 
charter:

The indicator turns red when its values are decreasing and green when the values are increasing.


really... so simple) thank you!
 
Stomatolog:
Hi guys, can you help me with my question ? I am new to MQL4, i am writing an EA, i had to writeint total=OrdersTotal();total<1 to avoid opening a deal on every new tick. How to make deals open on all currency pairs, where the EA is installed. And on a single currency pair you can open multiple deals.

In order not to open on every tick and to optimise the EA faster, I often use this design:

datetime t;                     // переменная для запоминания значения времени
int start()
{
  if (t == Time[0]) return;     // если "старое" время и текущее совпадают, выходим из start
  else t = Time[0];             // иначе присвоим переменной текущее время

This way, when a new bar appears, the code will be executed once.

Read how to use MagicNumber in orders and then using total < 1 will enable the EA to open an order for each currency pair and for one currency pair but open in different windows. You can see a sample here.

 
lottamer:


after PlaySound("alert.wav"); has been executed, the following ifs will no longer be executed?

if (1<2) 
{
   if(2<3)
      {
      if (3<4) PlaySound("alert.wav");  
           { 
            if (X)....
                {
                    if (Y)
                }
            }
       }
}

Your code is wrong. Opening parentheses should be before operators, not after.

//+----------------------------------------------------------------------------+
if (1<2) {                                // Если один меньше два и ...
   if(2<3) {                              // ... два меньше три, ...
      if (3<4) PlaySound("alert.wav");    // Если три меньше четыре - врежем рок в этой дыре ... (С), 
                                          // Далее пойдём проверять остальные условия:
      if (4<5)                            // Если четыре меньше пять и ...
      if (5<6) Print("Истина");           // ... пять меньше шесть - верно, блин...
      }
   }
//+----------------------------------------------------------------------------+

The block with Sound` and Print` will only be executed if 1 is less than 2 and 2 is less than 3. Sound will be executed if 3 is less than 4.
But Print will also execute if 4 is less than 5 and 5 is less than 6

 
artmedia70:

Your code is wrong. The opening brackets should be before the operators, not after.

Sound` and Print` block will only execute if 1 is less than 2 and 2 is less than 3. Sound will be executed if 3 is less than 4.
But Print will also execute if 4 is less than 5 and 5 is less than 6



It seems to me that if 4>5 , and 5<6 at the given entry Print will still be executed, because the machine will work all 3 if in a row regardless of their TRU-FOLS result - there are NO COLLECTIONS!
 
and is it possible to derive a local variable for global use?
 
lottamer:

It seems to me that if 4>5 , and 5<6 then with this entry Print will still be executed, because the machine will execute all 3 ifs in a row regardless of their TRU-FOLS result - there are NO COLLECTIONS!
If (4<5) is true, then the following line is executed: if(5<6), but ... if (4<5) is false, then the next if () together with its print is not processed, and we pass to the closing parenthesis from if (2<3).
 
lottamer:
but is it possible to deduce a local variable for global use?
You can, as long as you make sure that the logic is not violated. There can be two or more local variables (each declared in its own function) with the same name as one global variable. You need to be careful and pay attention to their visibility.
 
How do I correctly attach one indicator to another via iCustom()?
I have one indicator in which all 8 indicator arrays are occupied. How to create correctly the second one, so that it draws the curve from the first indicator in 1 indicator array?
Both indicators #property indicator_chart_window.
The most obvious explanation, is the analogue in the form of the code of the two linked indicators.
Thank you in advance!!!
 
Leo59:
How do I correctly attach one indicator to another via iCustom()?
I have one indicator in which all 8 indicator arrays are occupied. How to create correctly the second one, so that it draws the curve from the first indicator in 1 indicator array?
Both indicators #property indicator_chart_window.
The most obvious explanation, is the analogue in the form of the code of the two linked indicators.
Thank you in advance!!!

Read into the indicator buffer of the second indicator the buffer of the first indicator from which you want to display the line.