[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 692

 
Don't worry, essentially it's int.
 
Roger:
Don't worry, it's essentially int.


i.e. if I reassign the result of TimeCurrent()-OrderOpenTime() calculation to int as:

int mytime = TimeCurrent()-OrderOpenTime();

there won't be any uncertainties in this form? And I'll get number of seconds in mytime?

 
IgorM:

Thanks, but I'm afraid to experiment with datetime type - there are no conversions to other types (I would like datetime --> int), and it's not realistic to see what the output is.

Why is it unrealistic? Time functions return "the number of seconds elapsed...", which is a pure int. By adding and subtracting "number of seconds", we get the time offset from the "time reference point".
 
IgorM:


i.e. if I reassign the result of TimeCurrent()-OrderOpenTime() calculation to int in the form:

int mytime = TimeCurrent()-OrderOpenTime();

there won't be any uncertainties in this form? and i will get the number of seconds in mytime?


Right.
 
DDFedor:

Why is it unrealistic? Time functions return "number of seconds elapsed..." and this is a pure int. By adding and subtracting "number of seconds" we get a time deviation from the "time reference point".


I know that, it's just that sometimes the uncertainty of the automatic type conversion scares me - there's no information, i.e.

what will happen if

int = double

int = datetime

etc.

In other programming languages, such constructions will not be allowed by compiler - the type conversion error will be called, but in mql there will be no error, but it does not mean that it will work correctly - that's why I asked

 
IgorM:


sounds nice, but no one knows when the flat ends and when it starts :) - I'm struggling with this phenomenon and it seems to be working - we'll discuss it later

I would like to control an open order according to the following principle - if after placing an order by closing N bars its profit is less than the set value, then close the order

how to check/comput how many bars ago an order was opened from an EA?

Strange that you are only asking this question now... I have been using Igor Kim's function for a long time... I want to add it to the pile... :)

//+----------------------------------------------------------------------------+
//|  Автор    : Ким Игорь В. aka KimIV,  http://www.kimiv.ru                   |
//+----------------------------------------------------------------------------+
//|  Версия   : 19.02.2008                                                     |
//|  Описание : Возвращает номер бара открытия последней позиции или -1.       |
//+----------------------------------------------------------------------------+
//|  Параметры:                                                                |
//|    sy - наименование инструмента   ("" или NULL - текущий символ)          |
//|    tf - таймфрейм                  (    0       - текущий таймфрейм)       |
//|    op - операция                   (   -1       - любая позиция)           |
//|    mn - MagicNumber                (   -1       - любой магик)             |
//+----------------------------------------------------------------------------+
int NumberOfBarOpenLastPos(string sy="0", int tf=0, int op=-1, int mn=-1) {
  datetime t;
  int      i, k=OrdersTotal();

  if (sy=="" || sy=="0") sy=Symbol();
  for (i=0; i<k; i++) {
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
      if (OrderSymbol()==sy) {
        if (OrderType()==OP_BUY || OrderType()==OP_SELL) {
          if (op<0 || OrderType()==op) {
            if (mn<0 || OrderMagicNumber()==mn) {
              if (t<OrderOpenTime()) t=OrderOpenTime();
            }
          }
        }
      }
    }
  }
  return(iBarShift(sy, tf, t, True));
}
 

Greetings, forum members

Can you please tell me if there is an indicator that could display a single total total position if I have the same positions on a particular pair.

For example, I have 7 sell positions on gbp/usd and I would like to see one total sell position on this pair

If something similar has already been implemented, please suggest a name

 


Can you please tell me,

Why during testing of an Expert Advisor with the visualization mode turned on, all graphic markup of performed deals disappears after the end of testing?

At the same time, during the test it is there.

 

Hello people.

Answer my loose-question, please. Or please give me a link. Question: What trading servers do you use with MetaTrader 4? Are there any free trade servers where you can register or guest usernames and passwords?

Thank you for your feedback.

 
Guest77:

Hello people.

Answer my loose question, please. Or give me a link. Question: What MetaTrader 4 trade servers do you use? Are there free trade servers where you can register or guest login and password?

Thank you for your feedback.




On the forex market, almost all servers are free.

And even more, almost every DC has demo accounts where you can trade with virtual money instead of real money.