MT5 EA Template

ssopiak

Trader
Mar 2, 2024
3
0
7
51
Thanks for the template, it's really useful.
I'd like to customise it to add trailing stoploss for example.
What do you think would be the best way to do this?
 

Enivid

Administrator
Staff member
Nov 30, 2008
19,259
1,514
144
Odesa
www.earnforex.com
Thanks for the template, it's really useful.
I'd like to customise it to add trailing stoploss for example.
What do you think would be the best way to do this?
To add a trailing stop? You can look at any trailing stop EA we have and use the code from there. For example, Trailing Stop on Profit.
 

ssopiak

Trader
Mar 2, 2024
3
0
7
51
To add a trailing stop? You can look at any trailing stop EA we have and use the code from there. For example, Trailing Stop on Profit.
OK thanks, but my question isn't how to implement a trailling stop but where to implement it.
My idea is to code several buy/sell signals and several types of stop loss and then test several combinations.
For example, is it relevant to add 2 parameters to the "CheckEntrySignal()" function to add an argument with a type of signal (1=moving average crossing, 2=bollinger band, 3=hammer canddle...etc) and a type of stoploss (1=fixed, 2=based on ATRs, 3=trailing stop, ....) ?
 

Enivid

Administrator
Staff member
Nov 30, 2008
19,259
1,514
144
Odesa
www.earnforex.com
OK thanks, but my question isn't how to implement a trailling stop but where to implement it.
My idea is to code several buy/sell signals and several types of stop loss and then test several combinations.
For example, is it relevant to add 2 parameters to the "CheckEntrySignal()" function to add an argument with a type of signal (1=moving average crossing, 2=bollinger band, 3=hammer canddle...etc) and a type of stoploss (1=fixed, 2=based on ATRs, 3=trailing stop, ....) ?
I wouldn't mix entry signals and trailing stop. Trailing stop is best added as a separate function like this:
MQL5:
if (CountPositions())
    {
        // There is a position open. Manage SL, TP, or close if necessary.
        if (UsePartialClose) PartialCloseAll();
        CheckExitSignal();
        TrailingStop();
    }
Then you implement the actual trailing stop strategy (or strategies) inside the TrailingStop() function.
 
  • 👍
Reactions: ssopiak

ssopiak

Trader
Mar 2, 2024
3
0
7
51
I wouldn't mix entry signals and trailing stop. Trailing stop is best added as a separate function like this:
MQL5:
if (CountPositions())
    {
        // There is a position open. Manage SL, TP, or close if necessary.
        if (UsePartialClose) PartialCloseAll();
        CheckExitSignal();
        TrailingStop();
    }
Then you implement the actual trailing stop strategy (or strategies) inside the TrailingStop() function.
Ok thanks !
 

linux_usr

Trader
Oct 20, 2023
55
1
19
38
Hey Admin, i see there is a copyright on the mt5 template.
if i was to create a unique EA with the template. where do i stand selling that EA commercially .
Would his be allowed.
Post automatically merged:

I'm taking about a compiled binary (EA) . Not the src
 

linux_usr

Trader
Oct 20, 2023
55
1
19
38
Hey Envid, "commentry " is important feature to have in a bot especially running multiple combinations. some may have same magic number but different settings. Then commentry is good to keep trades group via tab. The mt5 template does not place commentry if added via the config file. can you take a look. thahanx