Join our fan page
Function for converting the number of seconds to years, months, days, hours, minutes, seconds - script for MetaTrader 5
- Views:
- 1280
- Rating:
- Published:
-
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)
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 Ea MT5
Rsi Ea using RSI signals with ATR volatility-based stops, automatic position sizing, scale-out feature, and trading session filter
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
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