EA fix: Close all positions at profit target X
Page 1 of 733 123 LastLast
Results 1 to 10 of 329

Thread: EA fix: Close all positions at profit target X

  1. #1
    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/atta...1740190990.mq4

  2. #2
    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/atta...1937157447.mq4

  3. #3
    Hence that the viper is back?
    But at office !
    Let's kidnap his Boss

  4. #4
    Quote Originally Posted by ;
    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.

  5. #5
    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

    Quote Originally Posted by ;
    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.

  6. #6
    Quote Originally Posted by ;
    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

  7. #7
    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

  8. #8
    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

    Quote Originally Posted by ;
    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...

  9. #9
    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?

  10. #10
    Quote Originally Posted by ;
    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?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
This website uses cookies
We use cookies to store session information to facilitate remembering your login information, to allow you to save website preferences, to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners.