Watch how to download trading robots for free
Find us on Facebook!
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
Views:
1687
Rating:
(5)
Published:
Updated:
Test.mq5 (0.09 KB) view
MQL5 Freelance Need a robot or indicator based on this code? Order it on Freelance Go to Freelance

Here is a simplified function to convert server times (also stored times of bars, ticks, or economic calendar events) from one broker's time zone to another.

//+------------------------------------------------------------------+
//| Convert server time from one broker's time zone to another.      |
//+------------------------------------------------------------------+
datetime  ConvertServerTime(
   const datetime   aTime,                             // source server time to convert
   const int        sourceOffsetUTC = 0,               // source server standard (winter) UTC offset in seconds
   const int        destinationOffsetUTC = 0,          // destination server standard (winter) UTC offset in seconds
   ENUM_RULE_DST    sourceRuleDST = DST_NONE,          // source server daylight savings schedule
   ENUM_RULE_DST    destinationRuleDST = DST_NONE      // destination server daylight savings schedule
  )

To be able to identify the DST schedules for the source and destination servers (US, EU, or no schedule), you can use that script https://www.mql5.com/en/code/48650

This function adopts the standard offset notation used in most programming languages (for example, JavaScript). In this convention, positive time zones (such as GMT+3) correspond to positive offsets (e.g., +10800), while negative time zones correspond to negative offsets.

Note that this is the inverse of MQL5’s built-in TimeGMTOffset() function, which represents positive time zones with negative offsets (e.g., -10800) and negative time zones with positive offsets.

This is a sample of running the function:


The output:


The complete library (TimeZoneInfo.mqh) with more features can be found here. https://www.mql5.com/en/code/48419

StopLoss trailing classes library for MQL5 StopLoss trailing classes library for MQL5

A set of classes for automatic moving of StopLoss of open positions by fixed indentation or by values of Parabolic SAR and moving averages indicators, or by specified position stop level.

MACD Histogram MC MACD Histogram MC

MACD Histogram

Bollinger Bands Squeeze Bollinger Bands Squeeze

It signals a period of low market volatility that is about to end, foreshadowing a significant price move.

Simple Expert Advisor based on WPR, Bollinger Bands and ATR indicators Simple Expert Advisor based on WPR, Bollinger Bands and ATR indicators

A simple strategy based on the signals of two indicators: Williams' Percent Range (WPR) and Bollinger Bands (BB). A position is opened only when the signals of both indicators coincide.