Follow_Your_Heart

Author: Copyright � 2013, basisforex@gmail.com
Profit factor:
0.84
Orders Execution
Checks for the total of open ordersIt Closes Orders by itself Checks for the total of closed ordersIt automatically opens orders when conditions are reachedIt can change open orders parameters, due to possible stepping strategy
5 Views
0 Downloads
0 Favorites
Follow_Your_Heart
/*-------------------------------------------------------------------+
 |                                               FollowYourHeart.mq4 |
 |                                                  Copyright © 2013 |
 |                                              basisforex@gmail.com |
 +-------------------------------------------------------------------*/
#property copyright "Copyright © 2013, basisforex@gmail.com"
#property link      "basisforex@gmail.com"
//---------------------------------------
#define MagicNum  3165
//--------------
extern int     nBars             = 6;
extern double  dLevel            = 2.3;
//----
extern double  profB             = 75;
extern double  profS             = 56;
extern double  lossB             = -54;
extern double  lossS             = -51;
//----
extern int     TP                = 550;
extern int     SL                = 550;
extern bool    UseMM             = false;
extern double  PercentMM         = 5;
extern double  lots              = 0.1;
//----
extern bool    TradingHoursOn    = true;
extern int     OpenSessionHourB  = 6;
extern int     CloseSessionHourB = 12;
extern int     OpenSessionHourS  = 4;
extern int     CloseSessionHourS = 10;
//+------------------------------------------------------------------+
int Get_Broker_Digit()
 {  
   if(Digits == 5 || Digits == 3)
    { 
       return(10);
    } 
   else
    {    
       return(1); 
    }   
 }
//+------------------------------------------------------------------+
int CalculateCurrentOrders()
 {
   int orderT = OrdersTotal(), buys = 0, sells = 0;
   //----
   for(int i = 0; i < orderT; i++)
    {
      if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES) == false) break;
      if(OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNum)
       {
         if(OrderType() == OP_BUY)  buys++;
         if(OrderType() == OP_SELL) sells++;
       }
    }
   //---- return orders volume
   if(buys > 0) return(buys);
   else if(sells > 0) return(-sells);
   else return(0);
 }
//+------------------------------------------------------------------+
double GetLots()
 { 
   if (UseMM)
    {
      double a;
      a = NormalizeDouble((PercentMM * AccountFreeMargin() / 100000), 1);      
      if(a > 49.9) return(49.9);
      else if(a < 0.1)
       {
         Print("Lots < 0.1");
         return(0);
       }
      else return(a);
    }    
   else return(lots);
 }
//+------------------------------------------------------------------+
void CheckForClose()
 {
   int d = Get_Broker_Digit();
   for(int cnt = 0; cnt < OrdersTotal(); cnt++)
    {
      OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
      if(OrderType() <= OP_SELL && OrderMagicNumber() == MagicNum)
       {
         if(OrderType() == OP_BUY)
          {
            if((OrderProfit() + OrderSwap() > profB) || (OrderProfit() < lossB))
             {
               OrderClose(OrderTicket(), OrderLots(), Bid, 2 * d, Violet);
             }               
          }
         else if(OrderType() == OP_SELL)
          {
            if((OrderProfit() + OrderSwap() > profS) || (OrderProfit() < lossS))
             {
               OrderClose(OrderTicket(), OrderLots(), Ask, 2 * d, Violet);            
             }  
          }
       }
    }
 }
//+------------------------------------------------------------------+
void CheckForOpen()
 { 
   int res;
   int d = Get_Broker_Digit();
   if(Volume[0] < 1) return;
   //======================
   int tot = OrdersHistoryTotal();
   if(tot > 0)
    {
      for(int n = tot - 1; n >= 0; n--)
       {
         OrderSelect(n, SELECT_BY_POS, MODE_HISTORY);
         if(OrderType() == OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNum)
          { 
            break;
          }
       }   
    } 
   if(iBarShift(NULL, 0, OrderCloseTime()) > 0 || tot == 0)
    {
      double o, c, h, l, sum;
      for(int i = 0; i < nBars; i++)
       {
         o = o + ((Open[i] - Open[i+1]) / Open[i+1]) / Point;
         c = c + ((Close[i] - Close[i+1]) / Close[i+1]) / Point;
         h = h + ((High[i] - High[i+1]) / High[i+1]) / Point;
         l = l + ((Low[i] - Low[i+1]) / Low[i+1]) / Point;
       }
      sum = (o + c + h + l) / 4;
      //=======================   
      if(sum > 0 && o > dLevel && c > dLevel && c > o) // BUY
       {
         if(TradingHoursOn == true)  
          {
            if(Hour() < OpenSessionHourB || Hour() > CloseSessionHourB)
             {
               return(0);
             }
          }
         if(1==1)
          {
            res = OrderSend(Symbol(), OP_BUY, GetLots(), Ask, 2 * d, 0, 0, "follow", MagicNum, 0, Green);
          }  
         if(res > 0)
          {
            OrderModify(res, Ask, Ask - SL * Point * d, Ask + TP * Point * d, 0, Green);
            return;
          }      
       }//==============================================
      if(sum < 0 && o < -dLevel && c < -dLevel && c < o)  // SELL
       {
         if(TradingHoursOn == true)  
          {
            if(Hour() < OpenSessionHourS || Hour() > CloseSessionHourS)
             {
               return(0);
             }
          }
         if(1==1)
          {
            res = OrderSend(Symbol(), OP_SELL, GetLots(), Bid, 2 * d, 0, 0, "follow", MagicNum, 0, Red);
          }  
         if(res > 0)
          {
            OrderModify(res, Bid, Bid + SL * Point * d,  Bid - TP * Point * d, 0, Red); 
            return;
          }   
       }
    }   
 }   
//+------------------------------------------------------------------+
void start()
 {  
   if(CalculateCurrentOrders() != 0) CheckForClose();
   if(CalculateCurrentOrders() == 0) CheckForOpen();
 }
//+------------------------------------------------------------------+

Profitability Reports

GBP/USD Jul 2025 - Sep 2025
0.99
Total Trades 38
Won Trades 17
Lost trades 21
Win Rate 44.74 %
Expected payoff -0.43
Gross Profit 1086.70
Gross Loss -1103.10
Total Net Profit -16.40
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
0.72
Total Trades 27
Won Trades 10
Lost trades 17
Win Rate 37.04 %
Expected payoff -9.29
Gross Profit 641.16
Gross Loss -891.86
Total Net Profit -250.70
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
0.47
Total Trades 38
Won Trades 11
Lost trades 27
Win Rate 28.95 %
Expected payoff -19.72
Gross Profit 674.72
Gross Loss -1424.06
Total Net Profit -749.34
-100%
-50%
0%
50%
100%
EUR/USD Jul 2025 - Sep 2025
0.87
Total Trades 265
Won Trades 122
Lost trades 143
Win Rate 46.04 %
Expected payoff -37.97
Gross Profit 67100.00
Gross Loss -77162.40
Total Net Profit -10062.40
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
1.54
Total Trades 19
Won Trades 11
Lost trades 8
Win Rate 57.89 %
Expected payoff 11.88
Gross Profit 646.60
Gross Loss -420.80
Total Net Profit 225.80
-100%
-50%
0%
50%
100%
USD/JPY Jan 2025 - Jul 2025
0.90
Total Trades 82
Won Trades 36
Lost trades 46
Win Rate 43.90 %
Expected payoff -2.90
Gross Profit 2192.99
Gross Loss -2430.53
Total Net Profit -237.54
-100%
-50%
0%
50%
100%
USD/CHF Jan 2025 - Jul 2025
0.96
Total Trades 89
Won Trades 40
Lost trades 49
Win Rate 44.94 %
Expected payoff -1.20
Gross Profit 2482.80
Gross Loss -2589.73
Total Net Profit -106.93
-100%
-50%
0%
50%
100%
USD/CAD Jan 2025 - Jul 2025
0.70
Total Trades 56
Won Trades 21
Lost trades 35
Win Rate 37.50 %
Expected payoff -9.75
Gross Profit 1291.32
Gross Loss -1837.20
Total Net Profit -545.88
-100%
-50%
0%
50%
100%
NZD/USD Jan 2025 - Jul 2025
0.87
Total Trades 49
Won Trades 20
Lost trades 29
Win Rate 40.82 %
Expected payoff -3.89
Gross Profit 1331.20
Gross Loss -1521.90
Total Net Profit -190.70
-100%
-50%
0%
50%
100%
GBP/USD Jan 2025 - Jul 2025
0.78
Total Trades 98
Won Trades 38
Lost trades 60
Win Rate 38.78 %
Expected payoff -7.18
Gross Profit 2481.00
Gross Loss -3185.10
Total Net Profit -704.10
-100%
-50%
0%
50%
100%

Comments