Copy Open/Close/High/Low of a Candle
You don't need any extra code for that.
In MetaTrader 4 when you hover your mouse over a bar/candle and you hit "Ctrl-C", it will copy the contents of the "Data Window" in TSV (Tab Separated Values) which you can then paste in a text file or into your spreadsheet application (like Excel).
The only precaution you should take is that the copied data uses the "decimal point" and should your spreadsheet application be set to use the comma as the decimal separator, then it can interpret the values incorrectly.
EDIT: Unfortunately in MetaTrader 5, this same functionality is "bugged" and does not work properly.
You don't need any extra code for that.
In MetaTrader 4 when you hover your mouse over a bar/candle and you hit "Ctrl-C", it will copy the contents of the "Data Window" in TSV (Tab Separated Values) which you can then paste in a text file or into your spreadsheet application (like Excel).
The only precaution you should take is that the copied data uses the "decimal point" and should your spreadsheet application be set to use the comma as the decimal separator, then it can interpret the values incorrectly.
EDIT: Unfortunately in MetaTrader 5, this same functionality is "bugged" and does not work properly.