EMA cross EA advice mql5

To add comments, please log in or register
Kyle Paarman
305
Kyle Paarman  

Hello world,


I'm somewhat new to mql5 and forex automation in general.

Recently I have been brushing up on c++ for the purpose of developing my own EA.

I would greatly appreciate it if someone could provide me with a link to the source code of a working EMA cross strategy.

My goal is to enter trades based on the crossing of the two EMA's, but I do not want to close a trade based on the same condition. Rather, have the trade closed if the candle has closed passed the slower EMA.

Any template related to this method would be of great use to my learning. Previously I used FXDreema to try create a template like this, but found that it was incredibly hard to work with. It's almost like those EA builders are not usable unless you accept the exported file as is.


Not looking for a freelancer, just some friendly advice from any experienced developers :)


Thank you!

William Roeder
23253
William Roeder  
Kyle Paarman: a link to the source code 
Top of every page is the link Code Base.
MQL5 Code Base
MQL5 Code Base
  • www.mql5.com
Range BreakOut EA. The range is defined by the min number of bars and max width in pips. This expert advisor is designed with visual strategy builder - Mission Automate. Code is generated automatically. More info: https://www.mql5.com/en/articles/4951 Grid system with limit orders. This expert advisor is designed with visual strategy builder...
Vladimir Karputov
Moderator
215852
Vladimir Karputov  
Kyle Paarman :


My advice: you need to write your own MQL5 code. This is the only way you can understand.

Are you ready to start?

Kyle Paarman
305
Kyle Paarman  
Vladimir Karputov:

My advice: you need to write your own MQL5 code. This is the only way you can understand.

Are you ready to start?

Yes I am ready to learn! I am currently working with your source code for: https://www.mql5.com/en/code/16849

My goal is to create my own version of this with a different method for stop loss. Also, to make it open trades based on a percentage rather than a fixed lot size.

EMA CROSS
EMA CROSS
  • www.mql5.com
Waddah_Attar_Trend_Alert Waddah_Attar_Trend indicator features alerts, emails and push notifications. Exp_ReOpenPositions The Expert Advisor increases the volume of an open position if profit in points from the last trade increases a threshold fixed in the EA inputs. Fibo...
Vladimir Karputov
Moderator
215852
Vladimir Karputov  
Kyle Paarman :

Yes I am ready to learn! I am currently working with your source code for: https://www.mql5.com/en/code/16849

My goal is to create my own version of this with a different method for stop loss . Also, to make it open trades based on a percentage rather than a fixed lot size.

This is an outdated code, now I switched to my more advanced engine "barabashkakvn Trading engine" (latest version 3.109). Literally the last code: iMA and Medium OHLC .

Description:

Trading strategy idea

The EA works (looking for signals to enter and / or exit) on the H1 timeframe and only at the time of the birth of a new bar.

At a given Start Hour hour, the direction of the trend is determined using the iMA (Moving Average, MA) indicator with a long MA Trend averaging period (it is recommended to take a period of at least 150 bars).

The trend is confirmed by two iMA indicators (Moving Average, MA) with periods much shorter than the trend ones - MA Fast and MA Slow . and the average bar price (high + low) / 2.

Determining the direction of the trend:

a record of the form MA Trend # 1 means: the value of the MA indicator (Moving Average, MA) on bar 1, the MA Trend indicator responsible for determining the trend is used

Trend Up: MA Trend # 1> MA Trend # 2, Trend Down: MA Trend # 1 < MA Trend # 2.

Trend confirmation:

a record of the form PRICE_MEDIAN # 1 means the average price of a bar, calculated by the prices of this bar: (high + low) / 2

Trend Up: PRICE_MEDIAN # 1 < MA Fast # 1 AND MA Fast # 1> MA Slow # 1, Trend Down PRICE_MEDIAN # 1 < MA Fast # 1 AND MA Fast # 1 < MA Slow # 1.

iMA and Medium OHLC


More details about the advisor settings:

Please note: the trading signal has the highest priority! You can restrict its execution only using the Only one positions parameter. If Only one positions is “ true ” and the number of positions opened by this EA on this symbol is greater than “1”, then the trading signal is ignored.

The Close opposite parameter is " true ": first, CLOSE the opposite position, then process the trading signal.


Trading settings

