Force an EA to load the last used set file.

Post Reply
dietcoke
Trader
Posts: 162
Joined: Tue Nov 15, 2011 9:59 pm

Force an EA to load the last used set file.

Post by dietcoke »

Does anyone know if it is possible to load EA or indicator and force it to use the last settings it was run with?
f-trader
Trader
Posts: 27
Joined: Sat Feb 25, 2012 4:08 pm

Re: Force an EA to load the last used set file.

Post by f-trader »

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.
f-trader
Trader
Posts: 27
Joined: Sat Feb 25, 2012 4:08 pm

Re: Force an EA to load the last used set file.

Post by f-trader »

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.
dietcoke
Trader
Posts: 162
Joined: Tue Nov 15, 2011 9:59 pm

Re: Force an EA to load the last used set file.

Post by dietcoke »

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.
You do not have the required permissions to view the files attached to this post.
f-trader
Trader
Posts: 27
Joined: Sat Feb 25, 2012 4:08 pm

Re: Force an EA to load the last used set file.

Post by f-trader »

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.
Post Reply

Return to “Coders Hangout”