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

 
alex12:

Outputs 2 errors

'clOpenBuy' - variable not defined .mq4 (40, 49)

clOpenBuy - variable not defined

I rewrote the code again and it fails to correct these 2 errors.

alex12, I don't understand you. You have a few jobs in kodobase and you ask such questions. You've already covered several threads with them.

The clOpenBuy variable isn't defined. So it must be defined. Judging by the code, it is something similar to the colour associated with the opening of a buy order.

How the variable is defined, you should know exactly. Since it is used in several different functions, it should probably be global. So define it as global. And all the more so because

color clCloseBuy;

You have defined it.

 

It generates a lot of errors


 

Sorry, alex12, but you look like a bulldozer (no offence, that's an accepted term). You make something out of different pieces and somehow get it to compile, but you don't understand the meaning of the code.

Contact the Jobs service.

 
alex12:

It generates a lot of errors


When using some of Igor Kim's functions, make sure you have his missing functions in your code which the compiler tells you about. Find them in his branch and write them in your code.
 
chief2000:
...

OrderOpenTime() shows the time when the position was opened, my question is how do I know the time when the STOP order was set?
The MT4 report has this time, but is it possible to find it out from the code?


Once again.

Go through all of your stop orders in a "standard" cycle, and for yourself, unprint the value of the OrderOpenTime() for them - this must be the time at which they (each of them) were set. Here is an example for market orders - adjust it a bit, i.e., or remove this line altogether

if ((orderType != OP_BUY) && (orderType != OP_SELL)) continue;

or replace it with data from the stop orders you are interested in...

int orderCount = 0; // сбрасываем счетчик ордеров 
      // ------------------------------------------------Считаем только наши ордера---------------------------
   int orderType;
   for (orderIndex = (OrdersTotal() - 1); orderIndex >= 0; orderIndex--)
   {
      if (!OrderSelect(orderIndex, SELECT_BY_POS))     continue; // если ордер не выбран, то идем на следующий открытый
      if(OrderCloseTime()!=0) continue;                          // если тикет принадлежит закрытому ордеру, то берем следующий открытый
      if ((OrderSymbol() != Symbol()) || (OrderMagicNumber() != magic))   continue;
      orderType = OrderType();
      if ((orderType != OP_BUY) && (orderType != OP_SELL))   continue;
          ticket = OrderTicket( );                         // Номер ордера
          orderLots = OrderLots();                         // Lots   
          orderProfit = OrderProfit() + OrderSwap();       // Profit
          Price = OrderOpenPrice();                        // Цена открытия рыночного ордера
          SL =  OrderStopLoss();                           // Значение StopLoss ордера
          TP = OrderTakeProfit();                          // Значение TakeProfit ордера 
          Time = O rderOpenTime();
         
                     
         
      orderCount++;                     // считаем ордера (не больше i)           

    }   
 
Roman.:


Once again.
Go through all of your stop orders in a "standard" loop, and for yourself, unprint the value of OrderOpenTime() for them - this must be the time at which they (each of them) are set. Here is an example for market orders - adjust it a bit, i.e., or remove this line altogether

if ((orderType != OP_BUY) && (orderType != OP_SELL)) continue;

or replace it with data from stop orders you are interested in...

Here, at this stage I encountered a dilemma - I need the time of opening a STOP order for some "statistics" and I would not like this process to be run all the time, but only at a certain final step. For this reason, we do not need to search for the orders currently open (OrdersTotal()), but to search among the orders already closed => OrdersHistoryTotal().
But for STOP orders that have already been closed, OrderOpenTime() returns the time of position opening, not the time when the order was placed.
As a result, it all comes down to this: Is it possible to retrieve the time that the STOP orders from the list of OrdersHistoryTotal(), when they were established?
 
chief2000:
This is where I ran into a dilemma - I need the STOP order opening time for some "statistics" and I wouldn't want this process to run all the time, but only at a certain final stage. For this reason, we do not need to search for the orders opened at that moment (OrdersTotal()), but to search among the orders already closed => OrdersHistoryTotal().
But for STOP orders that have already been closed, OrderOpenTime() returns the time of position opening, not the time when the order was placed.
As a result, it all comes down to this: Is it possible to retrieve the time that the STOP orders from the list of OrdersHistoryTotal(), when they were established?

Yes... The challenge... I DON'T KNOW. Looks like you can't - especially in the "final stages"...

You have to constantly monitor this process and keep track of it - see the FAQ post on the previous page.

 
Roman.:

Yes... The challenge... I DON'T KNOW. Looks like you can't - especially in the "final stages"...

You have to constantly monitor this process and keep track - see the FAQ post on the previous page.

If no other solution is found, I will use orders from OrdersTotal().
Thanks anyway!
 
In that case, it is easier to write to a file, less hassle, and the statistics can be organised as you need them, not the terminal.
 
FAQ:
In that case, it's easier to write to a file, less hassle, and the statistics can be organised as you need them, not the terminal.
Thank you!