Forex
Google
New signals service!

Go Back   Forex Trading > Discussion Areas > Metatrader 4


Register in Forex TSD!
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time).
Click here to register and get more information

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-06-2007, 07:32 PM
Junior Member
 
Join Date: May 2006
Posts: 20
witchazel is on a distinguished road
Question Calling a Script from an EA

is there a way to call a script from an EA?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-06-2007, 10:42 PM
jhernandez's Avatar
Member
 
Join Date: Mar 2006
Posts: 35
jhernandez is on a distinguished road
Quote:
Originally Posted by witchazel
is there a way to call a script from an EA?
Move the code in your script to an include file in the "experts\include" folder.

You can then include this script in your EA by adding the following line to the top of your EA file:

PHP Code:
#include <MySampleScript.mqh> 
From there you can call whatever function you need from your include file.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-06-2007, 11:34 PM
Junior Member
 
Join Date: May 2006
Posts: 20
witchazel is on a distinguished road
Quote:
Originally Posted by jhernandez
Move the code in your script to an include file in the "experts\include" folder.

You can then include this script in your EA by adding the following line to the top of your EA file:

PHP Code:
#include <MySampleScript.mqh> 
From there you can call whatever function you need from your include file.
Thank you! will this allow it to run autonomously? i have a buy/sell script as well as an exit script i would like to run almost as a "multithread" so my EA doesnt get bogged down.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-07-2007, 05:59 PM
jhernandez's Avatar
Member
 
Join Date: Mar 2006
Posts: 35
jhernandez is on a distinguished road
I dont think Metatrader supports multi-threading, when you call your buy/sell function from your include file your main EA will wait for it to finish. You can't 'kick off' your script to start running this way.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-08-2007, 01:33 PM
jhernandez's Avatar
Member
 
Join Date: Mar 2006
Posts: 35
jhernandez is on a distinguished road
You can assign a hotkey to your script, and then have your EA simulate 'pressing' the hotkey which will trigger your script to run as a process outside of your EA. That way the EA and the script are independent of each other.

This should give you a 'poor mans' version of multi threading in Metatrader.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 04-08-2007, 02:53 PM
Junior Member
 
Join Date: Apr 2006
Posts: 28
Mis B. Havin' is on a distinguished road
jhernandez


Can you loop a script so it runs continually. I understand that it will run within an endless loop. Would this be correct?

Can you have two copies of the same currency and or time frame open at the same time and have an entrence script on one and your exit script on the other to operate continually in that way all the scripts have to do is reconize the orders.

If this can be done you will need to entroduce a means to stop the scripts, which should not be to difficault to do.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 04-08-2007, 04:42 PM
jhernandez's Avatar
Member
 
Join Date: Mar 2006
Posts: 35
jhernandez is on a distinguished road
Yes, you can have a script loop endlessly on a chart. Not sure if you need to have two scripts running, since you can probably add the logic for buying/selling in the same script.

I would also try to space out the looping a bit in your code, adding something like Sleep(500); or Sleep(1000);, so that your code waits 1/2 or 1 second in between loops. Otherwise you might see your script take up a lot of your available memory.

Juan
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 09-21-2008, 09:25 PM
matrixebiz's Avatar
Senior Member
 
Join Date: Oct 2006
Posts: 1,159
matrixebiz is on a distinguished road
How can I set the EA to only call the script ONCE at a specific time and Day?

Last edited by matrixebiz; 09-21-2008 at 09:36 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
HMA - Calling All Programmers!! secxces Indicators - Metatrader 4 58 01-26-2008 09:19 PM
Calling 5_34_5 into an E.A. mrtools Setup Questions 1 11-27-2006 01:52 AM
Calling All Coders And Specialists jwoger Indicators - Metatrader 4 11 08-01-2006 05:19 AM
Calling Programmers/Coders... Aaragorn Expert Advisors - Metatrader 4 11 06-19-2006 05:15 PM


All times are GMT. The time now is 07:34 PM.



Search Engine Friendly URLs by vBSEO 3.2.0 ©2008, Crawlability, Inc.