Watch how to download trading robots for free
Find us on Twitter!
Join our fan page
Interesting script?
So post a link to it -
let others appraise it
You liked the script? Try it in the MetaTrader 5 terminal
Scripts

Function for converting the number of seconds to years, months, days, hours, minutes, seconds - script for MetaTrader 5

Views:
590
Rating:
(3)
Published:
2025.05.13 11:28
MQL5 Freelance Need a robot or indicator based on this code? Order it on Freelance Go to Freelance
string GetTimeSpan(datetime time_sec)
  {
   if(time_sec <= 0)
      return "0 seconds";
   string time_text = {};
   datetime remaining_sec = time_sec;
   int years = (int)remaining_sec / 31536000;
   remaining_sec %= 31536000;
   int months = (int)remaining_sec / 2592000;
   remaining_sec %= 2592000;
   int days = (int)remaining_sec / 86400;
   remaining_sec %= 86400;
   int hours = (int)remaining_sec / 3600;
   remaining_sec %= 3600;
   int minutes = (int)remaining_sec / 60;
   remaining_sec %= 60;
   int seconds = (int)remaining_sec;
   if(years > 0)
      time_text += (string)years + " years ";
   if(months > 0)
      time_text += (string)months + " months ";
   if(days > 0)
      time_text += (string)days + " days ";
   if(hours > 0)
      time_text += (string)hours + " hours ";
   if(minutes > 0)
      time_text += (string)minutes + " minutes ";
   if(seconds > 0)
      time_text += (string)seconds + " seconds ";
   return time_text;
  }

Translated from Russian by MetaQuotes Ltd.
Original code: https://www.mql5.com/ru/code/58198

ADX Indicator (MQL5) ADX Indicator (MQL5)

The ADX (Average Directional Index) Smoothed indicator enhances the standard ADX by applying dual exponential smoothing filters to reduce noise and provide clearer trend signals. It plots three lines: smoothed +DI (blue), -DI (red), and the main ADX line (green). This refined version helps traders identify trend strength and potential direction changes with reduced false signals. The indicator excels at confirming established trends and warning of weakening momentum before actual price reversals occur, making it valuable for both trend following strategies and determining optimal entry/exit points.

RSI Expert Advisor - Automated Trading Tool Based on RSI RSI Expert Advisor - Automated Trading Tool Based on RSI

The RSI Expert Advisor (EA) is an automated trading tool developed for the MetaTrader 5 (MT5) platform. This EA leverages the Relative Strength Index (RSI) to identify buy and sell signals, incorporating risk management, partial position closing, and trading hour restrictions to optimize trading performance.

Swaps Monitor for a Single Symbol Swaps Monitor for a Single Symbol

A simple utility for monitoring long and short swaps of a single symbol. If your broker-dealer's swaps are specified in points instead of account currency, this utility automatically converts points into account currency. Swaps are tripled on Wednesday. Horizontal and vertical alignment can be adjusted in the inputs.

AutoCloseOnProfitLoss Expert - Automatically Close All Positions on Profit/Loss AutoCloseOnProfitLoss Expert - Automatically Close All Positions on Profit/Loss

The AutoCloseOnProfitLoss Expert Advisor (EA) is a powerful automation tool for MetaTrader 5, designed to close all open positions when predefined profit or loss targets are reached

This website uses cookies. Learn more about our Cookies Policy.