Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 530

 
abeiks:

Thank you!

How do we get out? return(0); gives me an error.

Depending on function type. It's not start() but OnTick(), it's void, so just return;

return;
 
r772ra:
For comments on Print. if not needed when working.

Thank you! Can you tell me how you can put a time limit on the EA's work in external settings.

I have added this


int start()
{
  if(!isTradeTimeInt(21, 30, 01, 00)) return;
а в конце кода вот это
//+------------------------------------------------------------------+
//|  Описание : Возвращает флаг разрешения торговли по времени.                |
//+----------------------------------------------------------------------------+
//|  Параметры:                                                                |
//|    hb - часы времени начала торговли                                       |
//|    mb - минуты времени начала торговли                                     |
//|    he - часы времени окончания торговли                                    |
//|    me - минуты времени окончания торговли                                  |
//+----------------------------------------------------------------------------+
bool isTradeTimeInt(int hb=0, int mb=0, int he=0, int me=0) {
  datetime db, de;           // Время начала и окончания работы
  int      hc;               // Часы текущего времени торгового сервера

  db=StrToTime(TimeToStr(TimeCurrent(), TIME_DATE)+" "+hb+":"+mb);
  de=StrToTime(TimeToStr(TimeCurrent(), TIME_DATE)+" "+he+":"+me);
  hc=TimeHour(TimeCurrent());
  if (db>=de) {
    if (hc>=he) de+=24*60*60; else db-=24*60*60;
  }

  if (TimeCurrent()>=db && TimeCurrent()<=de) return(True);
  else return(False);
}
 
Integer:

Depending on the function type. Now it's not start() but OnTick(), it's void, so just return;


Thank you!
 
tatianati:

Thank you! Can you tell me how you can put a time limit on the EA's external settings?

Added this

extern int   StartHour     = 21;      // Время закрытия, часы
extern int   StartMinute   = 30;      // Время закрытия, минуты
extern int   CloseHour     = 01;      // Время закрытия, часы
extern int   CloseMinute   = 0;      // Время закрытия, минуты
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---

//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {

  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   if(isTradeTimeInt(StartHour,StartMinute,CloseHour,CloseMinute))
     {
     //Здесь то,,,,
     //что работает, в этом диапозоне времени
     }
  }
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//|  Описание : Возвращает флаг разрешения торговли по времени.                |
//+----------------------------------------------------------------------------+
//|  Параметры:                                                                |
//|    hb - часы времени начала торговли                                       |
//|    mb - минуты времени начала торговли                                     |
//|    he - часы времени окончания торговли                                    |
//|    me - минуты времени окончания торговли                                  |
//+----------------------------------------------------------------------------+
bool isTradeTimeInt(int hb=0, int mb=0, int he=0, int me=0) {
  datetime db, de;           // Время начала и окончания работы
  int      hc;               // Часы текущего времени торгового сервера

  db=StrToTime(TimeToStr(TimeCurrent(), TIME_DATE)+" "+(string)hb+":"+(string)mb);
  de=StrToTime(TimeToStr(TimeCurrent(), TIME_DATE)+" "+(string)he+":"+(string)me);
  hc=TimeHour(TimeCurrent());
  if (db>=de) {
    if (hc>=he) de+=24*60*60; else db-=24*60*60;
  }

  if (TimeCurrent()>=db && TimeCurrent()<=de) return(True);
  else return(False);
}
 

Can an EA display an indicator? Alternative to ChartIndicatorAdd in MQL5.


And where can I find an example of an EA that performs calculations based on a custom indicator?

 
Can you please tell me if it is possible to prescribe the angle of slope of the moving average or price intersection with the moving average at a certain angle?
 
Profitov:
Can you please tell me if it is possible to prescribe the angle of slope of moving average or price intersection with moving average at a certain angle?
Now they'll start explaining to you that the angle depends on the chart scale and it's impossible to do that...
But if you take not the angle, but only the tangent of that angle, you can do what you want.
 
Please advise if anyone knows.

My Expert Advisor, in int init(), first tests a 1000 bar history, then start(). In the tester this process takes 3-4 seconds, but in real life it takes about 8 minutes.
What can it be related to? How can I make the testing take as much time as in the tester?
 
agvozdezkiy:

Can an EA display an indicator? Alternative to ChartIndicatorAdd in MQL5.


And where can I find an example of an EA that performs calculations based on a custom indicator?

https://book.mql4.com/ru/samples/icustom
 
Profitov:
Can you please tell me if it is possible to prescribe the angle of slope of the moving average or price intersection with the moving average at a certain angle?


https://book.mql4.com/ru/samples/iroc
Reason: