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

 
HistorySelect.

Forum on trading, automated trading systems and trading strategy testing

MT5 and Speed in Action

fxsaber, 2020.09.02 00:32

If someone tries to use shared libraries where the from-input parameter doesn't match, you'll get slows.


The other HistorySelect.

Forum on trading, automated trading systems & strategy testing

MT5 and Speed in Action

fxsaber, 2020.09.02 00:52

HistoryDealSelect and HistoryOrderSelect should necessarily be written like this.

  static bool HistorySelectOrder( const ulong Ticket )
  {
    return((::HistoryOrderGetInteger(Ticket, ORDER_TICKET) == Ticket) || ::HistoryOrderSelect(Ticket));
  }

  static bool HistorySelectDeal( const ulong &Ticket )
  {
    return((::HistoryDealGetInteger(Ticket, DEAL_TICKET) == Ticket) || ::HistoryDealSelect(Ticket));
  }

Otherwise, you are guaranteed to encounter slows.

Forum on trading, automated trading systems and testing of trading strategies

MT5 and Speed in Action

Renat Fatkhullin, 2020.09.02 00:40

When you work with huge volumes (and you showed thousands and tens of thousands of deals in history for a reason), which require atomic/snapshot access, you need to understand their cost.

 
If the EA has MessageBox in OnInit, there are a number of things to do to get around the potential problem of re-logging.
 
It is advisable to minimise the number of calls to in-house functions to reduce the likelihood of encountering their not infrequent lags.
 

Can't win

2020.04.01 11:49:34 failed instant sell 0.32 EURUSD at 1.09539 [Invalid volume]

I have a check on the total volume limit in the market.

I do not know why I got such an error

In the marketplace validator
 
Vladimir Pastushak:

Can't win

2020.04.01 11:49:34 failed instant sell 0.32 EURUSD at 1.09539 [Invalid volume]

I have a check on the total volume limit in the market.

I do not understand why I got such an error.

In the marketplace validator

You could not hit the order limit? I think it was like that.

 
Edgar Akhmadeev:

Could you have run into a limit on warrants? I think I did.

It says wrong volume, availability of funds is checked, exceeding the lot limit is also checked. Keep digging...

 
Vladimir Pastushak:

It doesn't say the right amount.

Edgar Akhmadeev:

I seem to have had it.

...that a small volume did not open with a large deposit. I don't remember the details, but one of the brokers on the cent had a very small order limit on the instrument.

 

There is the following problem in MT5. I need to test the operation of the trading panel in the strategy tester in visual mode. The trading panel has input fields (OBJ_EDIT). When you change the text in the input field and press ENTER, the new text does not appear, instead, the original text that was set when the input field was created appears. That is, it is not possible to change the text in the input field during visual testing of the panel.

How can this be solved?

Example code:

void OnTick()
  {
   string name="EDIT";
   if(ObjectFind(0,name)==-1)
     {
      ObjectCreate(0,name,OBJ_EDIT,0,0,0);
      ObjectSetString(0,name,OBJPROP_TEXT,"EURUSD");
      ObjectSetInteger(0,name,OBJPROP_XDISTANCE,50);
      ObjectSetInteger(0,name,OBJPROP_YDISTANCE,50);
      ObjectSetInteger(0,name,OBJPROP_XSIZE,50);
      ObjectSetInteger(0,name,OBJPROP_YSIZE,20);
      ObjectSetInteger(0,name,OBJPROP_READONLY,false);
      ObjectSetInteger(0,name,OBJPROP_COLOR,clrBlack);
      ObjectSetInteger(0,name,OBJPROP_BGCOLOR,clrWhite);
     }
  }
 

I created this auto-hotkey script to hide title bars while coding. It works for all windows on Windows. I'm not sure about other platforms.



; 
Hide borders, title bar 









#IfWinNotActive ahk_class Progman 









#IfWinNotActive ahk_class Shell_TrayWnd 









^] :: 









WinGet Style, Style, A 









if (Style & 0xC40000) { 









WinSet, Style, -0xC40000, A 









WinMaximize, A 













} 









else { 









WinSet, Style, + 0xC40000, A 









WinRestore, A 









} 









return 

The result, is a perfectly filled desktop screen.

Just save the file as file_name.ahk. Save it in your preffered directory, then download and install https://www.autohotkey.com .

Create a shortcut of the script and cut it. Press win + r

Type shell: startup and paste the shortcut in the pop window.

That way, the script will start with windows after reboot. To launch the script now, double click it, then you can hide window title bars with ctrl +]

Make sure the window is not maximized while using the shortcut. No point in maximizing a maximized window, and I didn't handle for that case.

Enjoy

edit:

The code formater is behaving strangely. It keeps expanding the code to huge line-spacing. Lol!

AutoHotkey
  • www.autohotkey.com
AutoHotkey provides a simple, flexible syntax allowing you to focus more on the task at hand rather than every single little technicality. It supports not only the popular imperative-procedural paradigm, but also...
Files:
 

Forum on trading, automated trading systems and strategy testing

Libraries: Benchmark

fxsaber, 2020.10.01 23:49

// Возвращает true в некоторых ситуациях, когда чарт не виден.
bool IsInvisible( long chartID = 0 )
{
  bool Res = ::ChartGetInteger(chartID, CHART_IS_MINIMIZED);
  
  if (!Res && !::ChartGetInteger(chartID, CHART_IS_MAXIMIZED) && ::ChartGetInteger(chartID, CHART_IS_DOCKED))
  {
    if (!chartID)
      chartID = ::ChartID();

    for (long Chart = ::ChartFirst(); (Chart != -1) && !Res; Chart = ::ChartNext(Chart))
      Res = (Chart != chartID) && ::ChartGetInteger(Chart, CHART_IS_MAXIMIZED);
  }
  
  return(Res);
}

Trading panels and other information on charts do not update if returns true.

Reason: