stevehopwoodforex.com
https://www.stevehopwoodforex.com/phpBB3/
Print view

Force an EA to load the last used set file.
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=1346
Page 1 of 1
Author:  dietcoke [ Mon Dec 31, 2012 3:11 pm ]
Post subject:  Force an EA to load the last used set file.

Does anyone know if it is possible to load EA or indicator and force it to use the last settings it was run with?
Author:  f-trader [ Tue Jan 01, 2013 2:27 pm ]
Post subject:  Re: Force an EA to load the last used set file.

dietcoke wrote:Does anyone know if it is possible to load EA or indicator and force it to use the last settings it was run with?
Doing this manually is what you certainly know already:
1. Attach the EA , load the set-file.
2. Save a template.
Each time you want the EA with the settings, apply the template to the chart.

Disadvantage: Each time you want other settings, you need to save a new template manually.

Maybe you want something more convenient ?

The only way to do this I know of is this: ( I did not test it )
1. Download the ServicesMt4 package here:
http://codebase.mql4.com/ru/7085/page2#comments
Sorry, it is only in russian, you need google translation or something, but the commands are in english

I see 2 dll-calls in ServicesMt4 which you could use in your EA:

// 4.4.2.
void ServiceSetTemplateByName(int hwndChart, string sNameTemplate);

and

// 4.4.1.
void ServiceSaveTemplate(int hwndChart, string sNameTemplate);

At the appropriate location you make the EA saving the template for the chart it is attached to.
And likewise you make the EA to set the template.

Maybe you need a GlobalVariable to prevent the EA going into a loop where it constantly saves and sets the template, but I think it can be handled.

I have used some function-calls and yes, they work. The ServicesMt4 is a good package. What a pity there is no english instruction manual for it.

And finally a "normal" way to force an EA or indicator to use the latest settings it has been run with:
Store the settings in GlobalVariables or a file ( maybe in deinit() function ) and in init() you read all values
from the storage and thus it will use the latest settings.
Author:  f-trader [ Fri Jan 11, 2013 11:28 pm ]
Post subject:  Re: Force an EA to load the last used set file.

dietcoke,
if it is not too much work for you to give me a feedback, I would appreciate it.

I think if somebody is asking for something and somebody else is taking his time to answer,
it is a matter of decency and civility, to give a feedback, regardless if the suggestions
are valuable or not.
Author:  dietcoke [ Mon Jan 14, 2013 8:38 am ]
Post subject:  Re: Force an EA to load the last used set file.

f-trader wrote:dietcoke,
if it is not too much work for you to give me a feedback, I would appreciate it.

I think if somebody is asking for something and somebody else is taking his time to answer,
it is a matter of decency and civility, to give a feedback, regardless if the suggestions
are valuable or not.

:) I never saw your reply. I don't generally browse the russian MQL site as it's often too time consuming to work out what they were trying to achieve but that's an interesting looking add-on you have found.

Ideally, I'm after something that isn't a dll though. Switching templates is probably the way to do this and I'll probably use a mod to this template switcher.
Author:  f-trader [ Mon Jan 14, 2013 5:30 pm ]
Post subject:  Re: Force an EA to load the last used set file.

dietcoke wrote: Ideally, I'm after something that isn't a dll though. Switching templates is probably the way to do this and I'll probably use a mod to this template switcher.
The template switching script you posted uses a dll.
It is impossible to accomplish changing a template or profile from within an EA or indicator or script
without using the windows api and that is only possible via a dll.

If you want no dll, I already explained how to accomplish using the last settings.
Store the settings in GlobalVariables or a file ( maybe in deinit() function ) and in init() you read all values
from the storage and thus it will use the latest settings.
If somebody knows a better solution, please post it. I am interested to learn about it.
All times are UTC Page 1 of 1