Errors, bugs, questions - page 2930

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Translating an indicator from mt4 to mt5
The problem is inDRAW_HISTOGRAM size
When I set "1" or "2" the size changes, but "3" or "4" = size is still "2".
Why everything works in MT4, but there is such a problem with MT5?
Result in mt4
Result in mt5, shows only "2" thickness, although I have "3" in settings
Also, setting the property in OnInit() does not help
PlotIndexSetInteger(0,PLOT_LINE_WIDTH, 3);
Critical error during debugging:
Result:
Latest beta version at the momentHas anyone figured out a way to get the indicator handle to display property in the main window or subwindow? I am talking about custom indicators which are created using IndicatorCreate and then they can be added to the chart using ChartIndicatorAdd.
You could probably shove the indicator into OBJ_CHART and see where it is located.
Has anyone figured out a way to get a display property from an indicator handle in the main window or subwindow? I am talking about custom indicators which are created using IndicatorCreate and then they can be added to the chart by ChartIndicatorAdd at user's request.
did something similar.
The code searches all open charts for an indicator by its handle. Returns symbol, timeframe, chart id, subwindow and indicator name.Here's one I found. Can't remember if it works or not. Please check it out.
I guess you could put the indicator in OBJ_CHART and see where it is located.
I'll give it a try, for now I had to make the option to specify it by the user.
did something similar.
Judging by the code, it searches all open charts for an indicator by its handle. Returns symbol, timeframe, chart id, subwindow and indicator name.Here's one I found. Can't remember if it works or not. Please check it out.
It does not fit your question: indicators created by IndicatorCreate are not placed in any window - they "sit" inside it, and the task is to place such an indicator by its handle in the window. Now, MQL5 allows you to add an arbitrary handle to the main window or subwindow using the ChartIndicatorAdd function, regardless of the "properties" of the indicator (no errors!), and the result looks very strange when the adding is not performed as intended.
There's a bigger problem with indicators.
Some of them implement the OnCalculate handler according to the simplified version with one input array, and you can select the price type for their calculation. How do you know from the third-party MQL5 program that the indicator expects this price type, which must be passed after all parameters during the creation of the indicator? It seems that there is no way. And if you don't, the indicator is drawn by #property indicator_applied_price that cannot be accessed from the outside. Here is a simple Expert Advisor that adds the indicator/AMA to the chart programmatically:
If after that we switch the chart timeframe, we will get 2 indicators AMA: one at close price (programmatically created) and one at open price (generated due to timeframe change and #property indicator_applied_price PRICE_OPEN; it is not clear why this property is not caught by iCustom as well).
To continue the theme of indicators, I am attaching the Expert Advisor that I used to find out and avoid the problem with MqlParam parameters.
The task of the Expert Advisor is to add the indicator "Examples/Price_Channel" to the chart, if it is not there yet, with the same parameters.
To do this, we create an instance using iCustom/IndicatorCreate, get an array of its parameters through IndicatorParameters, and then call in the loop IndicatorParameters for indicators that already exist in the chart: if there is no match of the array parameters, the indicator is added to the chart, if there is a match, the new handle is simply destroyed.
The problem is that equality of parameters doesn't always work as expected. In particular, there is such a failsafe test case. We place the Expert Advisor on any empty chart and click - it creates the first instance of the indicator. Then we switch to any other chart timeframe (the old indicator remains) and click again. Strangely enough, the second instance of the indicator is created.
From the analysis of the execution and the log it is clear that this is due to the wrong equalization of strings of the indicator name in parameters. The strings there are 260 characters long, but the terminal 0 is located much earlier. After it there is either some service information or rubbish. So string comparison "==" or StringCompare takes this "rubbish" into account and we get inequality of strings.
If we convert strings into a char array, the arrays get a full match. If you convert to a short array, you get rubbish. All in all, some non-consistent behavior not described in the documentation.
I'm not sure what exactly the bug is, whether it's in the principle of string processing in MQL or something else.
If anyone knows the nuances, please give me a hint.
If anyone is aware of the nuances, please give me a tip.
This is the kind of feature that, even if you knew it, you have to bring up the whole layer in your head all over again.
Here did the definition of self availability. It seemed to work when switching TFs.