Lagging OI (open interest) - page 6

 
Renat Akhtyamov:

He's got a private room for that.

And now you're writing to the media, so we're having a discussion.

I also made it clear to you, use synchronous.

I do use synchronous, what else can I do from a submarine.

 
Dmi3:

....., but I'm not happy with the mechanism that prostotrader uses with crooked mages.


You either don't understand the nature of "crooked" mages at all or don't want to.

https://www.mql5.com/ru/blogs/post/557544

Отслеживание ордера, после команды OrderSendAsync
Отслеживание ордера, после команды OrderSendAsync
  • 2016.10.29
  • www.mql5.com
Отслеживание ордера, после команды OrderSendAsync Михаил | 23 апреля, 2015 В статье рассказывается принцип отслеживания ордера после команды OrderSendAsync, если нет события TradeTransaction
 
prostotrader:

You either don't understand the "crooked" magicians at all or don't want to.

https://www.mql5.com/ru/blogs/post/557544

Why? I understand exactly how it works. But I don't want to lose the "straight" mages. Without them it would be difficult for me to quickly find out where and what is in my account at the moment.

 
Dmi3:

Why? I understand exactly how it works. But I don't want to lose the "direct" medgies. Without them it would be difficult for me to quickly figure out where and what is in my account at the moment.

The majik is big, and both the constant part (strategy id, for example) and the "variable" part (request number) can be wrapped in it.

 
Stanislav Korotky:

The majik is big, so you can wrap both the constant part (strategy id, for example) and the "variable" part (query number) into it.

he has an int, not a long
 
Renat Akhtyamov:
He has an int, not a long

You won't believe it : ) Even with int magic you can trade 1000+ EAs with 1000000+ combinations of strategies in each.

 
prostotrader:

You hear a bell, you don't know where it is.

"Hitting" on the posted code.

......

How can you talk about results if the code is badly written?

......

So many "writers" of Expert Advisors, grasp at the work for MICEX, not even knowing many basics of trading on the Stock and Derivatives Market!


You are making too much out of it! The girl was doing fine, especially compared to the characters from the neighboring topics, who are trying to get sellers in the Market without even passing grades in Computer Science with BASIC))

 
Aleksey Mavrin:

You won't believe it : ) Even with int magic you can trade 1000+ EAs with 1000000+ combinations of strategies in each.

And if you have logic in your brain, you'll be fine without magicians.

By the way, I was just saying about int to go long if i'm really interested in it.

since the programmer, so to speak...
 
Aleksey Mavrin:


You're making a big deal out of it! The girl was all right, especially compared to the characters in the neighbouring threads, who go to the Market as salesmen without even passing the Basics test.)

what's wrong with her?

she doesn't even know what her output should be or what she needs to do for it.

even the experienced didn't tell me the tricky question because you can't talk about it on every corner

However, I know how to get the right result, because I dedicated about 5 years to studying this topic.

 
Dmi3:

Why? I understand exactly how it works. But I don't want to lose the "direct" medgies. Without them it would be difficult for me to quickly find out where and what is in my account at the moment.

If you write so, you do not understand how it all works!

The high bits of the Majic are formed from the name of the symbol, in addition, you can assign an ID to each EA, and the low bits

create a series of child majicles.

So, you have to claim you understand how it works!

//+------------------------------------------------------------------+
//|                                                    AutoMagic.mqh |
//|                                 Copyright 2017-2018 prostotrader |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
//version   "1.02
ulong symb_magic;
int exp_id;
//-------------------------------------------------------------------+
// Split string function                                             |
//+------------------------------------------------------------------+
string SplitString(const string a_str,ulong &a_month,ulong &a_year)
  {
   int str_size=StringLen(a_str);
   int str_tire=StringFind(a_str, "-");
   int str_tochka=StringFind(a_str, ".", str_tire);
   if((str_tire>0) && (str_tochka>0) &&(str_size > 0))
     {
      a_month= ulong(StringToInteger(StringSubstr(a_str,str_tire+1,str_tochka-str_tire-1)));
      a_year = ulong(StringToInteger(StringSubstr(a_str,str_tochka+1,str_size-str_tochka-1)));
      if((a_month > 0) && (a_year > 0)) return(StringSubstr(a_str, 0, str_tire));
     }
   return("");
  }
