Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 863

 

Igor Makanu: Off-topic of course. Here's a small idea concerning your code. If you use an array, you can set an unlimited number of intervals.

CWork *Work[];

int OnInit()
  {
   if(ArrayResize(Work,3) != 3)
      ExpertRemove();
   Work[0] = new CWorkTime(StartHour_0,StartMinute_0,StopHour_0,StopMinute_0);
   Work[1] = new CWorkTime(StartHour_1,StartMinute_1,StopHour_1,StopMinute_1);
   Work[2] = new CWorkTime(StartHour_2,StartMinute_2,StopHour_2,StopMinute_2);

   return(INIT_SUCCEEDED);
  }
void OnDeinit(const int reason)
  {
   for(int i=0; i<ArraySize(Work)); i++)
      if(Work[i] != NULL)
         delete Work[i];
   ZeroMemory(Work);
  }

void OnTick()
  {
   for(int i=0; i<ArraySize(Work)); i++)
      if(Work[i].Disable())
        {
         Comment("Не торговое время!!!");
         return;
        }
/* work */
  }
 
Konstantin Nikitin:

Igor Makanu: Off-topic of course. Here's a small idea concerning your code. If you use an array, you may define an unlimited number of intervals.

Why is it off-topic? - The topic is technical, I will always support any discussion of technical issues.


Of course, you can use an array of the ex-class. I checked my class a few times - everything seems to work correctly, you can set an interval for each minute and trade by any TS ;)


The idea of creating this way to analyze the time of trade to me more like string to datetime, and the meaning of my code - once a day to count the start and end of the trade as a datetime, until a new day does not make sense to recalculate these intervals, it came a new day - recalculate everything again in datetime, and comparison between datetime, it must occur very quickly, ie, will not load the terminal (tester)


Seric29:

Why this code does not work?

Maybe a class should be described through a colon ::? The idea to create a pointer that will point to another pointer.

You have syntax errors, it should look like this:

#include <Object.mqh>
class CArray : public CObject
  {
public:
   double            m_Array[100];
  };

void OnStart()
  {
   CArray *arr=new CArray;
   arr.m_Array[22]=1.23456;
  }
 
novichok2018:

Hello!

Thanks again toAlexey Viktorov for the tip on the quotes - everything works. This Monday we have a situation - Germans have traded, while Englishmen have a day off. It turned out that in condition for euro position opening old values of pound were used. Hence the request: advise how to set check in the code that both symbols are traded on this day?

Thank you.

Sorry, I'm too lazy to read the documentation today. And the memory chips have long since burnt out almost all of them, all that's left is sclerosis. and marasmus.

 
Alexey Viktorov:

Sorry, I'm too lazy to read the documentation today. And the memory chips have long ago burned out almost all of them. All that's left is sclerosis.

Well, I'm not lazy yet, even though I have enough of my own idiocy. But where to read? I couldn't find it. My eyes are all messed up on the computer.

 
novichok2018:

Well, I'm not lazy yet, even though I have enough of my own idiocy. But where to read? I couldn't find it. My eyes are messed up on the computer.

From documentation

AccountInfoInteger(ACCOUNT_TRADE_ALLOWED) may return false in following cases

  • no connection to the trade server. Can be checked with TerminalInfoInteger(TERMINAL_CONNECTED));
  • the trading account has been switched to read-only mode (sent to archive);
  • trading on the account has been banned on the trade server side;
  • connection to the trading account has been made in investor mode.

And if not exactly so, look for other options.

 
Alexey Viktorov:

From the documentation.

And if it's not quite like that, look for other options.

Unfortunately, that's not it. Trading is not forbidden in the account - we trade on euros, but we do not trade on the pound. Hence, we need to check trading on a specific symbol. Maybe someone has encountered something like this, or knows how to solve the problem. I'm not finding it on the forums or google yet.

 
novichok2018:

Unfortunately, it is not. Trading is not prohibited in the account - we trade on euros, but we do not trade on the pound. Consequently, I need to check trading on a particular symbol. Maybe someone has encountered something like this, or knows how to solve the problem. I haven't found it on the forums or google yet.

There are other functions in the documentation

IsTradeAllowed(symbol,TimeCurrent()
TerminalInfoInteger(TERMINAL_TRADE_ALLOWED)
 

Afternoon.

In MT4, the text specified in the TrendLine object settings in the "Description" field is displayed on the left side of the trend (at the left end). Maybe someone has a ready solution how to display the text at the right end?

 
Taras Slobodyanik:

there are other functions in the documentation

Tried it.

bool uk = IsTradeAllowed("GPBUSD",TimeCurrent());
bool de = IsTradeAllowed("EURUSD",TimeCurrent());

      if(de && uk) Alert("uk == true");

Writestrue on Monday 27 as well, even though it was a holiday in England.

 
novichok2018:

Tried it.

It saystrue on Monday 27, even though it was a holiday in England.

So do you need to identify a holiday or a ban on trading?
Trade was allowed on the 27th.

If it's a weekend, then you need a news parser - to identify holidays/weekends.