Help!

Hello,

Does anybody know of an EA that closes all the trades when net profit reaches a pre-defined level??

I have been testing a strategy on 5 min TF and sometimes I open orders across different pairs and it gets difficult to keep track of each and every trade. Some trades are in a floating profit while some are at a floating loss.
So, I was wondering if there is an EA that will close all the open positions when I reach a net floating profit of, say, $10? I searched across the web and found one but it does not work. It is attached below.

Any kind of help is appreciated.

thanks
Azz

close all positions at profit target.zip (1.35 KB)

Update: Ok, found a few more, including the “swiss army EA” and the likes.
All of them attach properly (I can tell from the smiley face on the chart) and I am sure i’m using the correct settings.
BUT none actually close orders. I set the profit target to just $5 but none closed any order even when the profit went to $10.
Need help

Hi Azzkikr,

Did you put the orders in after you have installed the ea or did you have open orders within your tradestation, installed the ea and see if it works?

Hi,
I’ve tried both i.e. adding the EAs before and after placing orders.
It shows the smiley face but just does not take any action.
Are you using such an EA and is it working for you?
Is anyone else here using it?
Do you think it could be because MT4 had a major data structure change in the new builds?
Most EAs are from 2012-13 so maybe they are not compatible with the latest build.
Any information is appreciated.
thanks

close all positions at profit target.zip (1.38 KB)
The original script has been modified for build 600; now this script shows you the inputs…
Please do some testing and inform me if it is OK

thanks pro34159
I’m on it…

Hi pro34159,

Thank you for your help.
I can see you have added program properties in the beginning and changed variable types (extern to input).
Unfortunately the program properties were preventing the EA from attaching to the chart and returned 9 warnings.
At first I thought it was because of a typo so I changed “show_inputs” to “script_show_inputs”. But that didn’t help.
I had to remove the 2 property statements altogether and the EA attached just fine and the warning were gone.
It still doesn’t do anything though. Ran it whole day with different profit values from $5 to $25.
Doesn’t close any orders, just sits there doing nothing.

Any other inputs? Do you think it has something to do with my broker? I get 5 decimal quotes BTW.
-azz

Hello,

I have 5 digits too.
do not worry for warnings…are warnings not errors;many of these warning are generated by “strict” property.
the property"show_inputs" is important for build 600 because show you the inputs…

Do you see any error in the Expert Tab like this:

2014.09.05 07:50:04.839 zero divide in ‘close all positions at profit target.mq4’ (149,92)

this error has been generated by “AccountMargin()” returning zero!! (fixed in the attached script)

I tested on my side having one trade with a 0.02 profit…

input “closes only profitable trades” true
input “Only trades above this amount close out” 0.0

and the script successfully closed the trade

the attached script is without warnings…

I hope this help…

hello,

Thank you again. But the EA just wont attach to my charts. I’ve tried it on real as well as demo accounts.
I’ve tried placing it in different directories. It just wont attach unless I remove the “property” statements.
This is odd because it is working for you.
I will try messing around with the settings.
Could you take a quick screenshot of your chart and show me please?
My MT4 is build 670… in case this helps.

-azz

I have the same built. My be a setting issue;look at “Options”, "tab “Expert Advisor”

what do you see when trying to attach the script in the Experts tab?
I see this:

2014.09.13 18:31:20.113 close all positions at profit target EURUSDp,H4: initialized
2014.09.13 18:31:20.103 close all positions at profit target EURUSDp,H4 inputs: ProfitTarget=25.0; CloseAllNow=false; CloseProfitableTradesOnly=false; ProftableTradeAmount=1.0; ClosePendingOnly=false; UseAlerts=false;
2014.09.13 18:31:18.633 Script close all positions at profit target EURUSDp,H4: loaded successfully

no errors at all in the Experts tab when attaching the script?

However I will send you a screenshot next monday.

hello,

before2.jpg: the existing trade
inputs2.jpg: the selected inputs
after.jpg: trade closed
after3.jpg: the message in the chart

bye

Hi,

That’s funny… It seems to be working fine for you. When I attach it to my chart I see the same details as you see on the top left. Also there are no errors in the experts tab. Anyways, I’ve given up on it. Guess i’ll have to be quick with my fingers.
Thank you for you time and help. I really appreciate it.

happy trading :slight_smile: