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

 
valenok2003:

it's actually like this

print gives _dif = 0.01, but_Lot = 0;

Probably set to

int _Lot; //then it will cut off anything less than one

and should be set to:

double _Lot;


 
forexnew:

Probably set to

int _Lot; //then it will cut off anything less than zero

and should be set to:

double _Lot;



double _Lot;
double _Lot_BUY = 0;
double _Lot_SELL = 0;
double _Lot_BUYSTOP = 0;
double _Lot_SELLSTOP = 0;
 

here's another construction

   if(_Lot_BUY > _Lot_SELL+_Lot_SELLSTOP) {
       _dif = _Lot_BUY - (_Lot_SELL + _Lot_SELLSTOP);
      if(_Lot_BUY - (_Lot_SELL + _Lot_SELLSTOP) >= 0.01) _Lot = 0.01;
      if(_Lot_BUY - (_Lot_SELL + _Lot_SELLSTOP) >=  0.1) _Lot =  0.1; 
      if(_Lot_BUY - (_Lot_SELL + _Lot_SELLSTOP) >=    1) _Lot =    1;   
      if(_Lot_BUY - (_Lot_SELL + _Lot_SELLSTOP) >=   10) _Lot =   10; 

Print(_dif +" установка2 _Lot = "+_Lot+ "_Lot_BUY = "+_Lot_BUY+ "_Lot_BUYSTOP = "+_Lot_BUYSTOP+ "_Lot_SELL = "+_Lot_SELL+ "_Lot_SELLSTOP = "+_Lot_SELLSTOP);

      _Price = NormalizeDouble((Low [iLowest (Symbol(),TF_Cnt_Bar_for_Lock,MODE_LOW, _Bars_PP_OP_SELLSTOP,0)]- Dist_For_Boot*Point),Digits);
      if(Bid - _Price < Dist_For_Boot*Point) {
         _Bars_PP_OP_SELLSTOP *=2;
         _RESET_Bars_PP_OP_SELLSTOP = false;
      }
      if(set_order_sellstop(_Price, _Lot, _Txt_Lock+Comment_Order)!= -1) _RESET_Bars_PP_OP_SELLSTOP = true;
   }

doesn't work like this, but in the following example it does

   if(_Lot_BUY > _Lot_SELL+_Lot_SELLSTOP) {
       _dif = _Lot_BUY - (_Lot_SELL + _Lot_SELLSTOP);
      //if(_Lot_BUY - (_Lot_SELL + _Lot_SELLSTOP) >= 0.01) 
      _Lot = 0.01;
      if(_Lot_BUY - (_Lot_SELL + _Lot_SELLSTOP) >=  0.1) _Lot =  0.1; 
      if(_Lot_BUY - (_Lot_SELL + _Lot_SELLSTOP) >=    1) _Lot =    1;   
      if(_Lot_BUY - (_Lot_SELL + _Lot_SELLSTOP) >=   10) _Lot =   10; 

Print(_dif +" установка2 _Lot = "+_Lot+ "_Lot_BUY = "+_Lot_BUY+ "_Lot_BUYSTOP = "+_Lot_BUYSTOP+ "_Lot_SELL = "+_Lot_SELL+ "_Lot_SELLSTOP = "+_Lot_SELLSTOP);

      _Price = NormalizeDouble((Low [iLowest (Symbol(),TF_Cnt_Bar_for_Lock,MODE_LOW, _Bars_PP_OP_SELLSTOP,0)]- Dist_For_Boot*Point),Digits);
      if(Bid - _Price < Dist_For_Boot*Point) {
         _Bars_PP_OP_SELLSTOP *=2;
         _RESET_Bars_PP_OP_SELLSTOP = false;
      }
      if(set_order_sellstop(_Price, _Lot, _Txt_Lock+Comment_Order)!= -1) _RESET_Bars_PP_OP_SELLSTOP = true;
   }
 

The following message appears in the log

0.01000000 setting2 _Lot = 0.00000000_Lot_BUY = 0.03000000_Lot_BUYSTOP = 0.00000000_Lot_SELL = 0.00000000_Lot_SELLSTOP = 0.02000000
17:07:12 Expert_V3 GBPUSD,M1: invalid lots amount for OrderSend function

However, while 3 SELLSTOPs were missing, it set the first two without problems, but stumbled on the third.

I.e., why it doesn't set lot to 0.01, even though it calculates the _dif variable correctly...

 
Roger:


Is that your idea?

It will only open orders from the second. Not even from the second, but from the third.

Thank you
 
Can you please advise whether it is possible to determine the time of the beginning of the trading session (for example, for Moscow it is 10-35, etc.) or just create a variable and write a value in it? This is necessary in order not to place orders at the beginning of the session, but to determine the direction.
 
first_may:
Can you please advise whether it is possible to determine the time of the beginning of the trading session (for example, for Moscow it is 10-35, etc.) or just create a variable and write a value in it? This is necessary in order not to place orders at the beginning of the session, but to determine the direction.
Schedule of Forex trading sessions
 

So it is suggested to just use a variable that stores the start of the session. Thank you.
 
Also, the best session indicator I've come across.
P.S.
Found it in the database. https://www.mql5.com/ru/code/9313
Files:
 
Is there an example function for working with dates, i.e. to determine the difference between two dates, is it greater than zero or not?
Reason: