This is a basic EMA for Buy & SL.
But I want to add TSL with the EA, can some experts help me solve this.
This is the code as I want to add a auto trailing stop loss into this below code.
***
This a a code I found on MQL5.com for trailing stop loss
***
Can someone help me to merge this both codes into a single file...
Thanks & Regards,
Novelty_Scalper
1. Remember that the indicator handle MUST be created ALL ONCE - AND THIS SHOULD BE DONE IN OnInit!!!
2. Please insert the code correctly: when editing a message, press the button and paste your code into the pop-up window
Forum on trading, automated trading systems and testing trading strategies
Help needed to solve this code on MQL5
Vladimir Karputov, 2022.02.11 07:48
1. Remember that the indicator handle MUST be created ALL ONCE - AND THIS SHOULD BE DONE IN OnInit!!!
An example of how to create indicators:
//+------------------------------------------------------------------+ //| Test.mq5 | //| Copyright © 2022, Vladimir Karputov | //| https://www.mql5.com/en/users/barabashkakvn | //+------------------------------------------------------------------+ #property copyright "Copyright © 2022, Vladimir Karputov" #property link "https://www.mql5.com/en/users/barabashkakvn" #property version "1.00" //--- input parameters //--- MA's parameters input string Inp_MA_Symbol = "USDJPY"; // MA: symbol input ENUM_TIMEFRAMES Inp_MA_period = PERIOD_M30; // MA: timeframe input int Inp_MA_Fast_ma_period = 7; // MA Fast: averaging period input int Inp_MA_Slow_ma_period = 36; // MA Slow: averaging period input int Inp_MA_Fast_ma_shift = 0; // MA Fast: horizontal shift input int Inp_MA_Slow_ma_shift = 2; // MA Slow: horizontal shift input ENUM_MA_METHOD Inp_MA_Fast_ma_method = MODE_SMA; // MA Fast: smoothing type input ENUM_MA_METHOD Inp_MA_Slow_ma_method = MODE_SMA; // MA Slow: smoothing type input ENUM_APPLIED_PRICE Inp_MA_Fast_applied_price = PRICE_CLOSE; // MA Fast: type of price input ENUM_APPLIED_PRICE Inp_MA_Slow_applied_price = PRICE_CLOSE; // MA Slow: type of price //--- int handle_iMA_Fast; // variable for storing the handle of the iCustom indicator int handle_iMA_Slow; // variable for storing the handle of the iCustom indicator //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- create handle of the indicator iMA handle_iMA_Fast=iMA(Symbol(),Period(),Inp_MA_Fast_ma_period,Inp_MA_Fast_ma_shift, Inp_MA_Fast_ma_method,Inp_MA_Fast_applied_price); //--- if the handle is not created if(handle_iMA_Fast==INVALID_HANDLE) { //--- tell about the failure and output the error code PrintFormat("Failed to create handle of the iMA indicator 'Fast' for the symbol %s/%s, error code %d", Symbol(), EnumToString(Period()), GetLastError()); //--- the indicator is stopped early return(INIT_FAILED); } //--- create handle of the indicator iMA handle_iMA_Slow=iMA(Symbol(),Period(),Inp_MA_Slow_ma_period,Inp_MA_Slow_ma_shift, Inp_MA_Slow_ma_method,Inp_MA_Slow_applied_price); //--- if the handle is not created if(handle_iMA_Slow==INVALID_HANDLE) { //--- tell about the failure and output the error code PrintFormat("Failed to create handle of the iMA indicator 'Slow' for the symbol %s/%s, error code %d", Symbol(), EnumToString(Period()), GetLastError()); //--- the indicator is stopped early return(INIT_FAILED); } //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { //--- } //+------------------------------------------------------------------+
Sir i dont have experience in coding....
You have these scenarios:
1. Start learning to program.
2. If you do not want to study:
2.1. You should start searching for the right code in CodeBase or Market
2.2. If you do not want to search - you can contact the Freelance service.

- 2022.02.11
- www.mql5.com
If you need code for the intersection of two iMAs, I searched the CodeBase:

- www.mql5.com

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
This is a basic EMA for Buy & SL.
But I want to add TSL with the EA, can some experts help me solve this.
This is the code as I want to add a auto trailing stop loss into this below code.
***
This a a code I found on MQL5.com for trailing stop loss
***
Can someone help me to merge this both codes into a single file...
Thanks & Regards,
Novelty_Scalper