PDA

View Full Version : EA fix: Close all positions at profit target X



anaais6
05-10-2010, 10:37 PM
Hello programming experts. This very simple EA enables multiple (usually hedged) trades to be closed when an inputed profit goal is attained. It is very useful.

But as with other easy EA's of its kind I've examined, when the profit goal is attained, it is going to begin to close rankings, but then it will stop closing positions when that floating profit drops below the goal level (easy to occur if the price is shing or the adverse trades would be the last to be closed). . So it tends to leave 1 or two transactions open. . Then will close them only when the profit goal returns again... not a fantastic situation for hedged trades as you stay exposed to the market one way or another. .

Can anybody fix this: Once the profit goal is hit must close 100 percent of open trades and dismiss any change to that floating profit level during the execution process.

If anyone can fix this from the goodness of the heart and good, but when someone with a fantastic background onforexsoutheast.asia(multiple coupons) needs me to pay them a modest sum for their services then please send me a PM. Thanks!
https://www.forexsoutheast.asia/attachments/1518414051740190990.mq4

Skrup
11-22-2021, 08:55 PM
Hi Hedgehog,
The code you have should work to shut everything unless there's an error - like the price is too close or slippage is too great.

I made a fast change that is more aggressive. If certain positions have mistakes, it just keeps trying - forever. I believe they will close.

I am not at my computer with MT4, so I was not able to compile it, but I think that it's OK. Give it a shot.

Viper
https://www.forexsoutheast.asia/attachments/15184140531937157447.mq4

M.Oxrrero
11-22-2021, 10:16 PM
Hence that the viper is back?
But at office !
Let's kidnap his Boss

anaais6
11-22-2021, 11:37 PM
Hi Hedgehog,
The code you have should work to close everything unless there's an error - like the price is too close or slippage is too great.

I created a fast shift that is more aggressive. If certain positions have errors, it just keeps trying - . I believe they will close eventually.

I'm not at my computer with MT4, therefore I was unable to compile it, but I think that it's OK. Give it a shot.

Viper Many thanks for your help Viper. I have run several tests in demo mode and it has not yet triggered in closing all places - so far so great, and I will keep throwing more scenarios within the forthcoming days at it.
Thanks again, and when there's any way I could ever return the favour, please don't hesitate to let me know.
Cheers.

Skrup
11-23-2021, 12:57 AM
No difficulty in any way. Allow me to know how it ends up. If you stumble upon a million dollar egy, just share ;--RRB-

Viper


Many thanks for your help Viper. I have run several tests today and it has not yet triggered in closing all places - so far so great, and I will keep throwing more situations over the coming days.
Thanks again, and when there is a way I could return the favour, then please do not hesitate to let me know.
Cheers.

anaais6
11-23-2021, 02:18 AM
No difficulty in any way. Allow me to know how it works out. If you stumble on a thousand dollar egy, just share ;--RRB-

Viper Viper - just wanted to let you know that this 'close all' EA is working brilliantly, demo and live. It doesn't stumble if the floating profit changes during the closure process I tried.

Excellent work - thanks again.

Cheers

amendimar
11-23-2021, 03:39 AM
TradingViper - seems you are the gun at closing transactions while in profit. Perhaps you can assist with this requirement.

The situation is my EA may have 50 transactions available - particularly during sideways movements, say 20-30 Buys and 20-30 sells.

However, when a breakout sign comes in, I need only the profitable flip unwanted transactions to close, not to shut the open transactions which are already in favour of the breakout.

That's, I don't utilize take profit or stop loss configurations. A new sign will come in saying breakout south or northwest, and also the profitable wrong way bets will need to be closed.

Staying wrong way bet transactions get picked up after during retracement etc - I am not worried about the dregs left over.

I would like to whack this shut in profits code into my existing EA.

If this can be achieved, then the profitable trades reverse the breakout could be closed out sweetly, and then transactions on the right side of the breakout get more leverage.

I really don't see this as a seperate EA, I see it's a Take Profit upon sign method inside the present EA.

Hope you can help

Skrup
11-23-2021, 05:00 AM
Hey Phil,

This Seems simple enough. Point me to where the EA is (all files) and I will add this to you. Should only take a couple of minutes, supposing the EA is written well enough for me to decode where to include this code...

Keep Dancing,
Viper


TradingViper - seems you're the gun in closing multiple trades while in profit. You can assist with this need.

The problem is my EA may have 50 trades open - especially during sideways movements, state 20-30 Buys and 20-30 sells.

However, when a breakout sign comes in, I want only the profitable flip side trades to close, not to close the open trades which are already in favour of this breakout.

That is, I don't utilize take profit or stop loss configurations. A new sign will come in saying breakout south or north, and also the profitable...

amendimar
11-23-2021, 06:20 AM
Hey Viper Trading,

Sorry for the late answer - your requirements have been challenging to meet as I am new to this particular coding racket material.

My bot is not so mature that it would be all set for your Cool Hand Luke stuff (old Paul Newman movie, revealing my age I guess).

I Believe I have sorted the Take Profit by Order Sort dilemma. Per the below pic,

I added

extern int minTPbuy
extern int minTPsell

at the top of my code, added
Inserted Code if (Order == SIGNAL_CLOSESELL (OrderProfit() gt;= minTPsell) ((EachTickMode !) TickCheck) || (! EachTickMode (Bars ! = BarCount)))) { OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, DarkOrange);
As an example of closing sells in a minimum profit.

Really, I find the final quite practical.

I'm VERY CURIOUS about All of the void stuff on your EA and of the OP.

What is this void code about?
https://www.forexsoutheast.asia/attachments/1518414055553453824.jpg

AliceOxcness
11-23-2021, 07:41 AM
Hi Hedgehog,
The code you have should work to close everything unless there's an error - such as the price is too near or slippage is too great.

I made a quick change that's more competitive. If certain positions have mistakes, it just keeps trying forever. I think they will close eventually.

I'm not in my computer with MT4, so I was not able to compile it, but I think that it is OK. Give it a shot.

Viper hi viper. .

I have a question,

I glue the scripts in my experts/scripts folder, but, how do I choose TP?

csampic
11-23-2021, 09:02 AM
Hello....


Will you help me


Close All Lot (instant and pending order) when current price retracement and attaining to any take profit . And shut all lot with this pair just. Not yet for another pair. Because We've put on separate state



Thank You.

Aricalcar
11-23-2021, 10:23 AM
Hello programming experts. This very simple EA allows multiple (usually hedged) trades to be shut when an inputed profit goal is attained. It's potentially helpful.

However, as with other easy EA's of its type I've examined, once the profit goal is attained, it will begin to close rankings, but it will stop closing positions if that floating profit drops below the goal level (simple to occur if the price is changing or the negative trades would be the last to be shut). . So it tends to leave two or 1 trades. . And then will shut... I neglect to get the ea. Can anybody send me

nedus8976
11-23-2021, 11:44 AM
Hi Hedgehog, The code you have should work to close everything unless there's an error - like the price is too near or slippage is too fantastic. I made. If specific positions have errors, it just keeps trying . I think they will close eventually. I think that it is OK, although I'm not at my computer with MT4, therefore I was unable to compile it. Give it a shot. Viper document Hi Sir Viper! Will you be able to re-code and compile it to .LUA so that I can use it using FXTS Marketscope Strategy? Credits to hedginghog as this is 1 egy I am looking for for ages.

Thank you!

oxite
11-23-2021, 01:04 PM
Hi Hedgehog, The code you have should work to shut everything unless there's an error - like the price is too near or slippage is too fantastic. I made. If specific positions have errors, it just keeps trying forever. I think they will close. I'm not in my computer with MT4, therefore I was not able to compile it, but I think it is OK. Give it a shot. Viper document MR TRADINGVIPER YOU ARE MY HEROOOOOOOOOOOOOOOOO... thanx alot for ur effort and for sharing this amazing EA, ive been lookin around for quite a while and I have dozens just to do exactly as this 1 will. . All expert advisors didnt shut exactly on the same targeted price, my broker have HUGE take profit requirements now im done with it by this fantastic tool. .

I wanted to ask if u can make a second copy of it targeting the profitable trades ammount by PIPS not the value (bcz u know 1 pip for silver differs than just 1 pip of EUR/USD). . All I need is to specify profits by The amount of pips in profit
i.e: (2 pips) not ($10.0) is it feasible please ?????

8959
11-23-2021, 02:25 PM
1 Attachment(s) pls. Try attached, I extended the onscreen-comment also
2 new outside vars added, should be self-explanatory ...
https://www.forexsoutheast.asia/forex-market-analysis/132-carry-grid.html

oxite
11-23-2021, 03:46 PM
pls. Strive attached, I long the onscreen-comment also 2 new external vars added, ought to be self explanatory ... document thank you so much @fxdaytrader_ I just watched the reply I promise I didnt receive an email that some1 responded to the article thank you so much for ur help

mirancacecammre
11-23-2021, 05:07 PM
If there a way to produce this work?

