10pips-a-day

Author: Expert Advisor Builder
Profit factor:
1.07

This script is designed to automatically trade on the Forex market using the MetaTrader platform. Here's how it works, explained without technical jargon:

Overall Strategy:

The script's core function is to make buy and sell decisions based on two technical indicators: Moving Averages (MAs) and the Relative Strength Index (RSI). It also incorporates stop-loss, take-profit, and trailing stop features to manage risk.

Here's a breakdown of the script's logic:

  1. Initialization: When the script starts, it sets up some initial values, like remembering how many "bars" (time periods) are on the chart. It also determines whether it should analyze every single price tick or only at the close of each bar.

  2. Checking for Existing Trades: The script first looks to see if it already has any open trades on the specific currency pair it's designed to trade. If it does, it checks if it should close them.

  3. Closing Trades (Exiting Positions):

    • For Buy orders, it exits (closes the trade) if a specific combination of the Moving Averages (MAs) and the RSI indicators suggests the price will go down. If these conditions are met, it closes the Buy trade and can send an email alert.
    • For Sell orders, it exits (closes the trade) if a different combination of the Moving Averages (MAs) and the RSI indicators suggests the price will go up. If these conditions are met, it closes the Sell trade and can send an email alert.
  4. Trailing Stop (Managing Profit): The script can also use a "trailing stop." This feature automatically adjusts the stop-loss order as the trade becomes more profitable, locking in gains. For Buy positions, if the price moves favorably, the stop loss price will increase, and vice versa for Sell Positions.

  5. Opening Trades (Entering Positions):

    • Buy Signal: The script looks for a specific pattern in the Moving Averages (MAs) and the RSI indicators that suggests the price is likely to rise. If it finds this pattern, it issues a "buy" signal.

    • Sell Signal: Similarly, the script looks for a pattern in the Moving Averages (MAs) and the RSI indicators that suggests the price is likely to fall. If it finds this pattern, it issues a "sell" signal.

  6. Executing Trades:

    • If the script identifies a "buy" signal and there isn't already an open trade, it checks if there is enough money in the account to open the trade. If so, it places a buy order. It also sets a stop-loss (to limit potential losses) and a take-profit (to automatically close the trade when a certain profit is reached) based on pre-defined parameters. It can then send an email alert when it opens a trade.

    • The same process is followed for "sell" signals.

  7. Repetition: The script repeats this process continuously, either on every price tick or at the close of each bar, depending on how it's configured.

In summary:

The script is a trading robot that automates buy and sell decisions based on a predefined strategy using Moving Averages (MAs) and the Relative Strength Index (RSI) indicators. It manages risk through stop-loss orders, take-profit orders, and a trailing stop feature. It also has the ability to send email alerts when it opens or closes trades.

Orders Execution
Checks for the total of open ordersIt Closes Orders by itself It can change open orders parameters, due to possible stepping strategyIt automatically opens orders when conditions are reached
Indicators Used
Moving average indicatorRelative strength index
Miscellaneous
It sends emails
4 Views
0 Downloads
0 Favorites
10pips-a-day
//+------------------------------------------------------------------+
//| This MQL is generated by Expert Advisor Builder                  |
//|                http://sufx.core.t3-ism.net/ExpertAdvisorBuilder/ |
//|                                                                  |
//|  In no event will author be liable for any damages whatsoever.   |
//|                      Use at your own risk.                       |
//|                                                                  |
//+------------------- DO NOT REMOVE THIS HEADER --------------------+

#define SIGNAL_NONE 0
#define SIGNAL_BUY   1
#define SIGNAL_SELL  2
#define SIGNAL_CLOSEBUY 3
#define SIGNAL_CLOSESELL 4

#property copyright "Expert Advisor Builder"
#property link      "http://sufx.core.t3-ism.net/ExpertAdvisorBuilder/"

extern int MagicNumber = 0;
extern bool SignalMail = False;
extern bool EachTickMode = False;
extern double Lots = 0.2;
extern int Slippage = 10;
extern bool UseStopLoss = True;
extern int StopLoss = 50000;
extern bool UseTakeProfit = True;
extern int TakeProfit = 50000;
extern bool UseTrailingStop = False;
extern int TrailingStop = 30;

int BarCount;
int Current;
bool TickCheck = False;
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init() {
   BarCount = Bars;

   if (EachTickMode) Current = 0; else Current = 1;

   return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit() {
   return(0);
}
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start() {
   int Order = SIGNAL_NONE;
   int Total, Ticket;
   double StopLossLevel, TakeProfitLevel;



   if (EachTickMode && Bars != BarCount) TickCheck = False;
   Total = OrdersTotal();
   Order = SIGNAL_NONE;

   //+------------------------------------------------------------------+
   //| Variable Begin                                                   |
   //+------------------------------------------------------------------+


double Buy1_1 = iMA(NULL, 0, 5, 0, MODE_EMA, PRICE_CLOSE, Current + 0);
double Buy1_2 = iMA(NULL, 0, 12, 0, MODE_EMA, PRICE_CLOSE, Current + 0);
double Buy2_1 = iRSI(NULL, 0, 21, PRICE_CLOSE, Current + 0);
double Buy2_2 = 50;

double Sell1_1 = iMA(NULL, 0, 5, 0, MODE_EMA, PRICE_CLOSE, Current + 0);
double Sell1_2 = iMA(NULL, 0, 12, 0, MODE_EMA, PRICE_CLOSE, Current + 0);
double Sell2_1 = iRSI(NULL, 0, 21, PRICE_CLOSE, Current + 0);
double Sell2_2 = 50;

double CloseBuy1_1 = iMA(NULL, 0, 5, 0, MODE_EMA, PRICE_CLOSE, Current + 0);
double CloseBuy1_2 = iMA(NULL, 0, 12, 0, MODE_EMA, PRICE_CLOSE, Current + 0);
double CloseBuy2_1 = iRSI(NULL, 0, 21, PRICE_CLOSE, Current + 0);
double CloseBuy2_2 = 50;

double CloseSell1_1 = iMA(NULL, 0, 5, 0, MODE_EMA, PRICE_CLOSE, Current + 0);
double CloseSell1_2 = iMA(NULL, 0, 12, 0, MODE_EMA, PRICE_CLOSE, Current + 0);
double CloseSell2_1 = iRSI(NULL, 0, 21, PRICE_CLOSE, Current + 0);
double CloseSell2_2 = 50;

   
   //+------------------------------------------------------------------+
   //| Variable End                                                     |
   //+------------------------------------------------------------------+

   //Check position
   bool IsTrade = False;

   for (int i = 0; i < Total; i ++) {
      OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
      if(OrderType() <= OP_SELL &&  OrderSymbol() == Symbol()) {
         IsTrade = True;
         if(OrderType() == OP_BUY) {
            //Close

            //+------------------------------------------------------------------+
            //| Signal Begin(Exit Buy)                                           |
            //+------------------------------------------------------------------+

                     if (CloseBuy1_1 < CloseBuy1_2 && CloseBuy2_1 < CloseBuy2_2) Order = SIGNAL_CLOSEBUY;


            //+------------------------------------------------------------------+
            //| Signal End(Exit Buy)                                             |
            //+------------------------------------------------------------------+

            if (Order == SIGNAL_CLOSEBUY && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
               OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, MediumSeaGreen);
               if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + " Close Buy");
               if (!EachTickMode) BarCount = Bars;
               IsTrade = False;
               continue;
            }
            //Trailing stop
            if(UseTrailingStop && TrailingStop > 0) {                 
               if(Bid - OrderOpenPrice() > Point * TrailingStop) {
                  if(OrderStopLoss() < Bid - Point * TrailingStop) {
                     OrderModify(OrderTicket(), OrderOpenPrice(), Bid - Point * TrailingStop, OrderTakeProfit(), 0, MediumSeaGreen);
                     if (!EachTickMode) BarCount = Bars;
                     continue;
                  }
               }
            }
         } else {
            //Close

            //+------------------------------------------------------------------+
            //| Signal Begin(Exit Sell)                                          |
            //+------------------------------------------------------------------+

                     if (CloseSell1_1 > CloseSell1_2 && CloseSell2_1 > CloseSell2_2) Order = SIGNAL_CLOSESELL;


            //+------------------------------------------------------------------+
            //| Signal End(Exit Sell)                                            |
            //+------------------------------------------------------------------+

            if (Order == SIGNAL_CLOSESELL && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
               OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, DarkOrange);
               if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + " Close Sell");
               if (!EachTickMode) BarCount = Bars;
               IsTrade = False;
               continue;
            }
            //Trailing stop
            if(UseTrailingStop && TrailingStop > 0) {                 
               if((OrderOpenPrice() - Ask) > (Point * TrailingStop)) {
                  if((OrderStopLoss() > (Ask + Point * TrailingStop)) || (OrderStopLoss() == 0)) {
                     OrderModify(OrderTicket(), OrderOpenPrice(), Ask + Point * TrailingStop, OrderTakeProfit(), 0, DarkOrange);
                     if (!EachTickMode) BarCount = Bars;
                     continue;
                  }
               }
            }
         }
      }
   }

   //+------------------------------------------------------------------+
   //| Signal Begin(Entry)                                              |
   //+------------------------------------------------------------------+

   if (Buy1_1 > Buy1_2 && Buy2_1 > Buy2_2) Order = SIGNAL_BUY;

   if (Sell1_1 < Sell1_2 && Sell2_1 < Sell2_2) Order = SIGNAL_SELL;


   //+------------------------------------------------------------------+
   //| Signal End                                                       |
   //+------------------------------------------------------------------+

   //Buy
   if (Order == SIGNAL_BUY && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
      if(!IsTrade) {
         //Check free margin
         if (AccountFreeMargin() < (1000 * Lots)) {
            Print("We have no money. Free Margin = ", AccountFreeMargin());
            return(0);
         }

         if (UseStopLoss) StopLossLevel = Ask - StopLoss * Point; else StopLossLevel = 0.0;
         if (UseTakeProfit) TakeProfitLevel = Ask + TakeProfit * Point; else TakeProfitLevel = 0.0;

         Ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, StopLossLevel, TakeProfitLevel, "Buy(#" + MagicNumber + ")", MagicNumber, 0, DodgerBlue);
         if(Ticket > 0) {
            if (OrderSelect(Ticket, SELECT_BY_TICKET, MODE_TRADES)) {
				Print("BUY order opened : ", OrderOpenPrice());
                if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Ask, Digits) + " Open Buy");
			} else {
				Print("Error opening BUY order : ", GetLastError());
			}
         }
         if (EachTickMode) TickCheck = True;
         if (!EachTickMode) BarCount = Bars;
         return(0);
      }
   }

   //Sell
   if (Order == SIGNAL_SELL && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
      if(!IsTrade) {
         //Check free margin
         if (AccountFreeMargin() < (1000 * Lots)) {
            Print("We have no money. Free Margin = ", AccountFreeMargin());
            return(0);
         }

         if (UseStopLoss) StopLossLevel = Bid + StopLoss * Point; else StopLossLevel = 0.0;
         if (UseTakeProfit) TakeProfitLevel = Bid - TakeProfit * Point; else TakeProfitLevel = 0.0;

         Ticket = OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, StopLossLevel, TakeProfitLevel, "Sell(#" + MagicNumber + ")", MagicNumber, 0, DeepPink);
         if(Ticket > 0) {
            if (OrderSelect(Ticket, SELECT_BY_TICKET, MODE_TRADES)) {
				Print("SELL order opened : ", OrderOpenPrice());
                if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + " Open Sell");
			} else {
				Print("Error opening SELL order : ", GetLastError());
			}
         }
         if (EachTickMode) TickCheck = True;
         if (!EachTickMode) BarCount = Bars;
         return(0);
      }
   }

   if (!EachTickMode) BarCount = Bars;

   return(0);
}
//+------------------------------------------------------------------+

Profitability Reports

EUR/USD Jan 2025 - Jul 2025
136.40
Total Trades 199
Won Trades 104
Lost trades 95
Win Rate 52.26 %
Expected payoff 3015.49
Gross Profit 604515.00
Gross Loss -4432.00
Total Net Profit 600083.00
-100%
-50%
0%
50%
100%
AUD/USD Jan 2025 - Jul 2025
3.00
Total Trades 165
Won Trades 40
Lost trades 125
Win Rate 24.24 %
Expected payoff 50.71
Gross Profit 12557.60
Gross Loss -4191.20
Total Net Profit 8366.40
-100%
-50%
0%
50%
100%
USD/CHF Oct 2024 - Jan 2025
0.00
Total Trades 0
Won Trades 0
Lost trades 0
Win Rate 0.0 %
Expected payoff 0.00
Gross Profit 0.00
Gross Loss 0.00
Total Net Profit 0.00
-100%
-50%
0%
50%
100%
USD/CAD Oct 2024 - Jan 2025
1.13
Total Trades 63
Won Trades 20
Lost trades 43
Win Rate 31.75 %
Expected payoff 2.54
Gross Profit 1368.23
Gross Loss -1208.06
Total Net Profit 160.17
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
0.63
Total Trades 81
Won Trades 18
Lost trades 63
Win Rate 22.22 %
Expected payoff -8.46
Gross Profit 1175.00
Gross Loss -1860.40
Total Net Profit -685.40
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
0.61
Total Trades 90
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -15.02
Gross Profit 2091.80
Gross Loss -3443.60
Total Net Profit -1351.80
-100%
-50%
0%
50%
100%

Comments