Errors, bugs, questions - page 409

 
T-G:

Please advise how the following code will work on mql5 I do not understand

in frequency how to get the current hour?
Here you go
//+------------------------------------------------------------------+
//|                                                       пример.mq5 |
//+------------------------------------------------------------------+
#property copyright ""
#property link      ""
#property version   "1.00"

input int HourOpen=4;

MqlDateTime str;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---

//---
   return(0);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---

  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   TimeToStruct(TimeCurrent(),str);

   if(str.hour==HourOpen)
     {
      // действие
     }
  }
//+------------------------------------------------------------------+
 
sergey1294:
See
TimeCurrent() has an overload, so you can take the time directly (bypassing TimeToStruct()), although your version is also correct.
 

stringo:

So the serious problems are caused by the implementation of this option?

void OnTrade(
             const string symbol,//символ, от которого (по которому) пришло торговое событие
             const uchar type,   //тип торгового события (изменения в ордерах, позициях или сделках)
             const ulong ticket  //тикет ордера или сделки, либо идентификатор позиции (в зависимости от второго параметра)
             );

Exactly. The thing is that the trade and the message queue are not synchronized in any way. One and the same ticket may receive a bunch of messages.

Moreover, when you receive the first message from this heap, you know nothing about the availability of further messages on the same ticket. You rushed to process a ticket modification, but the ticket already exists, it already in the history of closed positions. What to do? Unknown.

Now, when an impersonal trading event occurs, you can immediately know the current status of the open positions and the trading history. You don't have a ticket number and you have nothing to reference other than the current status.

Been out of touch for a couple of days.

Maybe, there are different variants of using possible parameters from theOnTrade() function, but my aim is this variant:

1. orders. Upon receiving the next message "from the pile", I find out from the order ticket whether the order is in the list of open orders(OrderSelect) or in the list of historical orders(HistoryOrderSelect). I.e. I get the most up to date information on the current location of a certain order, in relation to the lists of orders.

2. Positions. Upon receiving the next message "from the heap", I find out the position state of this symbol by its name(PositionSelect). I.e., I also get the most accurate information about the current state of the position.

Then I work with the properties of a specific symbol, as necessary.

Thus, I try to avoid excessive use of cyclic checks.

 
Urain and sergey1294 thanks for the prompt reply, now I understand
 
AlexSTAL:
What does it say? What are the symptoms?

Nothing! I am trying to open a demo account (I have tried different DCs)

comes back

and then can not create an account

 
papaklass:
If you are a demo trader you only need to know if a stop loss or take profit is triggered and on which instrument. The rest of the trading events are exotic and have little to do with trading. IMHO. Therefore, if there were a symbol in OnTrade() function, it would be possible to determine (for example, comparing the current balance with the previous one) what sl or tp triggered.
I agree. At the very least you need a symbol, and then we'll figure out what it was.
foxes:

Trying to open a demo account (I tried different brokerage companies)

comes up

I tried different brokerage companies and after that I cannot open an account.

When did you download the terminal and where? A screenshot of the next window is desirable, as this one is not informative.
 

To the developers of

Is Win 2003 SP2 (in terminal mode) constantly losing information about my trading account is a bug or it was designed to improve security?

More precisely, if I alternately use the same program copy in normal and terminal mode with different accounts the account data disappears from time to time. Apparently, if you just work in terminal mode with different accounts, the situation will be similar (I haven't checked that yet).

 
papaklass:
Most traders need to know whether a stop loss or take profit has been triggered and on which instrument. The rest of the trading events are exotic and have little to do with trading. IMHO. Therefore, if there were a symbol in function OnTrade(), then by comparing, for example, the value of the current balance with the previous one, you could determine whether it was sl or tp that triggered.
In "protection of ticket" :) I prefer to work with pending orders and trace their fate from birth to retirement. What is this "exotic with little relation to trading"? On the contrary, it is a requirement of time to track the fate of orders by their ticketing. - It is necessary to avoid placing a second pending order or overshooting the triggering of an order that has already been placed. If we have the parameters described above, we can move the order spot tracking block to OnTrade() function.
 
papaklass:
Most traders need to know whether a stop loss or take profit has been triggered and on which instrument. The rest of the trading events are exotic and have little to do with trading. IMHO. Therefore, if there were a symbol in function OnTrade(), you could determine (for example, comparing the current balance with the previous one) what triggered sl or tp.
I will repeat it once again. The issue is not closed. It has been postponed until we find an acceptable solution. Well, the more important tasks have not been solved yet.
 
Yedelkin:
In the Ticket's defence :) I prefer to work with pending orders and track their fate from birth to retirement. What kind of "exoticism of little relevance to trading" is that? On the contrary, it is a requirement of time to track the fate of orders by their ticketing. - It is necessary to avoid placing a second pending order or overshooting the triggering of an order that has already been placed. If we have the parameters described above, we can move the order spot tracking block to OnTrade() function.
Perhaps, giving information about how many trade events are still in the queue will simplify things.
Reason: