Download MetaTrader 5
To add comments, please log in or register
Examine the Top MetaTrader 5 signals. Choose the best one and subscribe to it!
zork
31
zork 2011.03.14 19:04 

Hi,

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?

Thanks,

Lukasz

bernd
977
bernd 2011.03.14 19:28  

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.

zork
31
zork 2011.03.14 21:19  
7bit:

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.


Only if an indicator creates new window. Calling an indicator from the EA code does not cause chart profile to be saved.
bernd
977
bernd 2011.03.14 21:26  
zork:

Only if an indicator creates new window. Calling an indicator from the EA code does not cause chart profile to be saved.
At least then it *might* be possible to use windows api (sendmessage and friends) to add an indicator and immediately remove it again. For my purpose this would already be enough, I could let my EA do this once every hour to save the chart with all the objects it has created (breakeven markers, trade markers, labels, etc).
zork
31
zork 2011.03.14 21:56  
7bit:
At least then it *might* be possible to use windows api (sendmessage and friends) to add an indicator and immediately remove it again. For my purpose this would already be enough, I could let my EA do this once every hour to save the chart with all the objects it has created (breakeven markers, trade markers, labels, etc).


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?

whroeder1
13627
whroeder1 2011.03.15 17:13  
  1. shutdown query is an interesting idea.
  2. I have Expert advisor, that creates some label object in init().
    Why bother. On startup the EA will again create the objects so who cares whither it was written to disk?
bernd
977
bernd 2011.03.15 17:14  
zork:


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 haven't tried it but i'm quite sure it will.
zork
31
zork 2011.07.30 19:21  
WHRoeder:
  1. shutdown query is an interesting idea.
  2. I have Expert advisor, that creates some label object in init().
    Why bother. On startup the EA will again create the objects so who cares whither it was written to disk?

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,

whroeder1
13627
whroeder1 2011.07.31 00:13  
zork
31
zork 2011.07.31 23:53  

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?

Marzullo
18
Marzullo 2014.03.15 23:42  

This will save it.

It just forces to re-acknowledge the EA parameters.

void forceProfileSaveHack()
{
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
      forceProfileHack();

   return;
   }  
/
To add comments, please log in or register