Maximum length of a symbol name on FOREX - page 8

 
fxsaber:

In fact, it's a hammering. Since it is possible to not wait for the order to be tracked. The only non-alternative onTradeTransaction is if the order is rejected. For example, if there is not enough money.


It turns out that we made a hundred Async-transactions filling the array (list) with appropriate mages and requesters. As soon as OnTradeTransaction received the response on the quest, we removed the element from the list. As soon as we saw the highlighting of a majic from the list among the living/dead, we removed the entry. That's how control is achieved more or less. Have you got it right?


You can still use other fields - SL/TP, Comment - instead of magic.

Yes, exactly like that. OnTradeTransaction is never disabled, just the check function is called periodically (if OnTradeTransaction is not triggered ). As soon as everything with the order is detected, the flags are reset.

How do I use the comment as SL/TP?

 
fxsaber:

Why wait when you can check on every On-stream?

Because in my strategies it's what came in the OnTradeTransaction that matters.

I don't use On-puke :)

Added

If the event came inOnTradeTransaction then everything is reset, so there is no hitch.

 
prostotrader:

How to use the commentary ronyatno, but as SL/TP?

Above supplemented...

You set the fake SL, in the value of which the info you need is stored. For example, that's how I stored the opening price of a position in MT4, which was fetched via a Limiter.

 
prostotrader:

Because in my strategies it is important exactly what came in OnTradeTransaction.

So make sure to check for magics directly in OnTradeTransaction. I would do it that way.


In general, the idea of megics as an alternative to reqests is cool!

 
fxsaber:

Above supplemented...

You set a fake SL, in the value of which the information you need is stored. For example, that's how I stored the opening price of a position in MT4, which was filled through the Limiter.

Is it possible to set SL when there is no position?

 
prostotrader:

Is it possible to expose SL if there is no position?

It may not be possible to do so for markdowns. I've been trading through limit orders only for a long time now.

 
fxsaber:

It may not be possible to do this for markets. For a long time now I have only been trading through limit orders.

"It's a bit odd to store information like that. Well, yes, you should know.

As FOREX market does not interest me at all, 6 symbols of symbol name and 65365 tags on one chart are more than enough for my needs,

Moreover, I can perform only 2000 transactions per trading day.

 
prostotrader:

Since the FOREX market does not interest me at all, the 6 characters of the symbol name and 65365 mogic on one chart is more than enough for my needs,

Moreover, I can carry out only 2000 transactions in a trading day.

It's not about forex. And there the same problems with OnTradeTransaction. Therefore a universal solution

#include <crc64.mqh> // https://www.mql5.com/en/blogs/post/683577

string GetMagicString()
{
  return(MQLInfoString(MQL_PROGRAM_PATH/*MQL_PROGRAM_NAME*/) + _Symbol + (string)ChartID()/* + (string)_Period*/);
}

// Формирует мэджик с изменяемой частью ReserveBits для прописывания туда Num-значения
ulong GetMagic( const int Num = 0, const int ReserveBits = 12 )
{
  uchar Bytes[];
  
  return((crc64(0, Bytes, (StringToCharArray(GetMagicString(), Bytes))) << ReserveBits) + (Num % (1 << ReserveBits)));
}

// Определяет, свой ли исходный мэджик с изменяемой частью ReserveBits
bool IsMyMagic( const ulong Magic, const int ReserveBits = 12 )
{
  return(GetMagic(0, ReserveBits) >> ReserveBits == Magic >> ReserveBits);
}

#define  PRINT(A) Print(#A + " = " + (string)(A))

void OnStart()
{  
  for (int i = 0; i < 10; i++)
  {
    PRINT(GetMagic(i));
    PRINT(IsMyMagic(GetMagic(i)));
  }
  
  PRINT(IsMyMagic(MathRand()));
}
 

Of course, the event model is inconvenient in this case. For example, if you want to make Async operations without exiting the On-function and get results from them.

Now it's possible to release this behavior through a crutch.

  1. We write an indicator (without buffers and input variables) with OnTradeTransaction that writes all the transactions in a public place (for example, in a resource).
  2. The Expert Advisor creates this indicator through iCustom.
  3. At any execution place the Expert Advisor can view all the incoming transactions written by the indicator.

This allows for great flexibility.

For example, we can send a hundred of Async orders and wait for their execution without getting out of the deepest part of the program, and then continue to execute our code.


We're talking, of course, about Requests. And the magic theme has nothing to do with it.


Although it would make sense for developers to write transactions to a publicly accessible array. Without indicator.

 
fxsaber:

It's not about forex. And there the same problems with OnTradeTransaction. Therefore a universal solution.

Although it's possible (and even better) to do without bitwise operations - just crc64 + Num.
2018.08.25 22:10:48.913 Test (BR-9.18,M1)       1749671450686091264
2018.08.25 22:10:48.914 Test (BR-9.18,M1)       1749671450686091265
2018.08.25 22:10:48.914 Test (BR-9.18,M1)       1749671450686091264
2018.08.25 22:10:48.914 Test (BR-9.18,M1)       1749671450686091265
2018.08.25 22:10:48.914 Test (BR-9.18,M1)       1749671450686091264
2018.08.25 22:10:48.914 Test (BR-9.18,M1)       1749671450686091265
2018.08.25 22:10:48.914 Test (BR-9.18,M1)       1749671450686091264
2018.08.25 22:10:48.914 Test (BR-9.18,M1)       1749671450686091265
2018.08.25 22:10:48.914 Test (BR-9.18,M1)       1749671450686091272
2018.08.25 22:10:48.914 Test (BR-9.18,M1)       1749671450686091273

There are coincidences...

Reason: