Questions from Beginners MQL5 MT5 MetaTrader 5 - page 125

 
progeon:
Can you tell me how to display a two-dimensional array as a constant, i.e. set all parameters manually?
double Variable[][3]={{1, 2, 3},{ 4, 5, 6},{7, 8, 9}};

https://www.mql5.com/ru/articles/567

Основы программирования на MQL5 - Массивы
Основы программирования на MQL5 - Массивы
  • 2012.11.03
  • Dmitry Fedoseev
  • www.mql5.com
Наряду с переменными и функциями, массивы являются практически неотъемлемой частью любого языка программирования. Статья должна быть интересна в первую очередь новичкам, приступившим к изучению программирования на MQL5. Опытным программистам представляется хорошая возможность подытожить, обобщить и систематизировать свои знания.
 

Can you please tell me how to set up trading on a certain day at a certain time?

I searched through the forum and read Programming basics in MQL5 - Time, but still do not understand how to fit it all into the algorithm?

For example, I need to open a deal on Wednesday after the first 4 o'clock candle.

I take everything about trading on a certain day from my article:

input bool Sunday   =true; // Воскресенье
input bool Monday   =true; // Понедельник
input bool Tuesday  =true; // Вторник 
input bool Wednesday=true; // Среда
input bool Thursday =true; // Четверг
input bool Friday   =true; // Пятница
input bool Saturday =true; // Суббота

bool WeekDays[7];
void WeekDays_Init()
  {
   WeekDays[0]=Sunday;
   WeekDays[1]=Monday;
   WeekDays[2]=Tuesday;
   WeekDays[3]=Wednesday;
   WeekDays[4]=Thursday;
   WeekDays[5]=Friday;
   WeekDays[6]=Saturday;
  }
bool WeekDays_Check(datetime aTime)
  {
   MqlDateTime stm;
   TimeToStruct(aTime,stm);
   return(WeekDays[stm.day_of_week]);
  }

How do I apply it? I try to add call of function in OnTimer() and put a condition that if WeekDays_Check(3)==true and time since beginning of Wednesday within seconds>14300 && seconds <14800, then trade will be opened.

void OnTimer()
  {
   S_Time=TimeCurrent();
   if(WeekDays_Check(3)==true)
     {
      Print("Среда");
      long seconds=S_Time%86400;
      if (seconds>14300 && seconds <14800)
      {
      double Open_1=S_Open(NULL,PERIOD_CURRENT,1);
      double Close_1=S_Close(NULL,PERIOD_CURRENT,1);
      double High_1=S_High(NULL,PERIOD_CURRENT,1);
      double Low_1=S_Low(NULL,PERIOD_CURRENT,1);
      bool S_CriBuy=0,S_CriSell=0;
      double S_Lot;
      S_CriBuy=S_TailBar_Buy(Open_1,Close_1,High_1,Low_1);
      S_CriSell=S_TailBar_Sell(Open_1,Close_1,High_1,Low_1);
      Print("Прошлый бар",High_1);
      if(S_CriBuy==1)
        {
         double S_Price=Low_1;
         double S_SL=Low_1+SL*Point();
         double S_TP=Low_1-TP*Point();
         S_Lot=countLot(Lot,HandLot);
         S_Trade.SellStop(S_Lot,S_Price,NULL,S_SL,S_TP);
        }
      if(S_CriSell==1)
        {
         double S_Price=High_1;
         double S_SL=High_1-SL*Point();
         double S_TP=High_1+TP*Point();
         S_Lot=countLot(Lot,HandLot);
         S_Trade.BuyStop(S_Lot,S_Price,NULL,S_SL,S_TP);
        }
        }
     }
  }

Doesn't work like this( It opens on any day. Explain how to make a trade on a specific day at least?

Thanks in advance. If the code is childish - sorry, I just learn)

 
DenisSavenko:

Can you please tell me how to set up trading on a certain day at a certain time?

I searched through the forum and read Programming basics in MQL5 - Time, but still do not understand how to fit it all into the algorithm?

For example, I need to open a deal on Wednesday after the first 4 o'clock candle.

I take everything about trading on a certain day from my article:

How do I apply it? I try to add call of function in OnTimer() and put a condition that if WeekDays_Check(3)==true and time since beginning of Wednesday within seconds>14300 && seconds <14800, then trade will be opened.

Doesn't work like this( It opens on any day. Explain how to make a trade on a specific day at least?

Thanks in advance. If the code is childish - sorry, I just learn)

M.B.
   if(WeekDays_Check(TimeCurrent())==true)
?
 
uncleVic:
Maybe.
?

Yes, it worked! Thank you very much. Of course, there are still some errors in day offsets, but that's already my part of the code problem, but as it is, everything works. If you put false on unnecessary days, in true the trade goes - that's what's needed.

Thanks again

 
I reregistered at Insta Trader connected a real account, in MQ5 I signed up for a signal at /**/ subscription was successful, then opened Insta Trader and went into the system settings to enable the signal but Atam writes signal is not connected, how do I connect the signal and run it in work with real money [Trading account #5216372]
 
752360:
I reregistered at Insta Trader connected a real account, signed up for the signal in MQ5 / ***/ subscription was successful, then opened Insta Trader and went into the system settings to enable the signal but Atam writes signal is not connected, how do I connect the signal and put it into effect with real money [Trading Account #5216372].
Same as with unreal money, i.e., log into your real account and sign up for the signal.
 
where to log in exactly
 
752360:
where to log in exactly

In the trading terminal.

Subscribe to a signal

 

Hello.

Could you please tell me how to set expiry date of pending order (EXPIRATION) in CTrade class? I tried to add this position when sending CTrade.SellStop(Lot,Price,NULL,SL,TP,expiration); it always says "can't convert enum". The only thing I found in CTrade's documentation is how to find out the lifetime for the RequestExpiration pending order, but I don't know how to set it.

Can CTrade set the expiration time? Or may be, it may be necessary to use the full request MqlTradeRequest through OrderSend()? I don't really understand how to use it, because CTrade is mentioned in all the articles.

 
DenisSavenko:

Hello.

Could you please tell me how to set expiry date of pending order (EXPIRATION) in CTrade class? I tried to add this position when sending CTrade.SellStop(Lot,Price,NULL,SL,TP,expiration); it always says "can't convert enum". The only thing I found in CTrade's documentation is how to find out the lifetime for the RequestExpiration pending order, but I don't know how to set it.

Can CTrade set the expiration time? Or may be, it may be necessary to use the full request MqlTradeRequest through OrderSend()? I don't really understand how to use it, because CTrade is mentioned in all the articles.

   bool              SellStop(const double volume,const double price,const string symbol=NULL,const double sl=0.0,const double tp=0.0,
                              const ENUM_ORDER_TYPE_TIME type_time=ORDER_TIME_GTC,const datetime expiration=0,const string comment="");
missed parameters
Reason: