MT5 EA Template

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?
 
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.
 
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, ....) ?
 
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
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 !
 
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
 
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
 
i fixed the commentry that did not work on the mt5 template.
add this too the template

Code:
//add
input string OrderCommentary = "Strategy";

Then find this line
if (!Trade.Buy(Size, Symbol(), OpenPrice, StopLossPrice, TakeProfitPrice))

change too

if (!Trade.Buy(Size, Symbol(), OpenPrice, StopLossPrice, TakeProfitPrice, OrderCommentary))
 
Last edited:
  • 👍
Reactions: Enivid
In your template... What if I don't need the atr at all!! like ever what do I do? Do I just delete it
 
For an EA to work properly, it needs to be customized according to your unique trading characteristics.