How to set 'show trade history' by code? --- ChartSetInteger() does not work --- might be a bug

 

In MT5, there is a checkbox to select the "Show trade history". It is the last item on the tab "Show" of the properties window of a chart (click F8).

I would like to know, how I can (de)select this property by code (in mql5)!

- Usually, I would expect to use the functions ChartSetInteger() and ChartGetInteger(), but I am missing the corresponding value in ENUM_CHART_PROPERTY_INTEGER (something like:      CHART_SHOW_TRADE_HISTORY). It does not exist. That might be a bug.

So, can somebody help me please to code the selection of the "trade history" property of a chart.

Thanks a lot in advance and best regards





Documentation on MQL5: Constants, Enumerations and Structures / Named Constants / Predefined Macro Substitutions
Documentation on MQL5: Constants, Enumerations and Structures / Named Constants / Predefined Macro Substitutions
  • www.mql5.com
//| Expert initialization function                                   | //| Expert deinitialization function                                 | //| Expert tick function                                             | //| test1                                                            |...
 
joelicht: I am missing the corresponding value in ENUM_CHART_PROPERTY_INTEGER … can somebody help me please to code
  1. Since there isn't any access, how do you expect anyone to help you with your want?
  2. My GUI/Trade Assistant EA (for MT4) creates it's own: 'Money Manager Graphic Tool' indicator by 'takycard' - Risk Management - Articles, Library comments - MQL5 programming forum - Page 6 #55
 

Thanks a lot for your answer.

On MT5, this is an easy way to switch on and off all visible trades on a chart.
Doing that by script, will allow me easily to switch on and off all visible trades on all charts with one hotkey only.

There must be a way to change this chart property by code, since all other properties nearby can be changed by code.

So, there are two options:

Either I do not know the way how to change this one property by code (therefore I am asking for help),
or this is not possible. In the later case, this is a bug in my opinion,
and I hope, that the developers from metaquotes will read this and work on it.
I tried to contact the service desk first, but it was discontinued for technical bugs. The advice was to ask in the forum.

 

 
 
 

 
joelicht:

Thanks a lot for your answer.

On MT5, this is an easy way to switch on and off all visible trades on a chart.
Doing that by script, will allow me easily to switch on and off all visible trades on all charts with one hotkey only.

There must be a way to change this chart property by code, since all other properties nearby can be changed by code.

So, there are two options:

Either I do not know the way how to change this one property by code (therefore I am asking for help),
or this is not possible. In the later case, this is a bug in my opinion,
and I hope, that the developers from metaquotes will read this and work on it.
I tried to contact the service desk first, but it was discontinued for technical bugs. The advice was to ask in the forum.

 

 
 
 

You are right, they problem forgot to add this property.
 
It bugs me too.
 

There might not be a straight forward way, but you might be able to go into the Profiles file, read through it using MQL code, and have it change the line that says "show trade history" to =0. Have it search for the line that says either


tradehistory=1

or

tradehistory=0


and change it to what you want it to be (=1 or =0)


You'd have to get the path of the file from MQL4 or MQL5 / Profiles / name of your profile and make that the file you open using FileOpen


then those changes should happen if not right away then next time you load metatrader


edit - you have to edit the chart profile files with metatrader closed, THEN open metatrader again... unless you can make the changes on a profile that's not currently open, then change profiles. 

Code profiling - Developing programs - MetaEditor Help
Code profiling - Developing programs - MetaEditor Help
  • www.metatrader5.com
Profiling means collecting program parameters during its execution. During a profiling, the execution time and the number of calls of individual functions and program code lines are measured. With this tool, the programmer is able to find and optimize the slowest code sections. Profiling can be performed on the normal chart of the trading...
 
Alain Verleyen:
You are right, they problem forgot to add this property.

Hi Alain, 


Do you know when this feacture (show/hide trade history via code) will do implemented?


Thanks

 
Learning2:

There might not be a straight forward way, but you might be able to go into the Profiles file, read through it using MQL code, and have it change the line that says "show trade history" to =0. Have it search for the line that says either


tradehistory=1

or

tradehistory=0


and change it to what you want it to be (=1 or =0)


You'd have to get the path of the file from MQL4 or MQL5 / Profiles / name of your profile and make that the file you open using FileOpen


then those changes should happen if not right away then next time you load metatrader


edit - you have to edit the chart profile files with metatrader closed, THEN open metatrader again... unless you can make the changes on a profile that's not currently open, then change profiles. 

Hi Leaning2,


May you send an example for this code?


Thanks

 
Maximiliano Salvatti:

Hi Leaning2,


May you send an example for this code?


Thanks


It is no programming code, but parameters. You have to put one of those parameters on the 'template' file, located at:

MQL5\Profiles\Templates

---

tradehistory=1

or

tradehistory=0

---

If you want it do be default, find a file called 'default' under that directory, open in notepad, and insert the parameter

Or you can edit any other custom template there.


As far as today, 26/mar/2021, there is no such function/property yet via C language. 

 

hello there is an easy way to do this. Just delete all objects that start with "autotrade".

here is the link to the code:

https://www.mql5.com/en/code/36136/


Usage:

DeleteObjects (ChartID (), "autotrade");

I hope this helps ...

 

I actually tried to recreate this but I cannot work out how it knows exactly which exits match which entries.

So for example for a simple situation where an entry and exit comes straight after, it's simply the previous deal that was the entry.


But if you do multiple entries (in in out out) then I don't know how to connect the correct in's and out's to draw the lines properly. Hmm.

Reason: