[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 53

 

Something seems to be clearing up.... Here's the situation: the global variable double Delete_Level is declared. In the body of the if statement, a new value is assigned to it:

Delete_Level = MA3

And when leaving the body, the global value of Delete_Level does not change. Question: how can I change the value of global variable Delete_Level when I exit the body of if statement?

 
vovan-gogan:

Sorry, but could you take it easy?) Help me understand the error in


The fact that there will NEVER be a perfect equality - this is the real world, the real world, in which there are some uncertainties and tolerances for this or that process, operation etc. Learn the "basics"... :-P It couldn't be simpler. Do as I recommended and tell me if the condition works, will it work? I'm interested in it myself. Thank you.


 
vovan-gogan:

Something seems to be clearing up.... Here's the situation: the global variable double Delete_Level is declared. In the body of the if statement, a new value is assigned to it:

And when leaving the body, the global value of Delete_Level does not change. Question: how can I change the value of global variable Delete_Level when I exit the body of if statement?


How does it not change? Of course it changes. Print the code and look at the Log tab, with F12 - step-by-step test in visualisation mode.
 
sergeev:

what is the date as you and MQL understand it ?
I would like to do a check before placing an order. Suppose a session starts at 10-30, then at 10-35 all conditions to open a buy order are fulfilled, but it should not be placed until the current time is greater than or equal to 10-45.
 
Roman.:

How come it doesn't change? Of course, it changes.


It goes like this. For example, in my EA, I first declare a global variable int Orders, and then in case a pending order is placed, the value of int Orders should change as shown below:

int Orders;
if (MA2_2<MA1_2 && MA2_1>MA1_1)//пересечение МА
{
   if (OrdersTotal()>= 1)
   {
   return;
   }
         SL = 30;
         TP = 12;
         S_Price = Low[1] - 1* Point;
         if (OrderSend (Symbol(), OP_SELLSTOP, Lots, S_Price, 0, SL, TP, "My order", Magic)>0)
            {
               Orders++;
               Alert ("Ордер выставлен. Orders=",Orders );
            }
}           

But this will not change in Orders. Every time we get a message that "Order is set. Orders=1"

 
vovan-gogan:


It goes like this. For example, in an EA, I first declare a global variable int orders and then in case a pending order is placed, the value of int orders should change as shown below:

But there is no change in orders. Every time I get a message that "Order is placed. Orders=1"


You don't need a global variable, but a local variable of the start function. So, please try

int start()                            // Спец. функция start
  {
    int Orders=0;
     if (MA2_2<MA1_2 && MA2_1>MA1_1)  //пересечение МА
        {
          if (OrdersTotal()>= 1) return(0);   
          SL = 30;
          TP = 12;
          S_Price = Low[1] - 1* Point;
          if (OrderSend (Symbol(), OP_SELLSTOP, Lots, S_Price, 0, SL, TP, "My order", Magic)>0)
            {
               Orders++;
               Alert ("Ордер выставлен.Orders = ",Orders );
            }
        }   
       Alert ("Ордеров нет. Orders = ",Orders );    
//----------------------------------------------------------------  
   return;                             // Выход из start()
  }
 
Roman.:


You don't need a global variable there, but a local variable for the start function. So try


Isn't it the same in my example? How is it different? Except that I didn't add a start function.
 
vovan-gogan:

Isn't it the same in my example? How is it different? Except that I didn't add a start function.

You should try my example.
 
Roman.:

You try my version.

But I don't see the difference to try. Please tell me what I did wrong.
 
Tell me why when I open a chart (real time) with M30 timeframe and apply the indicator with parameter int shift=iBarShift(NULL,PERIOD_M5,some_time); shift will be as it should be, but when I run the same indicator through the tester with period M30 shift is not calculated?
Reason: