Hello ,
I need help to coding a function to close the trades based on each currency contribution as a percent of the account balance.
For example if I have a set of trades opened , USDJAP is giving 5% profit and I want to keep those trades open , while EURUSD is causing a 3% of the account in loss and I want to close those EURUSD trades only due to a percent risk their causing on the account.
I know how to close trades in terms of pips or dollar value , but I don't know how to close a set of trades as a percent of the main account whiteout affecting the other opened ones.
Any ideas ?
Equity contribution per currency
- mjws00
- Trader
- Posts: 609
- Joined: Fri Jan 04, 2013 10:17 pm
- Location: Victoria
Re: Equity contribution per currency
You are going to need to iterate through trade history and calculate the profit/loss for the pair (and all it's associated trades). There are a few dashboard indicators that will do the math for you, and show you the sample code. The actual close the trade code isn't much more than looping though the trades, checking the symbol, closing it if it is in the pair you want.
Pretty much every EA has some functions that loop trades to check for a closing conditions. Steve's BASE EA code would get you rolling. You'll have to add your own conditions but the framework will be there. LookForTradeClosure() is the function to start in.
Good luck.
Mike
Pretty much every EA has some functions that loop trades to check for a closing conditions. Steve's BASE EA code would get you rolling. You'll have to add your own conditions but the framework will be there. LookForTradeClosure() is the function to start in.
Good luck.
Mike
You do not have the required permissions to view the files attached to this post.
Reading the dark heart.
-
icon
- Trader
- Posts: 18
- Joined: Thu Apr 12, 2012 4:49 pm
Re: Equity contribution per currency
thanks a lot Mike