I actually worked it out for anyone interested...
// Support and resistance level testing int totalLevels; totalLevels = ObjectsTotal((int) OBJ_HLINE); Alert("There are currently " + IntegerToString(totalLevels) + " on the chart"); //loop through all horizontal level objects and grab values for(int i=0;i<totalLevels;i++) { string name = ObjectName(i); double levelval = ObjectGet(name, OBJPROP_PRICE1); Alert("Level Value = " + DoubleToString(levelval, Digits)); }
dazamate:
I actually worked it out for anyone interested...
// Support and resistance level testing int totalLevels; totalLevels = ObjectsTotal((int) OBJ_HLINE); Alert("There are currently " + IntegerToString(totalLevels) + " on the chart"); //loop through all horizontal level objects and grab values for(int i=0;i<totalLevels;i++) { string name = ObjectName(i); double levelval = ObjectGet(name, OBJPROP_PRICE1); Alert("Level Value = " + DoubleToString(levelval, Digits)); }
That won't work properly if there are other object types on the chart.
your code will output the value of any object type and may miss some horizontal lines
You have to loop through all objects and check the object type.
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
Dear Mql4ers,
I would like to create some code that will read all the horizontal price levels that was placed by the user via the horizontal line tool in the terminal.
I have some code that knows there are levels on the chart...
Now how do I tap into each level and get the price value?
I did some searching and one suggestion was to use ObjectGet();
I am stuck here:
What are you meant to use for the object name?
Thanks