Stolen. Now you can make a schedule for the week.
Here's a situation. It took me a long time to make a weekly schedule. Everything works. Suddenly, hello, New Year's Eve. Holidays. We need a schedule taking into account the holidays. It's a pity to break the weekly schedule. Solution: I create an additional instance of weekly schedule with prohibition of trading on holidays. Question: should I expand m_state to the size of the year century? Or how do you solve this issue beyond one week?
Stolen. Now you can make a schedule for the week.
Here's a situation. It took me a long time to make a weekly schedule. Everything works. Suddenly, hello, New Year's Eve. Holidays. We need a schedule taking into account the holidays. It's a pity to break the weekly schedule. Solution: I create an additional instance of weekly schedule with prohibition of trading on holidays. Question: should I expand m_state to the size of the year century? Or how do you solve this issue beyond one week?
Yes, there is such a task. I am still thinking about how to do it. I haven't come to a beautiful solution yet. But I have an understanding of how it should look like.
- The SetTradeState(...) interface itself suggests that if we set the date in the variables time_begin and time_end in the format D'hh:mm', then this mode will be in effect all the time for all days that satisfy the day_of_week condition. If the date is set specifically, specifying the year, month and day in the format D'YYYYY.MM.DD hh:mm', then the set mode will have to act specifically on this time range.
- Apparently, the second time variant will have to be placed in another data type (it can be an array of some structures or something else). Then we will have to search for the trade mode in two different ways in two different collections and compare the modes, deciding which mode should act. In this case, the GetTradeState interface should remain unchanged.
+5
day_of_week - more often it is a group of days: PN..PT or "except Friday" or "except Monday and Friday".
+5
day_of_week - more often it is a group of days: PN..PT or "except Friday" or "except Monday and Friday".
The group of days is formed as follows: let's say we want to trade on Mondays, Tuesdays and Fridays. Then we prohibit trading on Wednesday and Thursday:
//+------------------------------------------------------------------+ //|TestTradeState.mq5 | //|Copyright 2015, Vasiliy Sokolov. | //| http://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2015, Vasiliy Sokolov." #property link "http://www.mql5.com" #property version "1.00" #include <Strategy\TradeState.mqh> CTradeState TradeState(TRADE_BUY_AND_SELL); // Set default mode Buy And Sell //+------------------------------------------------------------------+ //| Script programme start function| //+------------------------------------------------------------------+ void OnStart() { TradeState.SetTradeState(D'00:00', D'23:59', WEDNESDAY, TRADE_STOP); TradeState.SetTradeState(D'00:00', D'23:59', THURSDAY, TRADE_STOP); }I.e. each day of the week is configured individually to the minute.
I implement this in my Expert Advisors, though not in the class.
how to change D'00:00' to the usual digits 00:00 ????? datetime is annoying((((((
In TradeState.SetTradeState(D'00:00:00', D'23:59', WEDNESDAY, TRADE_STOP);
Please:
TradeState.SetTradeState(0, 86399, WEDNESDAY, TRADE_STOP);
#include <Strategy\TradeState.mqh> CTradeState TradeState(TRADE_BUY_AND_SELL); void OnTick() { ......здесь работаем с закрытием (тралом и прочим).... TradeState.SetTradeState(ontime, offtime, ALL_DAYS_OF_WEEK, TRADE_NO_NEW_ENTRY); ......остальной код, в частности для открытия.... }
correct location of the code?
I apologise in advance for dumb questions!!! just a newbie)))))))

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
TradeState - the EA trading mode switcher depending on the time:
The class restricts the EA trading by time. It has flexible configuration options, which allow to set a custom number of the time zones, and also to allow trading only on the specified week days.
Author: Vasiliy Sokolov