I have Expert advisor, that creates some label object in init().
I noticed that adding EA on chart causes MetaTrader4 to store chart profile on disk, but it happens before my object is created, so created object data is not stored in chart profile. I need to readd EA again, change profile or restart metatrader to get my chart profile updated.
Is there a way to force MetaTrader4 to store it again from my EA init() or start() functions?
I haven't found a way yet. The only way is to quit MT4 and restart it, a crash of MT4 will make you lose all newly added chart objects, a method to save the state of the chart while it is running does not exist to my knowledge (I could need this too).
But it is interesting to hear that adding an EA will trigger the saving of the chart, I did not know this! Does this happen when adding an indicator too? If this is the case then maybe here lies the key to automating it.
I am also thinking about sending shutdown query event to metatrader ( WM_QUERYENDSESSION ). The questions are:
does metatrader saves its data upon receiving this event?
Can it cause some other side effects?
I need to find profile file of a chart where my EA is running from my own application.
My current way to do it is as follows:
1. EA creates an object with unique id and connects to my application providing this id.
2 .My application scans all profiles and tries to find profile file with this unique object.
I need to add my EA to chart twice for this to work and my users find it a little bit strange.
Thanks for any hints,
Thx, but this is to intrusive. Better idea is to send F5 and ctrl+F5 to terminal, but this will cause flicker too. More advanced method is to create custom indicator in separate window. Adding this indicator and removing it will cause profile to be stored. Have you ever tried this from EA or external application?
This will save it.
It just forces to re-acknowledge the EA parameters.
keybd_event(118, 0, 0, 0); //VK_F7
keybd_event(13, 0, 0, 0); //VK_RETURN
In my EA I trigger such save manually with the letter "S" (but you can call it from anywhere, maybe with a timer)
void OnChartEvent(const int id, const long& lparam, const double& dparam, const string& sparam)
if(id == CHARTEVENT_KEYDOWN && lparam == 83) // VK_S
To add comments, please log in or register