Download MetaTrader 5

Watch how to download trading robots for free

Interesting script?
So post a link to it -
let others appraise it

You liked the script? Try it in the MetaTrader 5 terminal

2016.01.20 09:51
CIsSession - class to set time intervals (sessions)

CIsSession - class to set time intervals (sessions) - library for MetaTrader 5

| English Русский 中文 Español Deutsch 日本語 Português

Views:
638
Rating:
votes: 20
\MQL5\Include\
issession.mqh (10.15 KB)view
\MQL5\Experts\

I decided to publish this class after reading this publication. This topic looks interesting. My approach does not solve every problem as well. Therefore, suggest what can be improved.

The class usage example was made similar to this variant. That way it is easier to see the advantages and disadvantages.

The advantages:

  1. Possibility of standard input of date and time. See the picture. Less likelihood of mistakes.
  2. The possibility to optimize the time intervals in the strategy tester is preserved.
  3. All the settings can be quickly changed anywhere in program.
  4. More usage options. Details after the picture.
  5. Easier to use in the code. At least for me.

Options for setting the time

1. Daily session. For example, it allows the trading every day in the specified time interval. Conditions:

  • The session start and end dates are equal to 1970.01.01.
  • The session start time is less than the session end time.

2. Night session. For example, the trading through the night is allowed: start today, end tomorrow. And so every day. Conditions:

  • The session start and end dates are equal to 1970.01.01.
  • The session start time is greater than the session end time.

3. Within the range of dates. For example, the trading is allowed from the session start date up to the session end date. Conditions:

  • The session start date is less than the session end date.
  • Any time, but it is also considered.

4. Out of the range of dates. The session start date is greater than the session end date. Thus, the trading is allowed until the session end date and after the new session start date. Conditions:

  • The session start date is greater than the session end date.
  • Any time, but it is also considered.

5. Disabling/enabling the trading on a week day. It is sufficient to set "true" in the parameters for each of the week days, if you want to trade. Or "false" to disable trading.

6. All the setting can be changed anywhere in program using the Init() methods.


P.S. The class was created for the MetaTrader 5, but it also works for the MetaTrader 4. The only difference is that the MetaTrader 4 strategy tester does not support the optimization of the time intervals in the datеtime format. But it is solved by replacing the datеtime to long in the EA input parameters.

Translated from Russian by MetaQuotes Software Corp.
Original code: https://www.mql5.com/ru/code/14305

Accelerator Oscillator (AC) Accelerator Oscillator (AC)

The Acceleration/Deceleration Indicator (AC) measures acceleration and deceleration of the current driving force.

Average Directional Movement Index (ADX) Average Directional Movement Index (ADX)

The Average Directional Movement Index Indicator (ADX) helps to determine if there is a price trend.

Modify All TP SL Modify All TP SL

The script modifies all orders (market and pending) on the symbol with specified Take Profit and Stop Loss.

iFractals 4all TF iFractals 4all TF

Buy or sell just by looking at the "arrow" as a signal. Very easy and simple.