Download MetaTrader 5

Watch how to download trading robots for free

Interesting script?
So post a link to it -
let others appraise it

You liked the script? Try it in the MetaTrader 5 terminal

2015.10.02 17:28
Robust EA Template

Robust EA Template - expert for MetaTrader 4

| English Español Português Русский Deutsch 日本語

Views:
14005
Rating:
votes: 21

Real author:

Inovance - https://www.inovancetech.com/

Description:

A robust EA template to help correctly set take profit and stop loss levels, enter and exit positions, and handle terminal issues, such as crashes or disconnects.

To use, input your entry conditions at the bottom of the EA in the "Long and Short Entry Conditions" section. Input your long conditions to return "1" if a long signal is generated in the "LongSignal()" function and your short conditions to return "-1" if a short signal is generated in the "ShortSignal()" function.

A single Buy or Sell order will be placed if your conditions are met and no order will be placed if both long and short conditions are met. It will exit the trade if the take profit or stop loss is hit or if there is a signal in the opposite direction, in which case it will exit the existing trade and open a new one in the appropriate direction.

Image:

External Inputs

EA Inputs

"Long and Short Entry Conditions" section with example strategy shown (note:this is an arbitrary strategy for demonstration purposes only).

//+------------------------------------------------------------------+
//| Long and Short Entry Conditions                                  |
//+------------------------------------------------------------------+
int indCCI0period = 14; // Indicator 1 period
int indRSI1period = 14; // Indicator 2 period
//+------------------------------------------------------------------+
//| Long Entry(Return "1" for long entry, "0" for no entry)          |
//+------------------------------------------------------------------+
int LongSignal()
  {
   double CCI0 = iCCI(NULL,0,indCCI0period,PRICE_CLOSE,1);
   double RSI1 = iRSI(NULL,0,indRSI1period,PRICE_CLOSE,1);
   int match=0;
   if(CCI0>-200 && CCI0<=-150) match++;
   else if(CCI0>-100 && CCI0<=-50) match++;
   if(RSI1>0 && RSI1<=25) match++;
   if(match == 2) return 1;
   return 0;
  }
//+------------------------------------------------------------------+
//| Short Entry(Return "-1" for long entry, "0" for no entry)        |
//+------------------------------------------------------------------+
int ShortSignal()
  {
   double CCI0 = iCCI(NULL,0,indCCI0period,PRICE_CLOSE,1);
   double RSI1 = iRSI(NULL,0,indRSI1period,PRICE_CLOSE,1);
   int match=0;
   if(CCI0 > 50 && CCI0 <= 150) match++;
   if(RSI1 > 80 && RSI1 <= 100) match++;
   if(match == 2) return -1;
   return 0;
  }


Recommendations:

  • Works with 4- and 5- digit brokers.
  • Always test on a demo account.
  • Example strategy shown in template (note:this is an arbitrary strategy for demonstration purposes only).
Accelerator Oscillator (AC) Accelerator Oscillator (AC)

The Acceleration/Deceleration Indicator (AC) measures acceleration and deceleration of the current driving force.

Average Directional Movement Index (ADX) Average Directional Movement Index (ADX)

The Average Directional Movement Index Indicator (ADX) helps to determine if there is a price trend.

LinesProfitLoss LinesProfitLoss

Calculates profit (loss) of the current orders on the symbol.

FFC - Forex Factory Calendar FFC - Forex Factory Calendar

Modified version of FF Calendar Indicator with new features.