Skip to content

Instantly share code, notes, and snippets.

@Capriatto
Last active September 22, 2021 17:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Capriatto/8d3a9abb047281ac2c895bdf70e360c2 to your computer and use it in GitHub Desktop.
Save Capriatto/8d3a9abb047281ac2c895bdf70e360c2 to your computer and use it in GitHub Desktop.
// some useful functions in mql4
// Alert() prints an alert with sound and window. So, it's useful to important notifications
// make sure you always cast numbers to string in order to avoid warnings in the console
Alert("");
// Print() prints a message in the experts page in the mt4's terminal window
// This is intended to inform the user all the changes that the expert or the script does.
// This is more quiet than the alarm type.
Print("");
// DayOfWeek() returns a integer of the current week's day. Useful to avoid trading mondays and fridays, for an instance.
DayOfWeek();
// NormalizeDouble() is good to use a specific decimal number. For example, print doubles with 3 decimals like this:
NormalizeDouble(1.55484,3); // output: 1.554
// IsTradeAllowed helps you to know if the "AutoTading" button is on or off in order to make a custom message to
// the user like "Hey, please turn on your AutoTrading button."
IsTradeAllowed();
// Same previous function but uses two parameters to know if the symbol is allowed to trade in the current time.
// may be useful to validate if is an off day of trading and notifies that to the user.
IsTradeAllowed(Symbol(), TimeCurrent());
// SymbolInfoDouble has many uses but this one is to know what is the account type of the current user
// it returns a double value like:
// standar lots: 100.000,00
// mini lots: 10.000,00
// micro lots: 1.000,00
SymbolInfoDouble(NULL,SYMBOL_TRADE_CONTRACT_SIZE)
// OrdersTotal tells you how many positions you have currently. It helps you to control your risk management and
// avoids you overtrading.
int OrdersTotal(); // output: 3
// OrderSelect allows you to use other functions related to the order attributes like
// OrderMagicNumber,OrderOpenPrice,OrderClosePrice
OrderSelect();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment