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

 
artmedia70:

For example, a function that automatically assigns an EA a unique magic number based on the name of the EA, the currency pair and the TF on which it is installed:

Call:



You can also assign a Magician using CRC32 to make sure it is unique. Or, you can quickly check the integrity of any data previously saved or received from another terminal, say, via the Internet. In this case, darb all function))). Use it wisely).

int crc_table[256];
 
/* Run this function previously */
void make_crc_table() 
{
    for (int i = 0; i < 256; i++) {
        int c = i;
        for (int j = 0; j < 8; j++) {
            if(c & 1 != 0)
               c = 0xEDB88320 ^ (c >> 1);
            else 
               c = c >> 1;
        }
        crc_table[i] = c;
    }
}
 
bool table_filled = false;

int crc32(string buf) 
{
    if(!table_filled)
    {
      make_crc_table();
      table_filled = true;
    }
    
    int len = StringLen(buf);
    
    int c = 0xFFFFFFFF;
    for (int i = 0; i < len; i++) {
        c = crc_table[(c ^ StringGetChar(buf,i)) & 0xFF] ^ (c >> 8);
    }
    return (c ^ 0xFFFFFFFF);
}
 
alsu:

And we can also assign a Magician using CRC32 to make sure it is unique. Or we can quickly check the integrity of any data previously saved or received from another terminal, say, via the Internet. In this case, darb all function))). Use it wisely).


Alexey, thank you for your interesting and well-written function. I will have a look at it. I've been thinking about a similar idea myself, and here it comes.

Well, here it is:


Victor, I looked in the Dock for you as well. So, these codes were seen in the indicators from CodeBase, which I used for manual trading. It turned out to be far from a panacea. So I threw out almost all indicators, and now my Expert Advisor is its own indicator, and I don't need almost anything else!

By the way, I learned a lot digging around in the Base! You have to be an expert yourself to grasp everything in the Dock! There's more detail in the textbook, but there's a lot missing!


Boris, I don't really use indicators myself. Unless it's a dash... And string functions are needed for other purposes. I wrote about it above. Here:

hoz:

So as not to read all sorts of crooked code, as herehttps://www.mql5.com/ru/articles/1524.

(I noticed there, a bunch of bugs. And in general, I do not know what the author was thinking when he wrote this code).

Please give me a hint on the algorithm of this variant. I want the pending order to follow the object, e.g. a trend line. Or the pending order was behind the line.

How is it implemented? I do not really understand it.

I understand that we should create an object. But we should somehow specify that if the price is "behind" the object, we should do something, or if the price is on the line, the pending order is on it.

 

Friends, can you give me a hint?

Is there a program that writes everything the terminal does?

Or how to make an EA write logs independently of the server?

 
polycomp:
Thanks for the clarification! Looks like it's best not to use statics in libraries.


And you shouldn't use them outside of them either. In MT4, variables of Static type are NEVER re-initialised.
 
herhuman:

How can I make the EA write logs independently of the server?

It does.
 
hoz:


For a start, just articulate clearly what you would like. Geometric approaches are welcome.
 
hoz:


Alexey, Thank you for an interesting and intelligently written feature. I'll have a look at it. I've been thinking of a similar idea myself, and here it is.


Boris, I don't really use indicators myself. Unless it's a waving machine... And string functions are needed for other purposes. I wrote about it above. Here:


Victor, I haven't dealt with this either, I've seen a lot of this in Base. As I understand it, price crossovers with lines are similar with swipes. Also catch line crossovers with your order and position parameters etc. Dig it out!
 

Dear Sirs, Could you please answer the following question for a newbie?

