TrendStrengthEMA

Author: pengie, Braindancer
Profit factor:
0.79
Orders Execution
Checks for the total of open ordersIt Closes Orders by itself It automatically opens orders when conditions are reached
Indicators Used
Moving average indicator
6 Views
0 Downloads
0 Favorites
TrendStrengthEMA
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

#property copyright "pengie, Braindancer"
#property link      "http://www.forex-tsd.com"

extern string EAName = "TrendStrengthEMA";
extern int magic = 2703;

extern int SL = 0;
extern int TP = 0;

extern int slippage = 3;
extern double lots = 0.1;

datetime prevTime, curTime;
int ticket;

int init()
{
   prevTime = Time[0];
   magic = GenerateMagicNumber(magic, Symbol(), Period());
	EAName = GenerateComment(EAName, magic, Period());
	
	int maxOrders = OrdersTotal();
	int t_index;
	for (t_index=0; t_index<maxOrders; t_index++)
	{
		OrderSelect(t_index, SELECT_BY_POS, MODE_TRADES);
		if (magic==OrderMagicNumber())
		{			
			ticket = OrderTicket();
			break;
		}	
	}	
   return (0);
}

int deinit()
{
   return (0);
}

int start()
{
   curTime = Time[0];
   
   if (prevTime != curTime)
   {
      prevTime = curTime;
      
      double tmp = iMA(NULL,0,11,0,MODE_EMA,PRICE_CLOSE,2);     
      double ma1 = tmp-iMA(NULL,0,5,0,MODE_EMA,PRICE_CLOSE,2); 
      double ma2 = tmp-iMA(NULL,0,10,0,MODE_EMA,PRICE_CLOSE,2); 
      double ma3 = tmp-iMA(NULL,0,15,0,MODE_EMA,PRICE_CLOSE,2); 
      double ma4 = tmp-iMA(NULL,0,20,0,MODE_EMA,PRICE_CLOSE,2);  
      double ma5 = tmp-iMA(NULL,0,25,0,MODE_EMA,PRICE_CLOSE,2);
      double ma6 = tmp-iMA(NULL,0,30,0,MODE_EMA,PRICE_CLOSE,2);
      double ma7 = tmp-iMA(NULL,0,40,0,MODE_EMA,PRICE_CLOSE,2);
     
      double prevTS = (ma1+ma2+ma3+ma4+ma5+ma6+ma7)/7;  
      
      tmp = iMA(NULL,0,11,0,MODE_EMA,PRICE_CLOSE,1);     
      ma1 = tmp-iMA(NULL,0,5,0,MODE_EMA,PRICE_CLOSE,1); 
      ma2 = tmp-iMA(NULL,0,10,0,MODE_EMA,PRICE_CLOSE,1); 
      ma3 = tmp-iMA(NULL,0,15,0,MODE_EMA,PRICE_CLOSE,1); 
      ma4 = tmp-iMA(NULL,0,20,0,MODE_EMA,PRICE_CLOSE,1);  
      ma5 = tmp-iMA(NULL,0,25,0,MODE_EMA,PRICE_CLOSE,1);
      ma6 = tmp-iMA(NULL,0,30,0,MODE_EMA,PRICE_CLOSE,1);
      ma7 = tmp-iMA(NULL,0,40,0,MODE_EMA,PRICE_CLOSE,1);
      
      double curTS = (ma1+ma2+ma3+ma4+ma5+ma6+ma7)/7;
      double stoploss, takeprofit;
      if (prevTS<0 && curTS>0)
      {
         OrderClose(ticket, lots, Ask, slippage, CLR_NONE);
         stoploss = 0;
         if (SL != 0) stoploss = Ask-SL*Point;
         takeprofit = 0;
         if (TP != 0) takeprofit = Ask+TP*Point;
         ticket = OrderSend(Symbol(), OP_BUY, lots, Ask, slippage, stoploss, takeprofit, EAName, magic, 0, CLR_NONE);         
      }
      else if (prevTS>0 && curTS<0)
      {
         OrderClose(ticket, lots, Bid, slippage, CLR_NONE);
         stoploss = 0;
         if (SL != 0) stoploss = Bid+SL*Point;
         takeprofit = 0;
         if (TP != 0) takeprofit = Bid-TP*Point;
         ticket = OrderSend(Symbol(), OP_SELL, lots, Bid, slippage, stoploss, takeprofit, EAName, magic, 0, CLR_NONE);         
      }
   }
   return (0);
}

int GenerateMagicNumber(int seed, string symbol, int timeFrame)
{
   int isymbol = 0;
   if (symbol == "EURUSD") isymbol = 1;
   else if (symbol == "GBPUSD") isymbol = 2;
   else if (symbol == "USDJPY") isymbol = 3;
   else if (symbol == "USDCHF") isymbol = 4;
   else if (symbol == "AUDUSD") isymbol = 5;
   else if (symbol == "USDCAD") isymbol = 6;
   else if (symbol == "EURGBP") isymbol = 7;
   else if (symbol == "EURJPY") isymbol = 8;
   else if (symbol == "EURCHF") isymbol = 9;
   else if (symbol == "EURAUD") isymbol = 10;
   else if (symbol == "EURCAD") isymbol = 11;
   else if (symbol == "GBPUSD") isymbol = 12;
   else if (symbol == "GBPJPY") isymbol = 13;
   else if (symbol == "GBPCHF") isymbol = 14;
   else if (symbol == "GBPAUD") isymbol = 15;
   else if (symbol == "GBPCAD") isymbol = 16;
   return (StrToInteger(StringConcatenate(seed, isymbol, timeFrame)));
}

string GenerateComment(string EAName, int magic, int timeFrame)
{
   return (StringConcatenate(EAName, "-", magic, "-", timeFrame));
}

Profitability Reports

USD/JPY Jul 2025 - Sep 2025
0.58
Total Trades 49
Won Trades 12
Lost trades 37
Win Rate 24.49 %
Expected payoff -9.98
Gross Profit 680.49
Gross Loss -1169.34
Total Net Profit -488.85
-100%
-50%
0%
50%
100%
USD/CHF Jul 2025 - Sep 2025
0.44
Total Trades 51
Won Trades 9
Lost trades 42
Win Rate 17.65 %
Expected payoff -11.86
Gross Profit 480.89
Gross Loss -1085.74
Total Net Profit -604.85
-100%
-50%
0%
50%
100%
USD/CAD Jul 2025 - Sep 2025
0.79
Total Trades 39
Won Trades 12
Lost trades 27
Win Rate 30.77 %
Expected payoff -2.83
Gross Profit 409.20
Gross Loss -519.56
Total Net Profit -110.36
-100%
-50%
0%
50%
100%
NZD/USD Jul 2025 - Sep 2025
1.11
Total Trades 37
Won Trades 12
Lost trades 25
Win Rate 32.43 %
Expected payoff 1.29
Gross Profit 497.40
Gross Loss -449.70
Total Net Profit 47.70
-100%
-50%
0%
50%
100%
GBP/USD Jul 2025 - Sep 2025
1.02
Total Trades 35
Won Trades 11
Lost trades 24
Win Rate 31.43 %
Expected payoff 0.53
Gross Profit 903.10
Gross Loss -884.40
Total Net Profit 18.70
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
0.84
Total Trades 36
Won Trades 6
Lost trades 30
Win Rate 16.67 %
Expected payoff -3.57
Gross Profit 694.24
Gross Loss -822.86
Total Net Profit -128.62
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
0.97
Total Trades 37
Won Trades 12
Lost trades 25
Win Rate 32.43 %
Expected payoff -0.56
Gross Profit 702.58
Gross Loss -723.30
Total Net Profit -20.72
-100%
-50%
0%
50%
100%
EUR/USD Jul 2025 - Sep 2025
0.00
Total Trades 5
Won Trades 0
Lost trades 5
Win Rate 0.00 %
Expected payoff -21124.32
Gross Profit 0.00
Gross Loss -105621.60
Total Net Profit -105621.60
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
1.25
Total Trades 33
Won Trades 14
Lost trades 19
Win Rate 42.42 %
Expected payoff 2.84
Gross Profit 464.50
Gross Loss -370.80
Total Net Profit 93.70
-100%
-50%
0%
50%
100%
USD/JPY Jan 2025 - Jul 2025
0.89
Total Trades 93
Won Trades 33
Lost trades 60
Win Rate 35.48 %
Expected payoff -2.61
Gross Profit 2000.96
Gross Loss -2243.31
Total Net Profit -242.35
-100%
-50%
0%
50%
100%

Comments