Forex
Google

Go Back   Forex Trading > Metatrader Training > Metatrader 4 mql 4 - Development course
Forex Forum Register FAQ Members List Calendar Search Today's Posts Mark Forums Read


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 11-02-2006, 06:10 PM
Mr.Marketz Mr.Marketz is offline
Senior Member
 
Join Date: Feb 2006
Posts: 230
Mr.Marketz is on a distinguished road
Trouble Shooting

So I’m trying to piece together my first EA… obviously I’m at a dead end. The concept is to combine two functions which are:

Run (close profitable trades) executed every designated (time cycle)
I have two user input options – 1 (define profitable) and 2 define (time cycle). I believe most of the code is in order.

I am left with one last error “end program”... and I can't figure out why. Can someone with a bit more experience at coding please correct what I’m doing wrong? It’s driving me CRAZY!!!

Thanks in advance,
MM
Attached Files
File Type: mq4 Close all profitable positions on time.mq4 (1.4 KB, 19 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 11-02-2006, 07:36 PM
Michel Michel is offline
Senior Member
 
Join Date: Feb 2006
Posts: 509
Michel is on a distinguished road
Quote:
Originally Posted by Mr.Marketz
So I’m trying to piece together my first EA… obviously I’m at a dead end. The concept is to combine two functions which are:

Run (close profitable trades) executed every designated (time cycle)
I have two user input options – 1 (define profitable) and 2 define (time cycle). I believe most of the code is in order.

I am left with one last error “end program”... and I can't figure out why. Can someone with a bit more experience at coding please correct what I’m doing wrong? It’s driving me CRAZY!!!

Thanks in advance,
MM
The "For" do not have an ending bracket
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 11-03-2006, 07:28 PM
Mr.Marketz Mr.Marketz is offline
Senior Member
 
Join Date: Feb 2006
Posts: 230
Mr.Marketz is on a distinguished road
Thanks

Did as suggested, and compiles fine now. However upon running it live I noticed it did not work as specified. In other words I set the time update to 15 min and it never initialized the Close All Profitable Positions script. Any thoughts?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 11-03-2006, 09:29 PM
Michel Michel is offline
Senior Member
 
Join Date: Feb 2006
Posts: 509
Michel is on a distinguished road
PHP Code:
double   LastUpdate CurTime();
//----
if (MathAbs(CurTime()-LastUpdate)> UpdateInterval*60
This will never work, as at each tick you assign at lastUptade the value Curtime(), then, immediately after, you check if there is a difference between both...no.
The right way is:
PHP Code:
if(CurTime() >= LastUpdate UpdateInterval*60)
{
   
BlahBlahBlah;
   
LastUpdate CurTime();

My 2 cents : Why this time trick ? you can check all your orders every tick and close those which have reached your target !

EDIT : sorry, I didn't see it is a Script and not an EA, so there is another reason why it doesn't work : a script is executed only once : if you want to check something periodically, you have to write some loop in the code

Last edited by Michel : 11-03-2006 at 09:38 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 11-07-2006, 08:37 PM
Mr.Marketz Mr.Marketz is offline
Senior Member
 
Join Date: Feb 2006
Posts: 230
Mr.Marketz is on a distinguished road
Quote:
Originally Posted by Michel
PHP Code:
double   LastUpdate CurTime();
//----
if (MathAbs(CurTime()-LastUpdate)> UpdateInterval*60
This will never work, as at each tick you assign at lastUptade the value Curtime(), then, immediately after, you check if there is a difference between both...no.
The right way is:
PHP Code:
if(CurTime() >= LastUpdate UpdateInterval*60)
{
   
BlahBlahBlah;
   
LastUpdate CurTime();

My 2 cents : Why this time trick ? you can check all your orders every tick and close those which have reached your target !

EDIT : sorry, I didn't see it is a Script and not an EA, so there is another reason why it doesn't work : a script is executed only once : if you want to check something periodically, you have to write some loop in the code
Thanks Michel,

I might have to leave this one to the pros.

MM
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 11-07-2006, 08:48 PM
Michel Michel is offline
Senior Member
 
Join Date: Feb 2006
Posts: 509
Michel is on a distinguished road
Quote:
Originally Posted by Mr.Marketz
Thanks Michel,

I might have to leave this one to the pros.

MM
No ! You will never learn if you do not try !
Just write an EA to close your trades, not a script : put your test and the close func in the "start" func without any time-trick, that's all : at every tick the start function is called, there all your trades will be checked and eventually closed.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hammer and Shooting Star indicator Marbo Indicators - Metatrader 4 12 03-30-2007 02:07 PM
anyone having trouble with marketiva increase General Discussion 2 02-09-2007 03:08 AM
Trouble with bars pabloschiki Metatrader 4 4 08-29-2006 08:09 PM
having trouble with multiple EAs ycomp Expert Advisors - Metatrader 4 6 03-03-2006 04:41 AM


All times are GMT. The time now is 09:25 AM.