Forex
Google
New signals service!

Go Back   Forex Trading > Downloads > Expert Advisors - 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 08-22-2006, 04:57 PM
Senior Member
 
Join Date: Jan 2006
Posts: 80
jyrik is on a distinguished road
looking simple ea

Im looking ea what would close all open and pending orders in specific time.
Example I want all orders close at 9 PM GMT???
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 08-22-2006, 05:48 PM
Senior Member
 
Join Date: Mar 2006
Posts: 787
Maji is on a distinguished road
Try to incorporate the following snippet in your code.

In the main body,

if(CurTime() >= expiration) CloseAll();

And the CloseAll routine is:
PHP Code:
void CloseAll()
{
 
int tradecerrNumberOfTries=100;
 
bool closed;
 
int trades=OrdersTotal();
 for(
trade=0;trade<trades;trade++)
 {
  
OrderSelect(trade,SELECT_BY_POS,MODE_TRADES);

  if(
OrderSymbol()!=Symbol()||OrderMagicNumber()!=MagicNumber)
   continue;
   
  if(
OrderSymbol()==Symbol()&&OrderMagicNumber()==MagicNumber)   
  if(
OrderType()==OP_SELL || OrderType()==OP_BUY)
         for(
NumberOfTries c++)
         {
            
closed=OrderClose(OrderTicket(),OrderLots(),Ask,Slippage,Red);
            if (
closed) break;
            
err=GetLastError();
            if(
err==0)
            { 
               break;
            }
            else
            {
               if(
err==|| err==137 ||err==146 || err==136//Busy errors
               
{
                  
Sleep(5000);
                  continue;
               }
               else 
//normal error
               
{
                  break;
               }  
            }
         } 
   
 }
//for

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 08-22-2006, 05:59 PM
Senior Member
 
Join Date: Jan 2006
Posts: 80
jyrik is on a distinguished road
no i am looking separate ea. I dont want to add anything
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 08-22-2006, 06:17 PM
Senior Member
 
Join Date: Dec 2005
Location: In front of my trading desk
Posts: 344
Devil2000 is on a distinguished road
Quote:
Originally Posted by jyrik
no i am looking separate ea. I dont want to add anything
So you don't have any EA? do you have your own system? if yes you can ask somebody here or pay somebody outthere to coding it. If no, my suggestion is.. create your system, tweak it until it's profitable in the long run, then learn mql4 programming or pay somebody to create an EA based on it. To write an EA maybe a lot simpler than create or tweak a good system that suit you.

Learn and learn is the only way to survive. Maji already assist you to write that code. Market is always changing, today's best EA may save you for a while, someday it won't suit the market anymore. If you have a proper forex knowledge, you can tweak it until it's profitable again, and create a new EA again. Better to learn fishing rather than asking for a fish.

Just my 2 cents
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
SIMPLE-MACD-EA : An extremely simple EA based on 2 channels of MACD. Try it! investor_me Expert Advisors - Metatrader 4 31 07-30-2008 09:59 AM
My Simple EA Pepbullish Expert Advisors - Metatrader 4 5 02-10-2007 05:11 AM
Need some simple help with an EA... Gavner Metatrader 4 1 05-07-2006 06:06 AM


All times are GMT. The time now is 03:04 PM.



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