Client Terminal Properties: portable mode & market close - existing?

 

Hi,

has anybody found how to get the info of

a) market closed - in 509 you can get the error-msg

ERR_MARKET_CLOSED 132 Market is closed.

if you send an order and the market is closed - I would prefer a value from MarketInfo() or TerminalInfoInteger() as a closed market is .th. different than TERMINAL_TRADE_ALLOWED.


b) portable-mode I think it would help a lot if you have to use WinFile.mqh to know whether the terminal was started in /portable-mode or not. TerminalInfoInteger(..) has not such a property_id.

Any idea?


Thanks in advance

Gooly



 
gooly:

has anybody found how to get the info of

a) market closed - in 509 you can get the error-msg

ERR_MARKET_CLOSED 132 Market is closed.

if you send an order and the market is closed - I would prefer a value from MarketInfo() or TerminalInfoInteger() as a closed market is .th. different than TERMINAL_TRADE_ALLOWED.


b) portable-mode I think it would help a lot if you have to use WinFile.mqh to know whether the terminal was started in /portable-mode or not. TerminalInfoInteger(..) has not such a property_id.

Any idea?

Yes. a) && b) would be nice. If you can ... please contact the service desk with your suggestions.
 
gooly:

...


b) portable-mode I think it would help a lot if you have to use WinFile.mqh to know whether the terminal was started in /portable-mode or not. TerminalInfoInteger(..) has not such a property_id.

Any idea?


Thanks in advance

Gooly

Why ? What to do ?
 
ubzen:
Yes. a) && b) would be nice. If you can ... please contact the service desk with your suggestions.


a) I'd like to have another easier and faster way than sending a fake order and catching the error or delete it! Do you know an alternative?

"Why ? What to do ?"

b) mt4 has with its file-functions limited access to the 'environment' and I think mt4 should confess where it is playing in an easier way than by a string examination of the TERMINAL_DATA_PATH

gooly

PS: I send a request to the service desk, but I doubt that ....

 
gooly:

a) I'd like to have another easier and faster way than sending a fake order and catching the error or delete it! Do you know an alternative?

"Why ? What to do ?"

b) mt4 has with its file-functions limited access to the 'environment' and I think mt4 should confess where it is playing in an easier way than by a string examination of the TERMINAL_DATA_PATH

gooly

PS: I send a request to the service desk, but I doubt that ....


I doubt, too. In normal operation, you can hardly ever get the "market closed" error, just because there are no ticks to trigger the order.

And TERMINAL_DATA_PATH seems very handy to test the portable mode in one line comparison, so I am not really sure, if they could make it easier for you.

 
gooly:

a) I'd like to have another easier and faster way than sending a fake order and catching the error or delete it! Do you know an alternative?

See SymbolInfoSessionTrade(). I have not tested with new MT4 though.


"Why ? What to do ?"

b) mt4 has with its file-functions limited access to the 'environment' and I think mt4 should confess where it is playing in an easier way than by a string examination of the TERMINAL_DATA_PATH

I still don't see the usage you can do if you know if "/portable" was used. Lack of imagination maybe.
 
angevoyageur:

a) See SymbolInfoSessionTrade(). I have not tested with new MT4 though


b) I still don't see the usage you can do if you know if "/portable" was used. Lack of imagination maybe.

a) this looks good - I'll check tomorrow and next weekend.

(There are some new functions that are new and I'd like to have a list of them, a list of what is new and what has changed - that would make life so much easier ;)

b) I have installed mt4 4 times (one for each kernel of my cpu) and some files - centrally saved - must be copied by the EA upon test begin in the correct mt4-folders.

Therefore I'd like to have cheap way (code lines, readability,..) to do that.

Gooly
 
gooly:

a) this looks good - I'll check tomorrow and next weekend.

(There are some new functions that are new and I'd like to have a list of them, a list of what is new and what has changed - that would make life so much easier ;)

b) I have installed mt4 4 times (one for each kernel of my cpu) and some files - centrally saved - must be copied by the EA upon test begin in the correct mt4-folders.

Therefore I'd like to have cheap way (code lines, readability,..) to do that.

Gooly

TERMINAL_COMMONDATA_PATH ?

 
As I needed a solution for the /portable mode detection and haven't yet found a better one elsewhere (TERMINAL_COMMONDATA_PATH is not related to this issue) I wrote my own.  
Imho it justifies to bump up an old thread. For backward compatibility the code is C++ and not MQL. It can be easily translated.

#include <windows.h>

#define MT4_EXPORT comment(linker, "/EXPORT:"__FUNCTION__"="__FUNCDNAME__)


/**
 * Whether or not the terminal was launched in portable mode.
 *
 * Terminal bug: The terminal's command line parser checks parameters incorrectly. It also enables the "portable mode" switch
 *               if one of the command line parameters *starts* with the string "/portable" (e.g. "/portablepoo" enables
 *               portable mode too). The logic of this function mirrors the bug.
 *
 * @return BOOL
 */
BOOL WINAPI TerminalIsPortableMode() {
   static int result = -1;

   if (result < 0) {
      int argc;
      LPWSTR* argv = CommandLineToArgvW(GetCommandLineW(), &argc);

      for (int i=1; i < argc; ++i) {
         if (wcsncmp(argv[i], L"/portable", 9) == 0) {          // StartsWith() instead of Compare()
            result = TRUE;
            break;
         }
      }
      if (result < 0)
         result = FALSE;
   }
   return(result);
   #pragma MT4_EXPORT
}
 

This would also work. 

bool is_portable()
{
   string path = TerminalInfoString(TERMINAL_DATA_PATH);
   string roam = "AppData\\Roaming\\MetaQuotes\\Terminal";
   return (StringFind(path, roam) < 0); 
}
Reason: