Follow_Your_Heart

Author: Copyright � 2013, basisforex@gmail.com
Profit factor:
0.83
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
7 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

USD/JPY Jul 2025 - Sep 2025
0.79
Total Trades 26
Won Trades 10
Lost trades 16
Win Rate 38.46 %
Expected payoff -6.77
Gross Profit 667.67
Gross Loss -843.65
Total Net Profit -175.98
-100%
-50%
0%
50%
100%
USD/CHF Jul 2025 - Sep 2025
0.91
Total Trades 30
Won Trades 13
Lost trades 17
Win Rate 43.33 %
Expected payoff -2.68
Gross Profit 817.44
Gross Loss -897.95
Total Net Profit -80.51
-100%
-50%
0%
50%
100%
USD/CAD Jul 2025 - Sep 2025
0.58
Total Trades 13
Won Trades 4
Lost trades 9
Win Rate 30.77 %
Expected payoff -14.80
Gross Profit 262.17
Gross Loss -454.62
Total Net Profit -192.45
-100%
-50%
0%
50%
100%
NZD/USD Jul 2025 - Sep 2025
0.81
Total Trades 18
Won Trades 7
Lost trades 11
Win Rate 38.89 %
Expected payoff -5.47
Gross Profit 430.70
Gross Loss -529.10
Total Net Profit -98.40
-100%
-50%
0%
50%
100%
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%

Comments