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

 
Valerius:


Try to refresh quotes. Service - Quote Archive - select your currency pair - download.

If that doesn't help, reinstall the metatrader.


I tried to reinstall several times and even open a new account.... It did not work. What could it be related to?

Thank you.

 
sidovi:


I tried reinstalling several times and even opening a new account.... Didn't work. What could it be related to?

Thank you.


Did you delete all the files in the MetaTrader installer folder before installation?

And have you tried with the quote archive?

 
a196012a:

All larger orders will only open with a volume of 0.3 lots. All orders of smaller volume which are opened in response to a close on the SL in the volume of 0.3 lots will open in the volume of 0.1 lot. Only 0.1 and 0.3. There are no other volumes.

While closing a 0.3 lot order through the SL, please remember the hour when the order was opened in reply to the closing of which it was opened (i.e. 0.1 lot order).

Thank you for your help.

Could you please tell me please where the option is set to send a message to my e-mails when somebody replies to my post.

Thanks again very much.


And you actually what you need, an algorithm or the written function itself?
 
a196012a:

Thank you for your feedback.

I need either the algorithm or the function.

The main thing is for the code to remember the value of the hour after I close a 0.3 SL order

I do not know how to code exactly this action.

If an order with a volume of 0.3 closed on the SL

{
A2= value for the hour when the order of a smaller volume was opened in response to the close of which it was opened
}

===================================================================================================

If several orders with a volume of 0.1 closed at SL on SINGLE TICK

{

open a separate order of 0.3 volume at the closing price of EVERY closed order

}

===================================================================================================

If several orders with a volume of 0.3 closed on a SL in ONE TIKE

{

remember the value of the opening hour of EVERY relevant order by volume 0.1

}

I wrote a working code to open and close orders (see first post)

I am not sure what code to include in it to save 0.1 order open time.

I do not know how to code the opening of orders and remember the opening hour value in case several orders are closed on one tick.

If in connection with the realization of my idea to change the code I have written - I do not mind if you change it.

THE FINAL GOAL OF MY PROGRAM IS TO MEMORIZE THE OPENING HOUR VALUE. All other operations (including opening orders) are subordinate to this final goal and are of an auxiliary nature.

If I knew how to do without them, I would not have included them in the code.

Thanks again.


Here is an example of a program. Please take a look at it. There's some comments in there.

extern int MagicNumber=123;

datetime time;
//=================================================================
void start()
{
int er,se;

if(prov_open_orders()) //Проверяем, есть ли открытые ордера
 {
  se=sear();//Ищем последний ордер, который закрылся по стопу. Если последний ордер закрылся по профиту
            //то просто возвращается нулевое значение
            //Если Последний ордер закрылся по по стопу, то ищем ордер с лотом 0.1 и возвращаем
           //его время открытия. В переменной time будет время открытия ордера с лотом 0.1
  if(se==1)
   {
    if(OrderType()==OP_BUY && OrderProfit()<0)
     {//Если закрылся по стопу, то открываем противоположный ордер с увеличенным лотом
      er=OrderSend(Symbol(),OP_SELL,0.3,Bid ,3,Bid+400*Point,Bid-200*Point,"jfh",MagicNumber);
      time=SearTim(se);//Теперь находим время ордера с лотом 0.1
     }
   }
  if(se==2)
   {
    if(OrderType()==OP_SELL && OrderProfit()<0)
     {//Если закрылся по стопу, то открываем противоположный ордер с увеличенным лотом
      er=OrderSend(Symbol(),OP_BUY,0.3,Ask ,3,Ask-400*Point,Ask+200*Point,"jfh",MagicNumber);
      time=SearTim(se);//Теперь находим время ордера с лотом 0.1
     }
   }
 }

return;
}

//========================
bool prov_open_orders()
{
for(int is=OrdersTotal()-1; is >= 0; is--)
   {
    if(OrderSelect(is, SELECT_BY_POS, MODE_TRADES))
      {
       if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber)
         {
          if(OrderType()==OP_BUY || OrderType()==OP_SELL)
           {
            return(false); // есть открытые ордера (любые)
           }
         }
      }
   }
return(true);
}

//=================================================================
datetime SearTim(int s)
{
for(int is=OrdersHistoryTotal(); is>=0; is--)
   {
    if(OrderSelect(is, SELECT_BY_POS, MODE_HISTORY))
      {
       if(OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber)
         {
          if(OrderType()==OP_SELL && OrderProfit()<0 && OrderLots()==0.1)
           {//Если закрылся по стопу, то открываем противоположный ордер с увеличенным лотом
            return(OrderOpenTime());
           }
          if(OrderType()==OP_BUY && OrderProfit()<0 && OrderLots()==0.1)
           {//Если закрылся по стопу, то открываем противоположный ордер с увеличенным лотом
            return(OrderOpenTime());
           }
         }
      }
   }
return(NULL);
}

//=================================================================
int sear()
{
for(int is=OrdersHistoryTotal(); is>=0; is--)
   {
    if(OrderSelect(is, SELECT_BY_POS, MODE_HISTORY))
      {
       if(OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber)
         {
          if(OrderProfit()>0)
           {//Если  закрылся по профиту то просто ухоим из цикла.
              return(0);
           }
          if(OrderType()==OP_SELL && OrderProfit()<0)
           {//Если закрылся по стопу, то открываем противоположный ордер с увеличенным лотом
            return(2);
           }
          if(OrderType()==OP_BUY && OrderProfit()<0)
           {//Если закрылся по стопу, то открываем противоположный ордер с увеличенным лотом
            return(1);
           }
         }
      }
   }
return(0);
}
 
Valerius:


Did you delete all the files in the folder where Metatrader is installed before installation?

And have you tried with the quote archive?


Yes, 0 result :((
 
sidovi:

Yes, 0 result :((


Then you have to contact your DC for support...

It's the first time I've seen that.

 
Valerius:


Then only contact your DC for support...

This is the first time I've seen this.


Do you think there is a service in windows 10 that affects this?
 
sidovi:

Do you think there is a service in windows 10 that affects this?

No. There isn't.
 
Victor Nikolaev:

No. There isn't one.

Thank you
 
a196012a:

Thank you very much for your help

I'm just learning the basics of programming from Kovalev's tutorial and the functions described in it.

I've encountered some functions in your code, which I haven't seen in my books or in Code Base

Here are the functions I do not know

sear();

SearTim(se);

prov_open_orders()

I'd be very grateful if you tell me where I can read about them.

Right in that very code.