Features of the mql5 language, subtleties and tricks - page 149

 
fxsaber:

Thank you, good rule. Became a victim of my own incompetence. Really, need some more rule for such a more obvious case.


Maybe for both cases Warning clever to do?

Don't)))) It would be boring at all)))

 
Vladimir Simakov:
What is the problem with this code? Deinit nailed the object by a constant pointer (I know the handle here). Normal limb firing in C++ style, otherwise the creators have dissolved everyone)))

There will be no problems at start-up. Once started, you can wait for a while and then create a situation for the EA that its execution will break down.

It's not a mystery, it's just that understanding comes much better if you look for the problem in seemingly innocuous code.
 
fxsaber:

There will be no problems at start-up. Once started, you can wait for a while and then create a situation for the EA that its execution will break down.

It's not a mystery, it's just that understanding comes much better if you look for the problem in seemingly innocuous code.
I know what the problem is. Change of time frame and oops... I mean, it's standard here. Warning? What for? For myself, when confronted with such a thing myself, I only count it in the raising of my skill. With your example, IMHO, here on the force of 20 percent of the community are able to encounter, so why deprive them of development?
 
Vladimir Simakov:
I know what the problem is here. Change of time frame and oops... I mean, it's standard here. Warning? What for? For myself, when confronted with such a thing myself, I only count it in the raising of my skill. With your example, IMHO, here on the force of 20 percent of the community are able to encounter, so why deprive them of development?

I had an even more interesting situation. There was no change of anything, but OnDeinit was called after the reconnect. Now I'll keep an eye on Reason.

 

I am constantly faced with the need to search the Market Watch for the required symbol. For example, the current chart symbol.

Each time it takes a lot of precious time. I've made it automated by hotkeying the following script.

// После запуска и нажатия ENTER делает активным в Обзоре рынка символ чарта.
#include <WinAPI\winuser.mqh>

#define  GA_ROOT           0x00000002

#define  WM_KEYDOWN        0x0100
#define  WM_LBUTTONDOWN    0x0201

#define  VK_DELETE         0x2E

#define  WM_CHAR           0x0102

#define  GET_HANDLE                                                                       \
  long Handle = user32::GetAncestor(::ChartGetInteger(0, CHART_WINDOW_HANDLE), GA_ROOT); \
                                                                                         \
  for (int i = 0; i < sizeof(ControlID) / sizeof(int); i++)                              \
    Handle = user32::GetDlgItem(Handle, ControlID[i]);


bool SetSymbolNavigator( const string SymbName )
{
  const bool Res = ::SymbolInfoInteger(SymbName, SYMBOL_EXIST);

  if (Res)
  {
    static const int ControlID[] = {0xE81C, 0x804B, 0x27A0, 0x271B, 0x3E9};
    GET_HANDLE

    user32::SendMessageW(Handle, WM_LBUTTONDOWN, 0, 0);
    user32::SendMessageW(Handle, WM_KEYDOWN, VK_DELETE, 0);

    const int Size = ::StringLen(SymbName);
    
    for (int i = 0; i < Size; i++)
      user32::SendMessageW(Handle, WM_CHAR, SymbName[i], 0);
  }

  return(Res);
}

void OnStart()
{
  SetSymbolNavigator(_Symbol);
}
 
fxsaber:

I'm always faced with the need to search the Market Watch for the required symbol. For example, the current chart symbol.

Each time it takes a lot of precious time. I've automated it by using the following script as a hotkey.

Colleague, clarify the purpose. Do you want the symbol to appear in the "Market Watch" or should it be highlighted in the "Market Watch"?

 
Denis Kirichenko:

Colleague, clarify the purpose. Do you want the symbol to appear in the Market Watch or should it be highlighted in the Market Watch?

To be highlighted. A lot of custom ones, for example. I need to run Tester on that custom one, which chart I can see.

Then I run this script and after that, I drop the selected symbol in Market Watch with the mouse into the tester. It all takes a couple of seconds.

 
fxsaber:

To be highlighted. For example, there are plenty of custom ones. I need to run the tester on that custom one, whose chart I can see.

Then I run this script, and after that, I drop the highlighted character in Market Watch with the mouse into the tester. It all takes a couple of seconds.

Well then this script does not work for me. Nothing happens, the symbol is not highlighted.

Launch, press Enter. I see an error in the log:

2019.11.29 11:47:38.609 Error   file C:\Users\Admin\AppData\Roaming\MetaQuotes\Terminal\5 B326B03063D8D9C446E3637EFA32247\MQL5\Scripts\Shared Projects\Testing\fxsaber\SetActiveSymbol.mq5 not found

Yes, I named the scriptSetActiveSymbol.mq5.

 
Denis Kirichenko:

I see an error in the logs

It just won't start like that. There is no file.

 
fxsaber:

It just won't start like that. There is no file.

There is. I've only given one entry from the log. The full one is like this:

2019.11.29 12:37:18.851 Scripts script SetActiveSymbol (AUDJPY,H1) loaded successfully
2019.11.29 12:37:18.878 Scripts script SetActiveSymbol (AUDJPY,H1) removed
2019.11.29 12:37:26.419 Error   file C:\Users\Admin\AppData\Roaming\MetaQuotes\Terminal\5 B326B03063D8D9C446E3637EFA32247\MQL5\Scripts\Shared Projects\Testing\fxsaber\SetActiveSymbol.mq5 not found