if (((((Bid>1.2153)&&(Bid<1.2160) || (Bid>1.2173)&&(Bid<1.2180)) || ( (Bid>1.2100)&&(Bid<1.2107) || (Bid>1.2094)&&(Bid<1.2101)) || (((Bid>1.2092)&&(Bid<1.2099) || (Bid>1.2091)&&(Bid<1.2098))||((Bid>1.2073)&&(Bid<1.2080)||(Bid>1.2005)&&(Bid<1.2012))))) // if the price matches one of the conditions listed in the if header

int Ticket=OrderSend(Symbol(),OP_BUY,0.1,Ask,3,SL,TP, "jfh",123 ) // open an order.

I have about 3000 non-repeating condition data, so I have placed them all in a one-dimensional array

double masiv [3000];

if ((Bid==masiv[5]) // if the price corresponds to the value of the array element with the index 5

int Ticket=OrderSend(Symbol(),OP_BUY,0.1,Ask,3,SL,TP, "jfh",123 ) // open the order.

QUESTION: Which code can be used to write the following command

If the price matches the value of any one of 3000 non-repeating values of the array double masiv [3000]

Open an order.

The simplest option is to put 3000 conditions in the if(.....) header.

But probably there are some more compact variants of the code.

Thanks for the help.


 
solnce600:

Dear Sirs, could you please tell a newcomer the answer to this question?

if (((((Bid>1.2153)&&(Bid<1.2160) || (Bid>1.2173)&&(Bid<1.2180)) || ( (Bid>1.2100)&&(Bid<1.2107) || (Bid>1.2094)&&(Bid<1.2101)) || (((Bid>1.2092)&&(Bid<1.2099) || (Bid>1.2091)&&(Bid<1.2098))||((Bid>1.2073)&&(Bid<1.2080)||(Bid>1.2005)&&(Bid<1.2012))))) // if price matches one of the conditions listed in the if header

int Ticket=OrderSend(Symbol(),OP_BUY,0.1,Ask,3,SL,TP, "jfh",123 ) // open an order.

I have about 3000 non-repeating condition data, so I have placed them all in a one-dimensional array

double masiv [3000];

if ((Bid==masiv[5]) // if the price corresponds to the value of the array element with the index 5

int Ticket=OrderSend(Symbol(),OP_BUY,0.1,Ask,3,SL,TP, "jfh",123 ) // open the order.

QUESTION: Which code can be used to write the following command

If the price matches the value of any one of 3000 non-repeating values of the array double masiv [3000]

Open an order.

The simplest option is to put 3000 conditions in the if(.....) header.

But there must be some more compact variants of the code.

Thanks for the help.




If necessary, a solution can be found. For example, switch to an integer ordered array. Search in it for the desired value.
 
solnce600:

Dear Sirs, could you please tell a newcomer the answer to this question?

if (((((Bid>1.2153)&&(Bid<1.2160) || (Bid>1.2173)&&(Bid<1.2180)) || ( (Bid>1.2100)&&(Bid<1.2107) || (Bid>1.2094)&&(Bid<1.2101)) || (((Bid>1.2092)&&(Bid<1.2099) || (Bid>1.2091)&&(Bid<1.2098))||((Bid>1.2073)&&(Bid<1.2080)||(Bid>1.2005)&&(Bid<1.2012))))) // if price matches one of the conditions listed in the if header

int Ticket=OrderSend(Symbol(),OP_BUY,0.1,Ask,3,SL,TP, "jfh",123 ) // open an order.

I have about 3000 non-repeating condition data, so I have placed them all in a one-dimensional array

double masiv [3000];

if ((Bid==masiv[5]) // if the price corresponds to the value of the array element with the index 5

int Ticket=OrderSend(Symbol(),OP_BUY,0.1,Ask,3,SL,TP, "jfh",123 ) // open the order.

QUESTION: Which code can be used to write the following command

If the price matches the value of any one of 3000 non-repeating values of the array double masiv [3000]

Open an order.

The simplest option is to put 3000 conditions in the if(.....) header.

But there must be some more compact variants of the code.

Thanks for the help.



Loop:

   double massiv[];  
//----------------------------------------------------------------------
   for (int i=0; i<ArrayRange(massiv,0); i++) {
      if (MathAbs(NormalizeDouble(Bid-massiv[i],Digits))<=0.5*Point) {
         // цена примерно совпадает со значением в massiv[i]
         // ... обрабатываем совпадение
         }
      }
//----------------------------------------------------------------------
Reason: