Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1178

 
Aleksey Vyazmikin:

So there is no mention of a fan for this function in the instructions

As an object in the same price coordinate can have several values, a line number must be specified. This function is only applicable to the following objects:

  • Trend line (OBJ_TREND)
  • Trendline by angle (OBJ_TRENDBYANGLE)
  • Gann Line (OBJ_GANNLINE)
  • Equidistant channel (OBJ_CHANNEL) - 2 lines
  • Linear regression channel (OBJ_REGRESSION) - 3 lines
  • Standard deviation channel (OBJ_STDDEVCHANNEL) - 3 lines
  • Line with arrow (OBJ_ARROWED_LINE)

The fan has two points at any one time. Add a parallel trend line to it and calculate it. The output can always be found.

 
Uladzimir Izerski:

Calculated withObjectGetValueByTime price, find out any percentage of the fan.

It works in the tester. I haven't tested it.

Can you show it in code form?

 
Aleksey Vyazmikin:

Can you show it in code form?

Just checked in the code. It works on the channels. It detects on the fan as well.

 F_Draw_Object("FAN",OBJ_FIBOFAN,Time[20],High[20],Time[5],Low[5],0,0,0,2,C'00,00,200',OBJPROP_FILL,false);
 PriseCLv=ObjectGetValueByTime(0,"FAN",Time[10],0);

You can bind a trendline to a fan and you can detect it too. But it works as it is.

 
Uladzimir Izerski:

Just checked in the code. It works on the channels. It detects on the fan as well.

You can bind the trendline to the fan and you can detect it too. But it works as it is.

How does it work for you?

It doesn't work for me, at least not in the visual tester...

bool fiboFanCreate(string ffname, datetime tm1, double pr1, datetime tm2, double pr2)
{
   Print(__FUNCSIG__);
   
   //if(!ObjectCreate(0,ffname,OBJ_FIBOFAN,0,tm1,pr1,tm2,pr2))
   if(!ObjectCreate(0,ffname,OBJ_FIBOFAN,0,tm1,pr1,tm2,pr2,0,0,0,2,C'00,00,200',OBJPROP_FILL,false))
   {
      Print(__FUNCSIG__,
            ": не удалось создать \"Веер Фибоначчи\"! Код ошибки = ",GetLastError());
      return(false);
   }
   
   ChartRedraw();
   Sleep(1000);
   
   return(true);
}
//+------------------------------------------------------------------+
bool fiboFanLevelsSet(double  &values[],  // значения линий уровня
                      string  name)       // имя веера
{
   Print(__FUNCSIG__);
   
   levels = ArraySize(values);
   ArrayPrint(values);
   //--- установим количество уровней
   ObjectSetInteger(0,name,OBJPROP_LEVELS,levels);
   
   //--- установим свойства уровней в цикле
   for(int i=0;i<levels;i++)
   {
      //--- значение уровня
      ObjectSetDouble(0,name,OBJPROP_LEVELVALUE,i,values[i]);
      //--- описание уровня
      ObjectSetString(0,name,OBJPROP_LEVELTEXT,i,IntegerToString(i+1));
   }
   ChartRedraw();
   Sleep(1000);
   //--- успешное выполнение
   return(true);
}

Check

