- Ruud Op: It seems like the ObjectsTotal function does not properly work,
How To Ask Questions The Smart Way. 2004
Don't rush to claim that you have found a bug.
Questions Not To Ask
My program doesn't work. I think system facility X is broken.It is almost always your code.
-
int totalLines = ObjectsTotal(0, 0, OBJ_HLINE); ⋮ priceLevelName = ObjectName(0, counter, 0,-1);
Your first line finds that there are three HLINEs. Then you ask for the first, second and third object, not the first, second and third HLINE.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
Hello,
I am looping through all horizontal lines of the current chart using the ObjectsTotal function: int totalLines = ObjectsTotal(0, 0, OBJ_HLINE);
I have 3 horizontal lines in my chart that I want the Expert Advisor to trade from. Then I have 2 extra lines that show a treshold value.
What I am doing is, that I use the nearest support line as a line to buy from and the nearest resistance line as a line to sell from.
The code works beautifully as long as I don't really open positions. The moment I open a position with a stop loss and a take profit, the ObjectsTotal function still counts the same number of lines, but the names of the lines have changed. Of my 3 horizontal lines, 2 are suddenly missing, and also the treshold lines are missing from the ObjectName function. The lines are still visible on the chart, but as I loop through all horizontal lines and for each step read the ObjectName, not all my lines show up. It shows however a line with a name that signifies the Buy or Sell line. And same old buy and sell lines.
It seems like the ObjectsTotal function does not properly work, from the moment a position is opened.
Does anybody know a workaround?
Thank you in advance,
Kind regards,
Ruud