Download MetaTrader 5

string of code to discard all records, memory of an EA?

To add comments, please log in or register
Do you want to become a well-known developer? Execute the orders of traders in the Freelance service!
Nauris Mucenieks
839
Nauris Mucenieks 2015.04.29 21:21 

so, lets say - i have an EA, which for some procedures uses some info from previous trades.

in my case - after a trade has hit TP, another trade is opened, in the same direction, but the parameters of the trade are changed.

is it possible to invoke a string of code, that would erase all such info, after a specific event (in this case, all trades are closed after X % equity growth).


big thanks to anyone reading.

Cornelis Duiker
1265
Cornelis Duiker 2015.04.29 23:07  
I think you need to provide a little more info.  Your question is very ambigious.  Sorry...
Nauris Mucenieks
839
Nauris Mucenieks 2015.04.29 23:48  
cornelis duiker:
I think you need to provide a little more info.  Your question is very ambigious.  Sorry...

oh.

well, question would be -

is it possible to "re-instate" the EA to the starting point?

clearing all records, caches, every info it has gathered for its own purposes?


on a live test, that would be simple - closing the terminal, and attaching the EA anew. but thats kinda manual, dont you think?

Stuart Browne
5821
Stuart Browne 2015.04.30 00:29  
Nauris Mucenieks:

oh.

well, question would be -

is it possible to "re-instate" the EA to the starting point?

clearing all records, caches, every info it has gathered for its own purposes?


on a live test, that would be simple - closing the terminal, and attaching the EA anew. but thats kinda manual, dont you think?


I've never used it in an EA so can't guarantee this will work but I use this line a lot in indicators to "re-start" them:

ChartSetSymbolPeriod(0,NULL,0);

 It basically just re-loads the current symbol and time frame which forces the indy to de-init and re-init. With an EA, you may also need to make sure in Options->Expert Advisors you uncheck the option "Disable trading when chart symbol or period has changed". Again, I've never tried it with an EA so you'll need to experiment.

Of course, it will also depend on the logic of your EA as to what happens when the EA reloads. If it sets/gets any global variables then you may also need to deal with them during init.

Nauris Mucenieks
839
Nauris Mucenieks 2015.04.30 01:06  
Stuart Browne:


I've never used it in an EA so can't guarantee this will work but I use this line a lot in indicators to "re-start" them:

 It basically just re-loads the current symbol and time frame which forces the indy to de-init and re-init. With an EA, you may also need to make sure in Options->Expert Advisors you uncheck the option "Disable trading when chart symbol or period has changed". Again, I've never tried it with an EA so you'll need to experiment.

Of course, it will also depend on the logic of your EA as to what happens when the EA reloads. If it sets/gets any global variables then you may also need to deal with them during init.

i played around with it a bit, sadly has no real effect, or at least doesnt do what i hoped for.

real neat trick tho, ill test it out on live, see what it does.

now at least i know for sure what i am looking for :

a function that will " de-init and re-init " an EA.


big thanks, by the way.

Stuart Browne
5821
Stuart Browne 2015.04.30 01:08  
Nauris Mucenieks:

i played around with it a bit, sadly has no real effect, or at least doesnt do what i hoped for.

real neat trick tho, ill test it out on live, see what it does.

now at least i know for sure what i am looking for :

a function that will " de-init and re-init " an EA.


big thanks, by the way.

Very welcome. Do you actually have the mq code or only an ex file?
Nauris Mucenieks
839
Nauris Mucenieks 2015.04.30 01:15  
Stuart Browne:
Very welcome. Do you actually have the mq code or only an ex file?
i have the code.
Stuart Browne
5821
Stuart Browne 2015.04.30 01:21  
Nauris Mucenieks:
i have the code.
OK, just re-reading your original request. Can you not just check for % equity growth and when it hits your limit, close out all orders and reset all related variables?
Nauris Mucenieks
839
Nauris Mucenieks 2015.04.30 01:25  
Stuart Browne:
OK, just re-reading your original request. Can you not just check for % equity growth and when it hits your limit, close out all orders and reset all related variables?

not trying to sound silly, but thats kinda what im trying [?] to do.

i lack skill, sadly.


p.s.

if ran manually, it would be a different story - but without proper backtesting - its more like a game of chance.

Stuart Browne
5821
Stuart Browne 2015.04.30 01:48  
Nauris Mucenieks:

not trying to sound silly, but thats kinda what im trying [?] to do.

i lack skill, sadly.


p.s.

if ran manually, it would be a different story - but without proper backtesting - its more like a game of chance.

hehehe no problem. Might be time to call in a coder mate. Without seeing the code it's hard to say but it really shouldn't be that difficult so shouldn't cost too much.
Nauris Mucenieks
839
Nauris Mucenieks 2015.04.30 01:59  
Stuart Browne:
hehehe no problem. Might be time to call in a coder mate. Without seeing the code it's hard to say but it really shouldn't be that difficult so shouldn't cost too much.
thanks for the suggestion, if i wont be able to do it myself, ill probably have to.
To add comments, please log in or register