void OnTick()
{
   new_bars    = current_chart.isNewBar();   // проверить появление нового бара
   
   if(new_bars > 0)
   {
      if(ObjectFind(0,ff_name) >= 0) Print(ff_name,"4 = ",NormalizeDouble(ObjectGetValueByTime(0,ff_name,TimeCurrent(),4),Digits()));

....

2020.01.19 19:38:50.208 2019.09.19 11:15:00   bool fiboFanCreate(string,datetime,double,datetime,double)
2020.01.19 19:38:50.208 2019.09.19 11:15:01   bool fiboFanLevelsSet(double&[],string)
2020.01.19 19:38:51.365 2019.09.19 11:30:00   FFan4 = 0.0
 

Forum on trading, automated trading systems and testing trading strategies

2 questions MT5

Sergey Tabolin, 2020.01.20 11:52

What has caused an error when calling the indicator from an EA? The indicator is normally placed manually on the chart.

   ResetLastError();
   handle_ICTMP1 = iCustom(Symbol(),0,"my_used\\ICTMP_3.01",0,in_symb1,false,false,in_smoothing);
   if(handle_ICTMP1 == INVALID_HANDLE)                                                 // проверяем наличие хендла индикатора
   {
      Print("Не удалось получить хендл индикатора handle_ICTMP1...",GetLastError());   // если хендл не получен, то выводим сообщение в лог об ошибке
      return(INIT_FAILED);                                                             // завершаем работу с ошибкой
   }
   else
   {
      Print("Получен хендл индикатора handle_ICTMP1");
      if(!MQLInfoInteger(MQL_OPTIMIZATION))
      {
         if(!ChartIndicatorAdd(ChartID(),0,handle_ICTMP1)) Print("Ошибка подключения индикатора к графику"); // подключаем индикатор к графику
      }
   }
2020.01.20 13:42:09.390 Core 1  file Indicators\my_used\ICTMP_3.01 read error
2020.01.20 13:42:09.390 Core 1  loading of ICTMP_  EURGBP,M15 failed [557]
2020.01.20 13:42:09.390 Core 1  2019.09.19 00:00:00   cannot load custom indicator 'my_used\ICTMP_3.01' [4802]
2020.01.20 13:42:09.390 Core 1  2019.09.19 00:00:00   Не удалось получить хендл индикатора handle_ICTMP1...4802
2020.01.20 13:42:09.390 Core 1  tester stopped because OnInit returns non-zero code
P.S. It's in the tester.

And this despite the fact that the EA is run on the chart in real time. It does not render the indicator. (((

In particular, what is this?

 

Dear friends, can't anyone suggest anything?

Separately, the indicator works both in the tester and on the chart. When I run it from the EA in the tester, I get an unclear error. The Expert Advisor with this indicator normally starts and works on the chart.

Where do I dig?

 
Сергей Таболин:

Dear friends, can't anyone suggest anything?

Separately, the indicator works both in the tester and on the chart. When I run it from the EA in the tester, I get an unclear error. The Expert Advisor with this indicator normally starts and works on the chart.

Where do I dig?

Maybe towards the path of the indicator in the tester?
 
Artyom Trishkin:
Maybe towards the indicator path in the tester?

How's that?

I have all the indicators I need in this way

handle_ICTMP1 = iCustom(Symbol(),0,"my_used\\ICTMP_3.01"
handle_HMA7C = iCustom(Symbol(),0,"my_used\\my_HMA7C_201",

This has never happened before. Also, this is the first time I've heard of a separate path to an indicator in the tester...

Does it work for other indicators, but not for this one?

 

Specially added another indicator beforehand.

   ResetLastError();
      handle_HMA7C = iCustom(Symbol(),0,"my_used\\my_HMA7C_201",45,9);
      if(handle_HMA7C == INVALID_HANDLE)                                                  // проверяем наличие хендла индикатора
      {
         Print("Не удалось получить хендл индикатора handle_HMA7C...",GetLastError());    // если хендл не получен, то выводим сообщение в лог об ошибке
         return(INIT_FAILED);                                                             // завершаем работу с ошибкой
      }
      else
      {
         Print("Получен хендл индикатора handle_HMA7C");
         if(!MQLInfoInteger(MQL_OPTIMIZATION))
         {
            if(!ChartIndicatorAdd(ChartID(),0,handle_HMA7C)) Print("Ошибка подключения индикатора к графику"); // подключаем индикатор к графику
         }
      }
   
   handle_ICTMP1 = iCustom(Symbol(),0,"my_used\\ICTMP_3.01",0,in_symb1,false,false,in_smoothing);
   if(handle_ICTMP1 == INVALID_HANDLE)                                                 // проверяем наличие хендла индикатора
   {
      Print("Не удалось получить хендл индикатора handle_ICTMP1...",GetLastError());   // если хендл не получен, то выводим сообщение в лог об ошибке
      return(INIT_FAILED);                                                             // завершаем работу с ошибкой
   }
   else
   {
      Print("Получен хендл индикатора handle_ICTMP1");
      if(!MQLInfoInteger(MQL_OPTIMIZATION))
      {
         if(!ChartIndicatorAdd(ChartID(),0,handle_ICTMP1)) Print("Ошибка подключения индикатора к графику"); // подключаем индикатор к графику
      }
   }
2020.01.20 20:15:34.713 program file added: Indicators\my_used\my_HMA7C_201.ex5. 41715 bytes loaded
2020.01.20 20:15:34.920 2019.09.19 00:00:00   Получен хендл индикатора handle_HMA7C
2020.01.20 20:15:34.921 file Indicators\my_used\ICTMP_3.01 read error
2020.01.20 20:15:34.921 loading of ICTMP_ EURGBP,M15 failed [557]
2020.01.20 20:15:34.921 2019.09.19 00:00:00   cannot load custom indicator 'my_used\ICTMP_3.01' [4802]
2020.01.20 20:15:34.921 2019.09.19 00:00:00   Не удалось получить хендл индикатора handle_ICTMP1...4802
2020.01.20 20:15:34.921 tester stopped because OnInit returns non-zero code

The EA is still put on the chart normally. All indicators are loaded and working....

 
Сергей Таболин:

Dear friends, can't anyone suggest anything?

Where to dig?

I can assume that you get the handle repeatedly and gradually overflow the memory. the one on the live graph does it slowly, and does not have time to fill the entire memory. the tester does it many times a second, and quickly overflows the memory.

Reason: