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
10 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.76
Total Trades 26
Won Trades 10
Lost trades 16
Win Rate 38.46 %
Expected payoff -7.52
Gross Profit 636.11
Gross Loss -831.65
Total Net Profit -195.54
-100%
-50%
0%
50%
100%
USD/CAD Jul 2025 - Sep 2025
0.53
Total Trades 12
Won Trades 4
Lost trades 8
Win Rate 33.33 %
Expected payoff -16.29
Gross Profit 218.96
Gross Loss -414.43
Total Net Profit -195.47
-100%
-50%
0%
50%
100%
NZD/USD Jul 2025 - Sep 2025
1.66
Total Trades 15
Won Trades 9
Lost trades 6
Win Rate 60.00 %
Expected payoff 13.91
Gross Profit 524.30
Gross Loss -315.60
Total Net Profit 208.70
-100%
-50%
0%
50%
100%
GBP/USD Jul 2025 - Sep 2025
0.61
Total Trades 40
Won Trades 14
Lost trades 26
Win Rate 35.00 %
Expected payoff -13.38
Gross Profit 823.40
Gross Loss -1358.60
Total Net Profit -535.20
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
0.59
Total Trades 25
Won Trades 8
Lost trades 17
Win Rate 32.00 %
Expected payoff -14.83
Gross Profit 524.47
Gross Loss -895.11
Total Net Profit -370.64
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
0.92
Total Trades 32
Won Trades 14
Lost trades 18
Win Rate 43.75 %
Expected payoff -2.52
Gross Profit 879.99
Gross Loss -960.75
Total Net Profit -80.76
-100%
-50%
0%
50%
100%
EUR/USD Jul 2025 - Sep 2025
0.83
Total Trades 204
Won Trades 92
Lost trades 112
Win Rate 45.10 %
Expected payoff -49.04
Gross Profit 50106.10
Gross Loss -60109.40
Total Net Profit -10003.30
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
0.81
Total Trades 17
Won Trades 7
Lost trades 10
Win Rate 41.18 %
Expected payoff -5.96
Gross Profit 421.70
Gross Loss -523.00
Total Net Profit -101.30
-100%
-50%
0%
50%
100%
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%

Comments