//-------------------------------------------------------------------+
// Get Magic function                                                |
//+------------------------------------------------------------------+
ulong GetMagic(const string a_symbol, const int sov_id)
{
  exp_id = -1;
  symb_magic = 0;
  if(SymbolSelect(Symbol(), true) == false)
  {
    Print(__FUNCTION__, ": Нет такого символа!");
    return(0);
  }
  ulong month = 0;
  ulong year = 0;
  string new_str = SplitString(a_symbol,month,year);
  if(StringLen(new_str)>0)
  {
    uchar char_array[];
    int result=StringToCharArray(new_str, char_array, 0, WHOLE_ARRAY, CP_ACP);
    if(result>0)
   {
     ulong value;
     for(int i = 0; i < result - 1; i++)
     {
       value=ulong(char_array[i]);
       value<<=(56 -(i*8));
       symb_magic += value;
     }
     month<<=24;
     symb_magic += month;
     year<<=16;
     symb_magic += year;
     exp_id = sov_id;      //New!!!
     int s_id = exp_id;
     s_id<<=8;             //New !!!   
     symb_magic += s_id;   //New !!!
     return(symb_magic);
   }
 }
  return(0); 
}
//-------------------------------------------------------------------+
// Is my magic function                                              |
//+------------------------------------------------------------------+
bool IsMyMagic(const ulong m_magic)
{
  if(m_magic > 0)
  {
    ulong stored_magic = symb_magic;
   // stored_magic>>=16;
    stored_magic>>=8;   //New!!!
    ulong in_magic = m_magic;
   // in_magic>>=16;
    in_magic>>=8;      //New!!!
    if(in_magic == stored_magic) return(true);
  }  
  return(false);
}
//-------------------------------------------------------------------+
// Get stored magic function                                         |
//+------------------------------------------------------------------+
ulong GetStoredMagic()
{
  if(symb_magic > 0) return(symb_magic);
  return(0);  
}
//-------------------------------------------------------------------+
// Get expert ID function                                            |
//+------------------------------------------------------------------+
int GetExpertId()
{
  return(exp_id);                //New!!!
}
//+------------------------------------------------------------------+

Check out

//+------------------------------------------------------------------+
//|                                                   Test_magic.mq5 |
//|                                      Copyright 2021 prostotrader |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021 prostotrader"
#property link      "https://www.mql5.com"
#property version   "1.00"
#include "AutoMagic.mqh"
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   ulong new_magic = GetMagic(Symbol(), 22);
   Print("Magic is: ", new_magic);
   ulong f_magic = new_magic;
   ulong a_letter = (f_magic>>56)&255;
   Print("7 byte: ", CharToString(uchar(a_letter)));   
   f_magic = new_magic;
   a_letter = (f_magic>>48)&255;
   Print("6 byte: ", CharToString(uchar(a_letter))); 
   f_magic = new_magic;
   a_letter = (f_magic>>40)&255;
   Print("5 byte: ", CharToString(uchar(a_letter))); 
   f_magic = new_magic;
   a_letter = (f_magic>>32)&255;
   Print("4 byte: ", CharToString(uchar(a_letter))); 
   f_magic = new_magic;
   a_letter = (f_magic>>24)&255;
   Print("3 byte (month): ", a_letter);
   f_magic = new_magic;
   a_letter = (f_magic>>16)&255;
   Print("2 byte (year)): ", a_letter);
   f_magic = new_magic;
   a_letter = (f_magic>>8)&255;
   Print("1 byte (expert id or series of magics): ", a_letter);
   f_magic = new_magic;
   a_letter = (f_magic&255);
   Print("0 byte (series of magics): ", a_letter);