In the adviser, you can turn on and off Stop Loss , Take Profit and Trailing Stop . To disable the selected parameter set to "0.0".

Trailing can be triggered either after N-seconds or only at the moment of birth of a new bar. Trailing interval in seconds is set in Trailing, in seconds . General rule: if the interval is set less than "10" - this means ONLY at the time of the birth of a new bar, if the interval is set exactly or more than "10" - this means work every "N" seconds.


Additional features

    • Only one positions - there is always only one position in the market
    • Close opposite - closing positions opposite to the trading signal, and first there is a guaranteed closing of the opposite position and only then opening a new position in the signal direction

    Please note: the trading signal has the highest priority! You can restrict its execution only using the Only one positions parameter. If Only one positions is “ true ” and the number of positions opened by this EA on this symbol is greater than “1”, then the trading signal is ignored.

    The Close opposite parameter is “ true ”: first, CLOSE the opposite position, then process the trading signal.


    Position size management (lot calculation)

    The lot can be either permanent ( Money management set in the Constant lot and set the lot size in The value for "Money management" ) or dynamic - in percentage of risk per trade ( Money management set in Risk in percent for a deal and set the percentage of risk in The value for "Money management" ). You can also set a permanent lot equal to the minimum lot - Set Money management to Lots Min .

    iMA and Medium OHLC
    iMA and Medium OHLC
    • www.mql5.com
    Советник работает (ищет сигналы на вход и/или выход) на таймфрейме H1 и только в момент рождения нового бара. В заданный час Start Hour по индикатору iMA (Moving Average, MA) с большим периодом усреднения  MA Trend (рекомендуется брать период не менее 150 баров) определяется направление тренда. Подтверждение тренда происходит по двум...
    Vladimir Karputov
    Moderator
    215852
    Vladimir Karputov  
    I can change the adviser and it will work just like the intersection of two iMAs. Necessary?
    Kyle Paarman
    305
    Kyle Paarman  
    Vladimir Karputov:
    I can change the adviser and it will work just like the intersection of two iMAs. Necessary?

    Busy doing a lot of learning so I can do it.

    Yes, I am just looking to simply open a buy or sell on the crossing of the two iMA's. With account risk instead of fixed lot.

    I want to create a stop loss if a candle closes above/below the slow iMA. Trailing stop would be ok too.

    Nelson Wanyama
    1241
    Nelson Wanyama  
    Vladimir Karputov:
    I can change the adviser and it will work just like the intersection of two iMAs. Necessary?
    Thank you for helping this guy out.  You are always very helpful.  Thanks
    Vladimir Karputov
    Moderator
    215852
    Vladimir Karputov  
    Kyle Paarman :

    Busy doing a lot of learning so I can do it.

    Yes, I am just looking to simply open a buy or sell on the crossing of the two iMA's. With account risk instead of fixed lot.

    I want to create a stop loss if a candle closes above/below the slow iMA. Trailing stop would be ok too.

    Especially for you: Сrossing of the two iMAs

    Сrossing of the two iMAs
    Сrossing of the two iMAs
    • www.mql5.com
    Советник ищет торговые сигналы и осуществляет трейлинг ТОЛЬКО в момент рождения нового бара. Пересечение двух индикаторов iMA (Moving Average, MA): MA Fast и MA Slow. Пересечение проверятся путём сравнения значений индикаторов на барах #2 и #1. Сигнал BUY:  MA FastMA SlowMA FastMA Slow MA FastMA SlowMA FastMA Slow Подробнее о настройках...
    Kyle Paarman
    305
    Kyle Paarman  
    Vladimir Karputov:

    Especially for you: Сrossing of the two iMAs

    Thank you so much for your help! I did not expect anyone to provide me with source code like this.


    I now realize the major problem with this method and I will have to make significant changes. You have saved me a lot of time as I can now work on a solution as this is a failing strategy.

    I will now attempt to create an EA that opens and closes orders upon contact with a slow exponential moving average. On the charts this seems to have a much higher chance of securing profits.


    Thank you very much for the code!

    Jocelyn
    202
    Jocelyn  
    Vladimir Karputov:

    Especially for you: Сrossing of the two iMAs

    Hello Vladimir,

    Can you provide the same sample code for determining a crossing section between a floating value and a percent value?
    Difficult to find something like that

    Thanks

    12
    To add comments, please log in or register