Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 552

 
VasiliKolchanov:
Ihor thank you for your reply, only one question, it won't be a delay, i.e. alerts will be accumulated with every tick during the pause, and at the end of time EA will send me all of them anyway (all accumulated) ? It may sound ridiculous, but sorry newbie - I'm learning.

It won't, because it won't get to the point of triggering an alert. You will get one alert and then, after a set period of time, another alert and so on.

 
Vitaly Muzichenko:

Actually it should be the other way round)

Thank you!!!

 

Explain what is wrong here. I set an order opening on a daily breakdown on daily candlesticks. I.e., at 00:00, a new daily candle opens inside the previous candle.



double open1, close1, open, close;

open1=iHigh(NULL,PERIOD_D1,1);

close1=iLow(NULL,PERIOD_D1,1);

open=iHigh(NULL,PERIOD_D1,0);

close=iLow(NULL,PERIOD_D1,0);


if(O(m)==false){ //if there is no order

if(open1<Ask){

b(......);} //open order


if(close1>Ask){

s(.......);}}/open order



Moscow time, the order opens inside the previous candle at 00.03, I was watching at night at 00.03 as a new candle was formed and it still opened the order. It is as if the EA does not see a new daily candlestick.

Although I did the exact same one on hourly breakdown, it works perfectly.

If I enable my EA at 06.00, it will work as it should, but I will not like the fact that daytime breakdowns happen before 06.00 and orders will open in wrong places after 06.00. The problem is in the time difference between the daily candle and Moscow time. DC grand capital


Help! Please!

 
Evgeniy Oshurkevich : You have answered your own question. Candlesticks are drawn on the server time. And your local one may not coincide with it.

So leave the owl overnight, if normally written, it will put you in a position. Or calculate your candlesticks on the time interval you are interested in.

 
Ihor Herasko:

It won't, because it won't get to the point of triggering an alert. You will get one alert and then, after a set period of time, another one

Thank you !

 

Please advise how to deal with a situation where an open order postponed to tomorrow, automatically with the opening of a new session carried profit on the specified parameters? The only question is: how do I recognize a new session? The new bar detecting function won't work in my situation. Maybe someone knows how to return separately the year, month and day of opening of the order, I will solve the problem in this case, I don't know how to do the rest.

 
VasiliKolchanov:

Please advise how to deal with a situation where an open order postponed to tomorrow, automatically with the opening of a new session carried profit on the specified parameters? The only question is: how do I recognize a new session? The function of recognizing a new bar will not work in my situation. The rest I have an approximate idea how to do.

Obviously - the function of recognizing a new session is needed)

 
VasiliKolchanov:

Maybe someone knows how to return separately the year, month and day of opening of this order, then the problem would be solved. I do not know how to do the rest. And do not know whether it will help me or not suggest in what format return value function OrderOpenTime (year.month.day.hour : min : sec OR hour : min : sec) ?

here i have sketched and tested a script which will check the history of closed orders (i don't have market orders right now, you can redo it yourself) and find the last closed order and log it:

#property strict
//+------------------------------------------------------------------+
void OnStart()
  {
   int i,otype,k=OrdersHistoryTotal();
   string sy=Symbol();
   datetime oclose,t=0;
   for(i=0; i<k; i++) 
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)) 
        {
         otype    = OrderType();
         oclose   = OrderCloseTime();
         if(OrderSymbol()==sy)
           {
            if(otype==OP_BUY || otype==OP_SELL)
              {
               if(t<oclose)
                 {
                  t=oclose;
                 }
              }
           }
        }
     }
   Print("Последний ордер закрыт: ",TimeDay(t)," день, ",TimeHour(t),"час, ",TimeMinute(t)," минуты");
  }
//+------------------------------------------------------------------+

result:

21:12:07.558 test EURUSD,H1: Last order closed: day 27, 21h, 17 min

 
Taras Slobodyanik:

obviously - a new session recognition function is needed)

What does it look like Taras ?
 
Igor Makanu:

I have sketched and tested a script which will check the history of closed orders (I don't have a market order right now, you can redo it yourself) and find the last closed order and log the information about it:

result:

21:12:07.558 test EURUSD,H1: Last order closed: day 27, 21h, 17 min

Reason: