Forex



Go Back   Forex Trading > Downloads > Expert Advisors - Metatrader 4
Forex Forum Register More recent Blogs Calendar Advertising Others Help






Register
Welcome to Forex-TSD!, one of the largest Forex forums worldwide, where you will be able to find the most complete and reliable Forex information imaginable.

From the list below, select the forum that you want to visit and register to post, as many times you want. It’s absolutely free. Click here for registering on Forex-TSD.

Exclusive Forum
The Exclusive Forum is the only paid section. Once you subscribe, you will get free access to real cutting-edge Trading Systems (automated and not), Indicators, Signals, Articles, etc., that will help and guide you, in ways that you could only imagine, with your Forex trading.
  • Elite Section
    Get access to private discussions, specialized support, indicators and trading systems reported every week.
  • Advanced Elite Section
    For professional traders, trading system developers and any other member who may need to use and/or convert, the most cutting-edge exclusive indicators and trading systems for MT4 and MT5.
See more

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 03-12-2007, 02:37 PM
Senior Member
 
Join Date: Apr 2006
Posts: 158
InTrance is on a distinguished road
Closing all orders EA?

Hi,

I've been working on a system and I'm in need of an EA that will close all orders (active and pending) as soon as a profit target is hit (lets say 30 pips, or an $ value). I'll be running a set of EAs for my testing so this EA should close all orders regardless of magic number.

Anyone seen such an EA?

Thanks a lot.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #2 (permalink)  
Old 03-12-2007, 05:38 PM
jkancil's Avatar
Junior Member
 
Join Date: Sep 2006
Location: Indonesia
Posts: 8
jkancil is on a distinguished road
extern int profit=30; //profit USD
int mgc=1234;

double pft;
int total=OrdersTotal();
for(int cnt=0;cnt<total;cnt++) {
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderMagicNumber()==mgc) pft=pft+OrderProfit();
}
if(pft>profit) {
for(cnt=0;cnt<total;cnt++) {
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderMagicNumber()==mgc) {
if(OrderType()==OP_BUY) OrderClose(OrderTicket(),OrderLots(),Bid,3,White); else
if(OrderType()==OP_SELL) OrderClose(OrderTicket(),OrderLots(),Ask,3,White); else
OrderDelete(OrderTicket());
}
}
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #3 (permalink)  
Old 03-12-2007, 06:59 PM
Senior Member
 
Join Date: Nov 2005
Posts: 168
mangman is on a distinguished road
This EA seems to work fine for me in closing all orders regardless of the magic number, active and pending, when the profit level is reached.
The default profit value is $30. You can set it to any $ value you wish externally.
Attached Files
File Type: mq4 CloseAll-PL.mq4 (4.2 KB, 734 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #4 (permalink)  
Old 03-12-2007, 10:28 PM
Senior Member
 
Join Date: Jun 2006
Posts: 744
yeoeleven is on a distinguished road
Closing EA

The EAs in this thread work well too

Close Open Trades EAs based on Equity

John
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #5 (permalink)  
Old 03-13-2007, 02:34 AM
Senior Member
 
Join Date: Apr 2006
Posts: 158
InTrance is on a distinguished road
Thanks a million guys!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #6 (permalink)  
Old 03-19-2007, 12:58 AM
Member
 
Join Date: Aug 2006
Posts: 30
gorinw9 is on a distinguished road
equity %

is it possible to add % of equity in addition to $ or pip values?..
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #7 (permalink)  
Old 08-08-2007, 03:56 PM
Member
 
Join Date: Jul 2007
Location: Frisco, Tx
Posts: 69
cochran1 is on a distinguished road
EA to close a trade when 2 MAs cross

A very kind programmer(thanks Shinigami) created an EA for me that will close a trade when 2 MAs cross. The EA is listed below. The MAs can be custom set, see parameter definitions at the following link.

iMA - MQL4 Documentation

-----------------------------------------
#property copyright "Shinigami© 2007"
#property link "Shini1984@gmail.com"
#define ORDER_ID 2016
extern int MA1.period =0;
extern int MA1.shift=0;
extern int MA1.method=0;
extern int MA1.price=0;
extern int MA2.period=0;
extern int MA2.shift=0;
extern int MA2.method=0;
extern int MA2.price=0;


int start()
{
if(CheckMACross()==1)
CloseOrders();
return(0);
}


int CheckMACross()
{
if(iMA(Symbol(),0,MA1.period,MA1.shift,MA1.method, MA1.price,2)<iMA(Symbol(),0,MA2.period, MA2.shift,MA2.method,MA2.price,2))
{
if(iMA(Symbol(),0,MA1.period,MA1.shift,MA1.method, MA1.price,1)>=iMA(Symbol(),0,MA2.period,MA2.shift, MA2.method,MA2.price,1))
return(1);
}
else if(iMA(Symbol(),0,MA1.period ,MA1.shift,MA1.method,MA1.price,2)>iMA(Symbol(),0, MA2.period,MA2.shift,MA2.method,MA2.price,2))
{
if(iMA(Symbol(),0,MA1.period,MA1.shift,MA1.method, MA1.price,1)<=iMA(Symbol(),0,MA2.period,MA2.shift, MA2.method, MA2.price,1))
return(1);
}
else return(0);
}


int CloseOrders()
{
for(int i=0;i<OrdersTotal();i++)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
//if(OrderMagicNumber()!=MagicNumber)
//continue;
if(OrderSymbol()!=Symbol())
continue;
if(OrderType()==OP_BUY)
OrderClose(OrderTicket(),OrderLots(),Bid,3);
if(OrderType()==OP_SELL)
OrderClose(OrderTicket(),OrderLots(),Ask,3);
}
return(0);
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #8 (permalink)  
Old 08-14-2007, 06:35 AM
Junior Member
 
Join Date: Aug 2007
Posts: 17
fxgroup is on a distinguished road
Hi,
Quite interesting but how could this EA define that it need to CLOSE for OPEN BUY or to CLOSE OPEN SELL POSITION . What I means is this EA should CLOSE OPEN BUY or OPEN SELL POSITION ?

Thank you.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #9 (permalink)  
Old 08-14-2007, 06:40 AM
Junior Member
 
Join Date: Aug 2007
Posts: 17
fxgroup is on a distinguished road
Hi,
Quite interesting but how could this EA Code define which one it should CLOSE.
OPEN BUY POSITION or OPEN SELL POSITION.

Thank you.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #10 (permalink)  
Old 08-14-2007, 09:50 PM
Member
 
Join Date: Jul 2007
Location: Frisco, Tx
Posts: 69
cochran1 is on a distinguished road
Not Sure, I requested this EA but I do not code myself. I have been using this and it seems to work ok. This just closes a trade when the EAs cross. thx
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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
modify orders and close pending orders bkgridley Questions 8 05-23-2007 10:49 PM
Closing Pending Orders bkgridley Expert Advisors - Metatrader 4 1 05-11-2007 06:47 AM
Closing positions before new day jorgeng Metatrader 4 5 04-11-2007 08:40 AM
EA Help Needed - Closing Existing Orders SuzanneFX Metatrader 4 1 12-26-2006 03:28 PM
EA - closing all positions at once. ra300z Metatrader 4 6 09-08-2006 02:45 AM


All times are GMT. The time now is 01:26 PM.



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