Skip to content

KeisukeIwabuchi/MQL4-Env

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

MQL4-Env

MQL4 handles environment setting files for each account.

Requirement

Install

  1. Donwload Env.mqh and defines.mqh
  2. Save the file to /MQL4/Include/mql4_modules/Env/

Usage

Prepare the environment file

  1. Make a file (.txt or .ini) in /MQL4/Files/
  2. Write the setting in the form of key = value in the created text file.
API_TOKEN=123456890-hogehogehoge
ACCOUNT=123
IS_DEBUG=true

How to use

  1. Includes Env.mqh
  2. Read the configuration file.
  3. Acquire value from environment setting file.

To get the value, execute the get method.

string api_token = Env::get<string>("API_TOKEN");

Env::get (initial value if key, key does not exist).
Initial value can be omitted.
If the initial value is omitted and a key does not exist, a value equivalent to NULL or NULL is returned.
To get the bool type value, execute the getBoolValue method.

#property strict

#include <Env.mqh>


int OnInit(){
   Env::loadEnvFile("sample.ini");
   Comment("API_TOKEN = ", Env::get<string>("API_TOKEN"), "\n",
           "USER_NAME = ", Env::get<string>("USER_NAME", "MQL4"), "\n",
           "ACCOUNT = ", Env::get<int>("ACCOUNT", 0), "\n",
           "IS_DEBUG = ", Env::getBoolValue("IS_DEBUG", false));

   return(INIT_SUCCEEDED);
}


void OnTick(){
   
}

image

About

Configuration files for MQL4

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages