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

The simplest EA using the DeMarker indicator - MetaTrader 4 Expert - MT4/MT5 Resources

author EAcpu | 5 reads | 0 comments |

Simplest EA using DeMarker indicator - expert for MetaTrader 4

Simplest EA using DeMarker indicator - expert for MetaTrader 4

Simplest EA using DeMarker indicator - expert for MetaTrader 4

In the past I thought about using EA for trading and this is part of my simple EA and the simplest EA I have ever used so please rate it after reading...

The EA works on single pairs. With fully functional setting of timeframes, lot size, stop loss and take profit can all be entered in the menu properties.

Simplest EA using DeMarker indicator - expert for MetaTrader 4

 External ENUM_TIMEFRAMES TF = PERIOD_CURRENT ; // Select time range
outer integer period = 8 ; // period to mark
outer double lt = 0.01 ; // many
External integer sl = 100 ; // Stop loss
External integer tp = 100 ; // Take profit
External double OB = 0.7 ; // oversold
external double os = 0.3 ; // overbought
external boolean OPENBAR = false ; // trade at new bar open price

Here's the secret, I split it into 3 parts variables:
1. Data | Approximate time
2. Order
3. Pairing

 //+------------------------------------------------------------------+

//-- time range | indicator
double dmrk[ 5 ]; integer signal =- 1 ; //-- 0.Buy 1.Sell
integer hold = 0 ; // - command
integer tickets = 0 ; double lot = 0.0 ; integer type = - 1 ; // - a pair
datetimet1 = 0 ; boolean new column= wrong ; boolean entry= wrong ; //+------------------------------------------------------------------+

In the OnInit() function I have to initialize the indicator DeMarker array variable and check the minimum trading lot size required by a specific type of broker.

 //+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
Blank initialization ()
  {
ArrayInitialization (dmrk, 0.0 );
//--- const double test batch = symbolinfo double ( symbol (), SYMBOL_VOLUME_MIN );
if (lt 

On the OnTick() function, this is used to calculate the indicator and determine buy and sell signals

//--------------------------------------------------------------------------------------------- Signal = - 1 ; //------------------------------------------------------------------------------------------------

//---compute for ( integer i = 0 ; i < array size (dmrk); i++)
    {
      dmrk[i] = Edmark ( symbol (),TF,period,i);
    } //--- if (dmrk[ 1 ] > obstetrics)
    {
      keep = 1 ; //put }
Else if (dmrk[ 1 ] < operating system)
        {
        keep= -1 ; //put }
other {
        keep = 0 ; //reset }

if (hold == 1 )
    {
if (dmrk[ 0 ]  1 ]>Obstetrics)
        {
        signal = OP_SELL;
        }
    }
if (hold ==- 1 )
    {
if (dmrk[ 0 ]>operating system&& dmrk[ 1 ]<operating system)
        {
        signal = OP_BUY;
        }
    }

To open buy and sell signals...

 //---------------------------------------------------------------------------------------- if (signal! = - 1 )
if (new column == true )
if (entry == false ) //door open {
//--- entry = true ; // put //--- if (signal == OP_BUY)
              {
              ticket = orderSend ( symbol (),OP_BUY,lt,ask,( integer )((ask-bid)/ view ),
                                  SL> 0 ?bid-sl* view : 0.0 ,
                                  TP> 0 ?Bid+TP* View : 0.0 ,
                                  EA name + ": signal=" + integer to string (signal) + ": hold=" + integer to string (hold),
                                  EA number,
0 ,
clear blue );
              signal= -1 ;
//Keep = 0; } //Reset other if (signal == OP_SELL)
                {
                  ticket = orderSend ( symbol (),OP_SELL,lt,bid,( integer )((ask-bid)/ view ),
                                    SL> 0 ? Ask+sl* View : 0.0 ,
                                    TP> 0 ?Q-tp* View : 0.0 ,
                                    EA name + ": signal=" + integer to string (signal) + ": hold=" + integer to string (hold),
                                    EA number,
0 ,
red blood cells );
                  signal= -1 ;
//Keep=0; } //Reset signal }


And for the closing ceremony...

 if (input == true ) // close {

if ( orderselect (ticket, SELECT_BY_TICKET))
        {
if (order closing time() == 0 ) //-- order active trading {
/* To-do item closing condition*/ //Input = false; }
//Other if (order closing time() != 0 ) //-- close to 1. manual 2. sl/tp 3. ea {
              entry = wrong ; //reset entry }
        }
    } 

Simplest EA using DeMarker indicator - expert for MetaTrader 4

Simplest EA using DeMarker indicator - expert for MetaTrader 4


Attachment download

📎ea_simplest.mq4 (4.95 KB)

Source: MQL5 #32418

Verification code Refresh