Welcome Forex EA downloads & MT4/MT5 auto-trading resources — EAs, Gold EAs, quant tools and real-world automation.
Sign In Sign Up

Stop Loss and Take Profit Scripts - MetaTrader 4 Scripts | Trading Script Downloads - MT4/MT5 Resources

author EAcpu | 5 reads | 0 comments |

Stop Loss and Take Profit Scripts - script for MetaTrader 4

Stop Loss and Take Profit Scripts - script for MetaTrader 4

Stop Loss and Take Profit Scripts - script for MetaTrader 4

Stop Loss and Take Profit Scripts - script for MetaTrader 4

Stop Loss and Take Profit Scripts - script for MetaTrader 4

Stop Loss and Take Profit Scripts - script for MetaTrader 4

Collection of predefined scripts

A collection of predefined scripts saves time by making the required settings available immediately without having to type it.

Make your own script from the downloaded script - this may seem lengthy, but once completed it's actually a quick 1, 2, 3. You'll find it's surprisingly quick and easy.

Why keep resetting Scrip, indicator or EA default parameters, for example from 34 to 50? Change the default setting to 50 permanently or copy using the default 50!

Please follow the steps below

Stop Loss and Take Profit Scripts - script for MetaTrader 4

The only codes that need to be edited are the two 500 numbers.

 // Script: 0-A SL 500 outer integer stop loss = 500 ;

Related information

The code behind the input tabs of scripts, indicators and Expert Advisors can always be located by looking for the code word "extern" (without quotes), which is always located near the top of the program.

The code word "int" represents an integer (..-2, -1, 0, 1, 2, ..). Basically a negative number or a positive number excluding decimal places. 'Int' defines "stop loss" as an integer value.

The code to change (as far as basic editing is concerned) will be the code after the = sign. Eg1: outer color line color = red; - change red to blue or green etc. For example 2: extern int line width=1; - Change 1 to 2, 3, 4 or 5. For example: extern string Font_Type = "Arial"; - changes Arial to "Arial Bold" or "Verdana". Please note that the parameters of string variables require quotes ("bla") (extern string ... = "bla";).

Text after // is used as a descriptive comment and is excluded from code functions. Sometimes code is commented out (// ..bla bla.. or /*..bla bla...*/ ) for reasons such as finding faults through an elimination process.

 // Script: 0-A SL 800
  •  outer integer stop loss = 800 ;
  • Click the Compile button. Always remember to compile. The edited code will only take effect after compilation.
  • Check the lower left corner of MetaEditor to see if there are 0 errors and 0 warnings in the toolbox (Ctrl+T).
  • Figure 3
  • Stop Loss and Take Profit Scripts - script for MetaTrader 4
  • If an error is flagged, the code will not compile and the code must compile for the program to run .
  • If an error is marked, follow the steps by pressing Ctrl+Z and following the code in MetaEditors as it is undone and returned to the original copy. Try to identify the mistakes for future reference and learning.
  • Click the "Compile" button to test that the code is error-free and start over.
  • If no errors are marked after editing 500 to 800 the new 0-A-SL-0800 script in the toolbox will be in the Scripts folder ready for use..
    1. test

      Apply the same process to other scripts.

      double: def - real number - including decimal part.

      int: def - (integer) Integer - no decimal part.

      Previous: 0-2 Buy Limit.mq4

      // Default input: Starting external double buy lot size = 0.01; // One small external double buy limit = 0.0;
      external integer slippage=3;
      External integer stop loss = 0;
      External integer take profit = 0; //Default input: end

      After: 0-2 buy limit 0200-0600.mq4

       //Default input: starting external double buying lot size = 0.10; // one small lot
      External double buy limit = 0.0;
      outer integer slippage = 4; // My name is Jack and I coded slippagw at 4. I added comments after 200 at StopLoss and 600 at TakeProfit
      External integer stop loss = 200; // 200 pips (20 pips)
      External integer take profit = 600; // 600 pips (60 pips) // Default input: end

      After: 0-2 buy limit 0300-2000.mq4

       //Default input: Start external double buy lot size = 10.00 ; // ten hands
      External Double Buy Limit = 0.0;
      external integer slippage = 5; // My name is Jill and I have encoded slippage as 5. I will not add comments after StopLoss and TakeProfit
      External integer stop loss = 300;
      External integer take profit = 2000; //Default input: end

      Attachment download

      📎Code_11087.zip

      Source: MQL5 #11087

      Verification code Refresh