//---
   return(INIT_SUCCEEDED);
  }

Result

2021.01.19 03:05:15.363 Test_magic (GOLD-3.21,M1)       Magic is: 5138409554846225920
2021.01.19 03:05:15.363 Test_magic (GOLD-3.21,M1)       7 byte: G
2021.01.19 03:05:15.363 Test_magic (GOLD-3.21,M1)       6 byte: O
2021.01.19 03:05:15.363 Test_magic (GOLD-3.21,M1)       5 byte: L
2021.01.19 03:05:15.363 Test_magic (GOLD-3.21,M1)       4 byte: D
2021.01.19 03:05:15.363 Test_magic (GOLD-3.21,M1)       3 byte (month): 3
2021.01.19 03:05:15.363 Test_magic (GOLD-3.21,M1)       2 byte (year)): 21
2021.01.19 03:05:15.363 Test_magic (GOLD-3.21,M1)       1 byte (expert id or series of magics): 22
2021.01.19 03:05:15.363 Test_magic (GOLD-3.21,M1)       0 byte (series of magics): 0

Change the symbol and id of the EA to 122

2021.01.19 03:07:06.225 Test_magic (RTS-3.21,M1)        Magic is: 5932457868670630400
2021.01.19 03:07:06.225 Test_magic (RTS-3.21,M1)        7 byte: R
2021.01.19 03:07:06.225 Test_magic (RTS-3.21,M1)        6 byte: T
2021.01.19 03:07:06.225 Test_magic (RTS-3.21,M1)        5 byte: S
2021.01.19 03:07:06.225 Test_magic (RTS-3.21,M1)        4 byte: 
2021.01.19 03:07:06.225 Test_magic (RTS-3.21,M1)        3 byte (month): 3
2021.01.19 03:07:06.225 Test_magic (RTS-3.21,M1)        2 byte (year)): 21
2021.01.19 03:07:06.225 Test_magic (RTS-3.21,M1)        1 byte (expert id or series of magics): 122
2021.01.19 03:07:06.225 Test_magic (RTS-3.21,M1)        0 byte (series of magics): 0

Add to code

   for(int i = 0 ; i<256;i++)
   {
     Print("My magic: ", string(IsMyMagic(new_magic + ulong(i))));
}Print("My magic: ", string(IsMyMagic(new_magic + ulong(256))));

Result

2021.01.19 10:25:45.855 Test_magic (RTS-3.21,M1)        My magic: true
2021.01.19 10:25:45.855 Test_magic (RTS-3.21,M1)        My magic: true
2021.01.19 10:25:45.855 Test_magic (RTS-3.21,M1)        My magic: true
2021.01.19 10:25:45.855 Test_magic (RTS-3.21,M1)        My magic: true
2021.01.19 10:25:45.855 Test_magic (RTS-3.21,M1)        My magic: true
2021.01.19 10:25:45.855 Test_magic (RTS-3.21,M1)        My magic: true
2021.01.19 10:25:45.855 Test_magic (RTS-3.21,M1)        My magic: true
.......................................................................
2021.01.19 10:53:40.451	Test_magic (RTS-3.21,M1)	My magic: false

The symbol name + EA id will make sure that the magik is unique,

and in the 0 byte, a series of child majiks (also unique).

The bigge will be automatically created.

Since the FORTS standard login is limited to 30 tr./sec, 256 child magics will be enough for you without 1 byte.

And all this "dancing with knuckles" is needed only in extreme cases, when the connection is lost (MT5 server crashed) and you have not received a ticket order.

Документация по MQL5: Предопределенные переменные / _Symbol
Документация по MQL5: Предопределенные переменные / _Symbol
  • www.mql5.com
_Symbol - Предопределенные переменные - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
Reason: