Expert Advisors • Indicators • Scripts • Libraries

MQL.RobotFX.org is the biggest collection of MetaTrader expert advisors (MT5 & MT4), indicators, scripts and libraries that can be used to improve trading results, minimize risks or simply automate trading tasks

MetaTrader 5 Libraries | Symbol Trade Made Simple With Functions

MetaTrader Experts, Indicators, Scripts and Libraries

This is my personal library with lot of functions to easily manipulate positions and receive various infos. I work on it since 2019. Hope you like it :)

  • SymbolOpenPipsMagic - return open pips from all positions by magic number.
  • SymbolOpenPercentageMagic - return percentage from open positions by magic number.
  • SymbolOpenPoints - return open points/pipets trades.
  • SymbolOpenPointsMagic - return open points/pipets by magic number.
  • SymbolOpenPositionsClose - close all open positions.
  • SymbolOpenPositionsClosePartial - close partial all open positions.
  • SymbolOpenPositionsCloseSpecificMagic - close specific open positions by magic number.
  • SymbolOpenPositionsBreakeven - breakeven specific position.
  • SymbolOpenPositionsBreakevenAll - breakeven all open positions.
  • SymbolOpenPositionsSpecific - return number of specific open trades by comment.
  • SymbolOpenPositionsSpecificMagic - return number of specific open trades by magic number.
  • SymbolOpenPositionsSpecificType - close specific open trades by comment and type).
  • SymbolOpenPositionsCloseSpecific - close specific open trades by comment.
  • SymbolOpenPositionsLast - return the price from last open trade.
  • SymbolOpenPositionsLowest - return the lowest price from open trades.
  • SymbolOpenPositionsHighest - return the highest price from open trades.
  • SymbolOpenPositionsVolumeMagic - volume of open trades by magic.
  • SymbolOpenPositionsTotalComment - total of open positions by comment.
  • SymbolOpenPositionsModifyTPSpecificMagic - changes only the TP of specific positions type by magic.
  • SymbolOpenPositionsModifySLSpecificMagic - changes only the SL of specific positions type by magic.
  • SymbolOpenPositionsModifyTPMagic - changes only the TP of all positions by magic.
  • SymbolOpenPositionsModifySLMagic - changes only the SL of all positions by magic.
  • SymbolOpenPositionsCloseSpecificMagicType - close specificy position type by magic.
  • SymbolOpenPositionsCloseSpecificMagicCommentType - close specific position type by magic and comment.
  • SymbolOpenPositionsHighestType - highest price by type.
  • SymbolOpenPositionsLowestType - lowest price by type.
  • SymbolOpenResultSpecific - return the open result of specific type of positions.
  • SymbolOpenResultSpecificMagic - return the open result of specific positions by magic number.
  • SymbolOpenPositionsSpecificTypeMagic - return the number of open positions by specific parameters.
  • SymbolOpenPositionsBars - bars amount of open trades.
  • SymbolOpenPositionsCloseAfterSeconds - close the trades after specified seconds.
  • SymbolPendingOrdersCloseAll - close all pending orders.
  • SymbolPendingOrdersCloseSell - close all pending sell orders.
  • SymbolPendingOrdersCloseBuy - close all pending buy orders.
  • SymbolPendingOrdersCloseSpecific - close specific trades by comment.
    SymbolPendingOrdersType - amount of orders by type.
  • SymbolPendingOrdersMagic - return the amount of pending orders by magic number.
  • SymbolPendingOrdersCloseBuyMagic - close buy pending orders by magic.
  • SymbolPendingOrdersCloseSellMagic - close sell pending orders by magic.
  • SymbolPendingOrdersSpecificTypeMagic - return the amount of pending orders by specific parameters.
  • SymbolRiskReward - return the risk/reward ration from specific open position (position = true) or pending order (position = false).  Stop loss and take profit must be specified.
  • SymbolPositionReverse - reverse specific position.
  • SymbolPositionReverseAll - reverse all open positions.
  • CandleTime - return the candle remaining time in string mode.
  • SymbolNormalizeVolume - return the normalized (corrected) the inputed volume.
  • SymbolNormalizeDigits - normalize digits to divide on some functions.
  • SymbolChartClean - clean all chart, including date and price (optional).
  • SymbolTimeframe - return the timeframe in string (ex. M1, M12, H3, Weekly, ect).
  • SymbolPositionsSwapTotal - return in double the total swap from all open positions.
  • SymbolPositionsCommissionTotal - return in double the total commission from all open positions .
  • SymbolPriceChange - return the percentage difference from two prices.
  • SymbolNormalizePrice - normalize price by tick size.
  • SymbolPositionResultMoney - return the result from a position specified price target in money.
  • SymbolPositionResultPercentage - return the result from a position specified price target in percentage.
  • SymbolPeriodChangePips - return the change in pips between the actual price and previous candle close. On daily period, for example, you can view the daily pips change.
  • SymbolPeriodChangePercentage - return the change in percentage between the actual price and previous candle close. On daily period, for example, you can view the daily percentage change.
  • SymbolBID - return the symbol bid price.
  • SymbolASK - return the symbol ask price.
  • SymbolSpread - return the symbol spread.
  • SymbolVolumeByBalance - calculate the operation volume by account balance excluding the stop loss factor. Only a generic interger factor is used. Big factor = small growth.
  • SymbolCheckPriceUsed - check if specific price is occupied by a pending order.
  • SymbolCalculateMargin - return the required margin to open a trade.
  • SymbolDigits - return the symbol digits.
  • SymbolSwapBuy - return the swap to open a buy trade.
  • SymbolSwapSell - return the swap to open a sell trade.
  • SymbolFilling - return in string mode the symbol filling type (FOK, IOC or Return).
  • SymbolCalculateVolumeByPercentage - volume by percentage of risk.
  • SymbolVolumeByPercentage - get auto volume by percentage.
  • SymbolGetDecimalPoints - symbol decimal points value.
  • SymbolGetExpirationType - expiration type in string.
  • OTHERS:
  • FixDatetimeDay - subtract or add days to specific date or time and return it in datetime.
  • FixDatetimeHours - subtract or add hours to specific date or time and return it in datetime.
  • FixDatetimeMinutes - subtract or add minutes to specific date or timed return it in datetime.
  • FixDatetimeSeconds - subtract or add seconds to specific date or time and return it in datetime.
  • RoundValue - return a integer rounded number.
  • NewCandleCheck - boolean return when new candle are formed.
  • ChartHideObjects - hide all objects from chart.
  • ChartGetScale -chart scale in integer.
  • ChartShowHiddenObjects - show all hidden objects from chart.
  • ChartGetPixelsWidth - chart width in pixels.
  • ChartGetPixelsHeight - chart height in pixels.
  • ChartGetColorForeground - chart foreground color.
  • ChartGetColorBackground - chart background color.
  • IsFirstTime - return boolean if is first time running the application.
  • GetDeinitReason - return in string the reason to program deinitialization.
  • StringRemoveEmptySpace - return in string type the original modified string.
  • CheckIfIsNumber - return true if a variable is number or false if it is not number. Good for text boxes.
  • ChartObjectsDeleteAll - delete all objects on chart.
  • IfMarketClosed - boolean return if market is closed.
  • KeyboardKeyCode- return in string mode the key pressed.
  • LocalHour - return the local computer hour.
  • LocalMinutes - return the local computer minutes.
  • GMTHour - return the GMT hour.
  • GMTMinutes - return the GMT minutes.
  • ToPoint - automatically convert to symbol _Point.
  • ScreenDPIFactor() - return the integer screen DPI factor for GUI purposes.
  • TradeTimeRemaining - return in boolean if the actual time is the scheduled trading time (hour and minute to start and end).
  • CheckStrategyTester - return in boolean if is Strategy Tester or not.
  • CandleOpen - return in double the open price of determined candle.
  • CandleClose - return in double the close price of determined candle.
  • CandleHigh - return in double the high price of determined candle.
  • CandleLow - return in double the low price of determined candle.
  • CandleCheckTrade - check if there is one or more trades on a candle (shift option).
  • CandleTime - the old function was renamed (now it is CandleTimeRemaining), now this one returns the candle datetime.
  • ACCOUNT:
  • AccountMode() - return the account mode in string (netting, exchange or hedging).
  • AccountType() - return the account type in string (demo, competition or real).
  • AccountDate(bool show day, bool show month, bool show year, str separator) - return in string modethe actual time in day, month and year.
  • AccountMonthOfYear(default months or specify each one) - return in string mode the actual month of year.
  • AccountDayOfWeek(default days or specify each one) - return in string mode the actual week day.
  • AccountDayOfWeekInt(default days or specify each one) - return in integer mode the day of week.
  • AccountHour() - return in integer mode the current hour.
  • AccountMinutes() - return in integer the current account minutes.
  • AccountOpenResult() - return in double mode the result from all open positions.
  • AccountOpenPercentage() - return in double mode the result in percentage from all open positions.
  • AccountCheckConnections(bool CheckServer, bool CheckTradingEnabled, bool CheckMQL5, str ServerErrorMsg, str TradingErrorMsg, str MQL5ErrorMsg, str MsgCaption) - show a error message when specific connections is not working.
  • AccountConnectionState() - return in string type the connection state (on-line or off-line).
  • AccountPositionsClose(str ErrorPrint) - close all open positions from all symbols.
  • AccountCheckReal - return bool type if account is real or not.
  • AccountPercentageByValue - return the accounte percentage according to a value.
  • HISTORY:
  • HistoryDealLastEntryAsString() - reason of last trade closed.
  • HistoryDealLastResult() - result of last closed trade.

Please comment what do you think :)

39947