Errors, bugs, questions - page 1178

 
svds75:
No, I need to set it manually and check it programmatically.
Then I have to read the visibility flag and do a logical & with the constant.
 

Like this:

   long cf=ObjectGetInteger(0,"name",OBJPROP_TIMEFRAMES);
   Alert(((cf&OBJ_PERIOD_H1)==OBJ_PERIOD_H1) || cf==0);
If the visibility flag on H1 is set, it will be true.
 
Integer:
Then you have to read the visibility flag and do a logical & with the constant.

If you mean:

ObjectGetInteger(0,"line",OBJPROP_TIMEFRAMES,OBJ_PERIOD_W1&OBJ_PERIOD_MN1,res);

Or

ObjectGetInteger(0,"line",OBJPROP_TIMEFRAMES,OBJ_PERIOD_W1&&OBJ_PERIOD_MN1,res);
Same thing.
 
svds75:

If you mean:

Or

Same thing.
No. There's no need to do get with enumeration. Just get, and then check if the required timeframe flag is set. Above is an example.
 
svds75:

If you mean:

Or

Same thing.

Your mistake here is bool(res), since res is always greater than 1 in any mapping, see what is returned in res, thus bool(res) will only return 0 or false when res=0

You are using type conversion and comparison inattentively

OBJ_NO_PERIODS

0

Object is not shown at any timeframe

OBJ_PERIOD_M1

0x00000001

Object is plotted on 1-minute charts

OBJ_PERIOD_M2

0x00000002

Object is plotted on 2-minute charts

OBJ_PERIOD_M3

0x00000004

Object is plotted on 3-minute charts

OBJ_PERIOD_M4

0x00000008

Object is plotted on 4-minute charts

OBJ_PERIOD_M5

0x00000010

Object is plotted on 5-minute charts

OBJ_PERIOD_M6

0x00000020

Object is plotted on 6-minute charts

OBJ_PERIOD_M10

0x00000040

Object is plotted on 10-minute charts

OBJ_PERIOD_M12

0x00000080

Object is plotted on 12-minute charts

OBJ_PERIOD_M15

0x00000100

Object is plotted on 15-minute charts

OBJ_PERIOD_M20

0x00000200

Object is plotted on 20-minute charts

OBJ_PERIOD_M30

0x00000400

Object is plotted on 30-minute charts

OBJ_PERIOD_H1

0x00000800

Object is plotted on 1-hour charts

OBJ_PERIOD_H2

0x00001000

Object is plotted on 2-hour charts

OBJ_PERIOD_H3

0x00002000

Object is plotted on 3-hourly charts

OBJ_PERIOD_H4

0x00004000

Object is plotted on 4-hourly charts

OBJ_PERIOD_H6

0x00008000

Object is plotted on 6-hourly charts

OBJ_PERIOD_H8

0x00010000

Object is plotted on 8-hour charts

OBJ_PERIOD_H12

0x00020000

Object is plotted on 12-hour charts

OBJ_PERIOD_D1

0x00040000

Object is plotted on daily charts

OBJ_PERIOD_W1

0x00080000

Object is plotted on weekly charts

OBJ_PERIOD_MN1

0x00100000

Object is plotted on monthly charts

OBJ_ALL_PERIODS

0x001fffff

Object is plotted on all timeframes

 
Integer:

There you go:

If the visibility flag on H1 is set, it will be true.
It's working, thank you.
 
meat:

As a continuation of my previous post, I managed to find the problem area causing the bug using the scientific method.

We have a library with this function:

Here is the main file:

The resulting Expert Advisor does not work and displays in the log: "EX5 loading failed".

Thanks for the post, it was fixed.
 

Hi. I locked the EA in OnInit function and it must be the reason why the terminal hangs when I turn off the EA and change timeframe (timeframe does not change after the brakes). So my question is: Is it caused by hangs? If so, is it corrected if I move the algorithm to OnTick? If no, what would help?

PS: The loop has a function Sleep, so that the terminal is not overloaded. The input fields are read in the loop.

 
king20:

Hi. I locked the EA in OnInit function and it seems that when I turn off the EA and change timeframe the terminal hangs (timeframe does not change after the brakes). So my question is: Is it caused by hangs? If so, is it corrected if I move the algorithm to OnTick? If no, what would help?

PS: The loop has a function Sleep, so that the terminal is not overloaded. The input fields are read in the loop.

Format the hard disk.
 
king20:

Hi. I locked the Expert Advisor in OnInit function and it seems that when I turn off the EA and change timeframe the terminal hangs (timeframe does not change after the brakes). So my question is: Is it caused by hangs? If so, is it corrected if I move the algorithm to OnTick? If no, what would help?

PS: The loop has a function Sleep, so that the terminal is not overloaded. The input fields are read in the loop.

OnInit - serves only for initialization. All calculations must be done further - OnTick, OnTimer etc.

If you need to know the change in the input field, there is a standard library for that: https://www.mql5.com/ru/docs/standardlibrary/controls/cedit

Документация по MQL5: Стандартная библиотека / Классы для создания панелей и диалогов / CEdit
Документация по MQL5: Стандартная библиотека / Классы для создания панелей и диалогов / CEdit
  • www.mql5.com
Стандартная библиотека / Классы для создания панелей и диалогов / CEdit - справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5