Total Equity trailing stop EA for MT4
Page 1 of 502 12 LastLast
Results 1 to 10 of 15

Thread: Total Equity trailing stop EA for MT4

  1. #1
    Hi,
    Does anybody know of an EA for MT4 which tracks the account equity and closes all transactions in the event the equity falls a specified percent from the account large? But also when the stop is hit all trades will shut disable all EAs in order no additional transactions can be entered until EA trading is re-enabled.
    I have had a hunt around on the forum however I didn't find anything.
    Thanks.

  2. #2
    Quote Originally Posted by ;
    subsequently disable all EAs so that no additional trades can be entered
    AFAIK there isn't any way to influence (disable) additional EAs from within an EA. It is possible to close any trades but not tell EAs to prevent opening new ones. (AFAIK means I could be wrong)

    An answer is to specify a global variable on your own stoploss-EA and have of your additional EAs modified to look at this variable before any trade.

    Another more rigorous solution is to produce the stoploss EA completely shut down the metatrader program via Windows-API once it has successfully closed all open trades and deleted all of pending orders.

  3. #3
    Hi 7bit,
    Thank you very much for your comprehensive answer. I feared there would not be an easy solution.
    Matthew

  4. #4
    Quote Originally Posted by ;
    Yet another more rigorous solution would be to produce the stoploss EA fully closed down the metatrader appliion via Windows-API once it has successfully closed all open transactions and successfully deleted all of pending orders.
    Hello 7bit. .
    Though I haven't searched around... if that is not so detailed
    Could you describe it with some code, that may be added to these stoploss Ea's?
    This facet is VERY important for people that can not visually manage their EA's all moment.
    Thanks ahead
    Regards

  5. #5
    Hey mathew.... The equity monitoring stoploss is an easy code.... Only marginally harder than a monitoring stop....

    It sounds like the usage of global variables, as 7bit said, is what would best fit your requirements.... It would only involve a few lines of code....


    //-----
    all that aside,

    yes, one ea can control other ea's... the sway might be something as simple as prohibiting futher trades in the trade producing ea's ....

    Or it might change any or all functioning parameters of the other ea's.... Such as lot dimensions, profittargets, stoploss , pairs to exchange , and on and on....

    The only ea doesn't need to be on the same computer as the trade producing ea's.... This is helpful if you depart ea's running on computers in other places.... Like if your work, you can command the ea's at home or another loion.... or vice versa....

    This form of ea will not be found on the internet...h

  6. #6
    de
    Guest
    Quote Originally Posted by ;
    AFAIK there is no way to influence (disable) additional EAs from within an EA. You can close any transactions but not tell EAs to stop opening new ones. (AFAIK means I might be wrong)
    How about globals? I guess I've globals on the mind. But, I guess if each EA was altered by you, it is possible.

    Quote Originally Posted by ;
    A solution would be to set a global variable by your stoploss-EA and possess your other EAs altered to look at this variable before any transaction.
    Oh well, nevermind, we seem to be saying the exact same thing. But this is what I would do.

  7. #7
    Hi,
    Thank you all. I have to acknowledge my knowledge is practically nill. With the number of EAs available I had been hoping somebody was going to say that it was an easy thing to do and they knew about one. It was something I was just considering as a final failsafe EA that 99.9 percent percent of the time could sit quietly in the background (as the trading EAs use stops), but would be there in case of the proverbial 'black swan'.
    Matthew

  8. #8
    Untested:

    Inserted Code #define SW_SHOWNORMAL 1 #import shell32.dll int ShellExecuteA(int hWnd, string Verb, string File, string Parameter, string Path, int ShowCommand); #import /** * start an external appliion but DON'T wait for it to complete */ void shell(string file, string parameters=-RRB- ShellExecuteA(0, open, file, parameters, NULL, SW_SHOWNORMAL); /** * shut metatrader immediately */ void shutdown() shell(taskkill, /im terminal.exe);

  9. #9
    Thank you 7bit,
    I'll have a play around with your code and see how I move.
    Matthew

  10. #10
    Quote Originally Posted by ;
    Thanks ,
    I will have a play around with your code and see how I go.
    Matthew
    I'd use the above code just as a last resort if you're dealing with commercial closed source EAs that cannot be turned off. It has some flaws, for example you cannot be 100% convinced that at the time between the closing of all open orders and the shutdown of the EAs finds time to start an new commerce.

    The very tasteful and foolproof solution is to disable a EA by immediately departing it's beginning() function in the top of the function if a certain global variable is defined.

    All EAs must be altered to contain this at the very start of the beginning function:
    Inserted Code int begin() if (GlobalVariableGet(trading_disbled) ! = 0) return(0); // here follows the rest of the original start function that your stoploss EA would then first have to perform the following:
    Inserted Code GlobalVariableSet(trading_disabled, 1); . . .and then close all open transactions and orders.

    After that none of the altered EAs are going to have the ability to do *whatever * anymore since their beginning functions would always immediately return before doing anything else, until the variable is deleted or set to 0 again. You are able to access and change global variables from the metatrader menu also, so after it has been triggered, you can reset it.

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 more information