• Home
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • User/Email: Password:
  • 6:26am
Menu
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • 6:26am
Sister Sites
  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Options

Bookmark Thread

First Page First Unread Last Page Last Post

Print Thread

Similar Threads

required to function call function 2 replies

my LockInProfit() and CloseAll() fail to close everything 6 replies

CloseAll Scritp!!! Some modifications needed!!! 0 replies

stop loss function and edit time function for Breakout EA 1 reply

Sleep function question 0 replies

  • Platform Tech
  • /
  • Reply to Thread
  • Subscribe
  • 1
Attachments: Question on closeAll function
Exit Attachments
Tags: Question on closeAll function
Cancel

Question on closeAll function

  • Post #1
  • Quote
  • First Post: Edited 8:24pm May 10, 2009 8:08pm | Edited 8:24pm
  •  Qpip
  • | Joined Jul 2007 | Status: Member | 993 Posts
Here’s the challenge.

Multiple (manual or EA) trades that all need to be CLOSED OUT if:

1) Total profit (in pips or $) reaches x
2) Total loss reaches x (may be positive, here’s the challenge – ie: goes down to x from here)
3) Day is Friday and/or time is 15:00.
4) Some major news is upcoming in x days/minutes

Anything else you can think of to secure profits/reduce losses without resorting to SLs.

I’m mostly interested in (2) when let’s say I have 4 open trades that total 50 pips. A half hour later, it’s down to 19. I have to leave the house. I’d put the EA to 1 if profit goes DOWN to 1. Problem is with the CLOSE ALL EA (the general one), if I do this, of course it closes out all trades (because they’re above 1). I want this thing to be able to close all trades if the total profit goes DOWN from here (the moment I put the EA on) to 1.

Could be a script, I dunno, not a programmer myself unfortunately.

Anyone up for the challenge?
  • Post #2
  • Quote
  • May 10, 2009 11:20pm May 10, 2009 11:20pm
  •  goingforward
  • | Joined Feb 2009 | Status: You can't lose what you don't have! | 123 Posts
Quoting Qpip
Disliked
Here’s the challenge.

Multiple (manual or EA) trades that all need to be CLOSED OUT if:

1) Total profit (in pips or $) reaches x
2) Total loss reaches x (may be positive, here’s the challenge – ie: goes down to x from here)
3) Day is Friday and/or time is 15:00.
[size=3][font=Times New Roman]4) Some major news is upcoming in...
Ignored
Hi Qpip,

I am attaching an EA which has several options including the ability to close based on total dollar amount (positive or negative) and by percentage as well. In addition, you have other options that you can work with. Check it out and test it in a demo account before using it please.

Regards,

GF
Attached File(s)
File Type: mq4 MoneyManagement.mq4   7 KB | 484 downloads
 
 
  • Post #3
  • Quote
  • May 13, 2009 1:10pm May 13, 2009 1:10pm
  •  Qpip
  • | Joined Jul 2007 | Status: Member | 993 Posts
Thanks GF,

What I'm looking for is "close all trades if total balance goes DOWN FROM HERE TO x". Let's say my 4-5 open trades on different currencies currently total 50 pips. Some are positive, others negative. I want to able to input "10" for example, and when the total balance goes down to 10, all trades are closed.

Might not even be programmable, I don't know.

Anyway, thanks for your help.

Qpip

Quoting goingforward
Disliked
Hi Qpip,

I am attaching an EA which has several options including the ability to close based on total dollar amount (positive or negative) and by percentage as well. In addition, you have other options that you can work with. Check it out and test it in a demo account before using it please.

Regards,

GF
Ignored
 
 
  • Post #4
  • Quote
  • May 13, 2009 1:25pm May 13, 2009 1:25pm
  •  Zen_Leow
  • Joined Jun 2008 | Status: Programming for a better future. | 649 Posts
Quoting Qpip
Disliked
Here’s the challenge.

Multiple (manual or EA) trades that all need to be CLOSED OUT if:

1) Total profit (in pips or $) reaches x
2) Total loss reaches x (may be positive, here’s the challenge – ie: goes down to x from here)
3) Day is Friday and/or time is 15:00.
[size=3][font=Times New Roman]4) Some major news is upcoming...
Ignored
1, 2 and 3 are very easy.

point 4 sounds same as point 3. assuming you know the news time in advance and is able to key into the EA.
Programming for a better future.
 
 
  • Post #5
  • Quote
  • May 13, 2009 7:26pm May 13, 2009 7:26pm
  •  Qpip
  • | Joined Jul 2007 | Status: Member | 993 Posts
Quoting Zen_Leow
Disliked
1, 2 and 3 are very easy.

point 4 sounds same as point 3. assuming you know the news time in advance and is able to key into the EA.
Ignored
Hi Zen,

Well, it's (2) I'm most interested in, but I think it isn't "programmable" ?!?
 
 
  • Post #6
  • Quote
  • Last Post: May 14, 2009 6:58am May 14, 2009 6:58am
  •  Zen_Leow
  • Joined Jun 2008 | Status: Programming for a better future. | 649 Posts
Didn't I just say it's easy? why do you insist that it's not programmable?

I've done it for someone's EA but due to confidentiality agreement I can't post it here.

The concept is simple. all that needs to be done is loop through all currently opened trades, get the point value of the currency pair in question using MarketInfo with OrderSymbol(). then get the difference between the order open price using OrderOpenPrice() and that currency's Bid or Ask using again MarketInfo function along with the OrderSymbol(). With these info you get the pip value of the trade. add up the pip value of all the trade and compare to your cut off point. if reached, close all starting from the newest order first.

if you're using dollar value instead of pip value. that's even much more simpler. just loop through all currently opened trades and add up their current dollar profit/loss using OrderProfit( ) function. then counter check the total balance with your cut off point.

all simple tasks, all easily done with very few lines of codes.

regards,
Zen
Programming for a better future.
 
 
  • Platform Tech
  • /
  • Question on closeAll function
  • Reply to Thread
0 traders viewing now
Top of Page
  • Facebook
  • Twitter
About FF
  • Mission
  • Products
  • User Guide
  • Media Kit
  • Blog
  • Contact
FF Products
  • Forums
  • Trades
  • Calendar
  • News
  • Market
  • Brokers
  • Trade Explorer
FF Website
  • Homepage
  • Search
  • Members
  • Report a Bug
Follow FF
  • Facebook
  • Twitter

FF Sister Sites:

  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Forex Factory® is a brand of Fair Economy, Inc.

Terms of Service / ©2023