Instance, if equity lt;= 800 then shut all positions. I tried to change the gt;= to lt;= in the mql document and it didn't work.

If(BuyProfit SellProfit lt;= ProfitTarget) CloseAll();

it just closed any transactions directly away like the first.

Thanks so much!

perepjm
11-23-2021, 06:27 PM
pls. Try attached, I expanded the onscreen-comment also 2 new outside vars added, should be self-explanatory ... document I have been searching for an EA to close a basket of trades at profit in pips. This EA is excellent but it considers ALL the trades on the account to figure the profit. Can anyone alter the code so the EA will close trades only on a single pair.

oklywits
11-23-2021, 07:48 PM
Hi Hedgehog, The code you have should work to close everything unless there's an error - like the price is too near or slippage is too fantastic. I made. If positions have mistakes, it just keeps trying . I think they will close. I am not at my pc with MT4, therefore I was unable to compile it, but I think it is OK. Give it a shot. Viper file Than you,you are fantastic. Cheers

tukylly
11-23-2021, 09:09 PM
pls. Try attached, I prolonged the onscreen-comment also 2 new outside vars added, should be self-explanatory ... document That's exactly what I've been on the lookout for but near goal should be the price, not cash or pips. One price goal. Is it possible?

Skein
11-23-2021, 10:30 PM
quote That is exactly what I have been on the lookout for but close goal should be the price, not cash or pips. One price goal. Is it possible? I really don't know if useful or not
https://www.forexsoutheast.asia/general-forex/102-trouble-launching-advanced-charts.html

https://www.forexsoutheast.asia/general-forex/113-uncommon-51-trades-lost.html

tukylly
11-23-2021, 11:50 PM
quote I do not know if useful or not https://www.forexsoutheast.asia/general-forex/105-building-system-based-price-action.html https://www.forexsoutheast.asia/forex-market-analysis/118-trading-journal-2008-a.html Gumrai thank you for the help but those EAs has targets for the profit or pips. It doesnt work for me personally since I have sl and pl levels on my transactions plus they continuosly change the quantity of profit which makes it impossible to calculate the specific profit target. I only need it to kill everything at a certain price even it strikes the price from above or below.

ivanduarcay
11-24-2021, 01:11 AM
Hello guys, I Want 'Auto close profit target with currency pair target'
Illuion :
RING 1
PAIR 1: AUDUSD
PAIR 2: EURUSD
PAIR 3: EURAUD
TOTAL PROFIT: USD30.00

RING 2
PAIR 1 : EURUSD
PAIR 2 : GBPUSD
PAIR 3 : EURGBP
TOTAL PROFIT : USD30



If you have any Accessible source please give me a Connection.

LLAQUISIMO808
11-24-2021, 02:32 AM
This place in profit have no divide error in line 88

paucacau
11-24-2021, 03:53 AM
Hi theer men I beleve I fount a ea is runing in profit a while is hard the take profit can any one add or change the code to include 3 easy option I want 3 thing take profit on dolar amount and standard tp pip step and lot expoedent if any can helo im wiling to share the mql document and teh wining seting by how I fount th ea im not the founder

Ekiros
11-24-2021, 05:14 AM
Hi Hedgehog, The code you have should work to close everything unless there's an error - such as the price is too near or slippage is too great. I made a fast change that is more aggressive. If specific positions have mistakes, it just keeps trying eternally. I believe they will close. I'm not at my computer with MT4, so I was unable to compile it, but I think that it is OK. Give it a shot. Viper document This ea doesn't work any more, could some 1 fix it?

ramanaixxa
11-24-2021, 06:34 AM
Hello Programming Pro,

I want help to fix my code. I have created attached EA (through EABuilder.com) using price action and want to close order at profit X. However, EABuilder has restricted functionality and can not close all open positions (BuySell) at the same moment. Would you be in a position to help attach mq4 file personally and to repair the code for me personally? I really don't have desktop ability nor knowledge.

Sorry I utilized existing forums as I can not create new article as I'm new member.

Thanks you in advance.

Regards,
Ken
https://www.forexsoutheast.asia/attachments/15184140821274211186.mq4

Raqwl
11-24-2021, 07:55 AM
Hi all, perhaps this is the ideal place....
I am looking for an EA that each 30/50 minutes looks my open transactions and shut only people in profit of 20 pips.
Do you know a similar EA? Thanks

Raqwl
11-24-2021, 09:16 AM
Hi all, maybe this is the ideal place.... I am looking that every 30/50 minutes looks my open transactions and close only those in profit of 20 pips. Do you understand a similar EA? Thank you