Author: Copyright � 2012, www.FxAutomated.com
Profit factor:
101.30
Orders Execution
Checks for the total of open ordersIt automatically opens orders when conditions are reachedIt can change open orders parameters, due to possible stepping strategy
Indicators Used
Moving average indicator
Miscellaneous
It issuies visual alerts to the screen
12 Views
0 Downloads
0 Favorites
X trader
//+------------------------------------------------------------------+
//|                                                      X trader.mq4 |
//|                            Copyright © 2012, www.FxAutomated.com |
//|                                       http://www.FxAutomated.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2012, www.FxAutomated.com"
#property link      "http://www.FxAutomated.com"

//---- input parameters
extern double    Lots=0.1;
extern int       TakeProfit=150;
extern int       StopLoss=100;
extern string    Ma1="First Ma settings";
extern int       Ma1Period=16;
extern int       Ma1Shift=8;
extern int       Ma1Method=0;
extern int       Ma1AppliedPrice=4;
extern string    Ma2="Second Ma settings";
extern int       Ma2Period=1;
extern int       Ma2Shift=0;
extern int       Ma2Method=0;
extern int       Ma2AppliedPrice=4;
extern int       MagicNumber=320101;


//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   Alert("Visit www.FxAutomated.com for more goodies!");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert starts                                  |
//+------------------------------------------------------------------+
int start()
  {
//----
int StopMultd,Slip=5;


int digits=MarketInfo("EURUSD",MODE_DIGITS);
StopMultd=10;
double TP=NormalizeDouble(TakeProfit*StopMultd,Digits);
// stop loss
double SL=NormalizeDouble(StopLoss*StopMultd,Digits); 

double Slippage=NormalizeDouble(Slip*StopMultd,Digits);

// Calculate stop loss
double slb=NormalizeDouble(Ask-SL*Point,Digits);
double sls=NormalizeDouble(Bid+SL*Point,Digits);

// Calculate take profit
double tpb=NormalizeDouble(Ask+TP*Point,Digits);
double tps=NormalizeDouble(Bid-TP*Point,Digits);

// Ma strategy one
double MA1_bc=iMA(NULL,0,Ma1Period,Ma1Shift,Ma1Method,Ma1AppliedPrice,0);
double MA1_bp=iMA(NULL,0,Ma1Period,Ma1Shift,Ma1Method,Ma1AppliedPrice,1);
double MA1_bl=iMA(NULL,0,Ma1Period,Ma1Shift,Ma1Method,Ma1AppliedPrice,2);



// Ma constant
double MA2_bc=iMA(NULL,0,Ma2Period,Ma2Shift,Ma2Method,Ma2AppliedPrice,0);
double MA2_bp=iMA(NULL,0,Ma2Period,Ma2Shift,Ma2Method,Ma2AppliedPrice,1);
double MA2_bl=iMA(NULL,0,Ma2Period,Ma2Shift,Ma2Method,Ma2AppliedPrice,2);



//-------------------------------------------------------------------+
//Check open orders
//-------------------------------------------------------------------+
if(OrdersTotal()>0){
  for(int i=1; i<=OrdersTotal(); i++)          // Cycle searching in orders
     {
      if (OrderSelect(i-1,SELECT_BY_POS)==true) // If the next is available
        {
          if(OrderMagicNumber()==MagicNumber) {int halt1=1;}
 
        }
     }
}
//-------------------------------------------------------------------+

//-------------------------------------------------------------------+
// trading strategy
//-------------------------------------------------------------------+

Comment("For more goodies, managed accounts, forex signals and premium EAs visit www.FxAutomated.com");


if(halt1!=1){// halt1

// Sell criteria
if ((MA1_bc>MA2_bc)&&(MA1_bp>MA2_bp)&&(MA1_bl<MA2_bl)) //Signal Sell
 {
   int opensell=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,0,0,"X trader order ",MagicNumber,0,Green);
   if(opensell<1){int sellfail=1;}
 }
 
 // Buy criteria
 if ((MA1_bc<MA2_bc)&&(MA1_bp<MA2_bp)&&(MA1_bl>MA2_bl)) //Signal Buy
 {
   int openbuy=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,0,0,"X trader order ",MagicNumber,0,Blue);
   if(openbuy<1){int buyfail=1;}
 }
 
 }// halt1

//-----------------------------------------------------------------------------------------------------
if(OrdersTotal()>0){
  for(i=1; i<=OrdersTotal(); i++){          // Cycle searching in orders
  
      if (OrderSelect(i-1,SELECT_BY_POS)==true){ // If the next is available
        
          if((OrderMagicNumber()==MagicNumber&&OrderType()==OP_BUY)&&(OrderTakeProfit()==0||OrderStopLoss()==0)) { OrderModify(OrderTicket(),0,slb,tpb,0,CLR_NONE); }
          if((OrderMagicNumber()==MagicNumber&&OrderType()==OP_SELL)&&(OrderTakeProfit()==0||OrderStopLoss()==0)) { OrderModify(OrderTicket(),0,sls,tps,0,CLR_NONE); }

        }
     }
}

//-------------------------------------------------------------------+
// Error processing
//-------------------------------------------------------------------+
if(buyfail==1||sellfail==1){
int Error=GetLastError();
  if(Error==130){Alert("Wrong stops. Retrying."); RefreshRates();}
  if(Error==133){Alert("Trading prohibited.");}
  if(Error==2){Alert("Common error.");}
  if(Error==146){Alert("Trading subsystem is busy. Retrying."); Sleep(500); RefreshRates();}

}

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

Profitability Reports

AUD/USD Jul 2025 - Sep 2025
3000.00
Total Trades 3
Won Trades 2
Lost trades 1
Win Rate 66.67 %
Expected payoff 99.97
Gross Profit 300.00
Gross Loss -0.10
Total Net Profit 299.90
-100%
-50%
0%
50%
100%
NZD/USD Jan 2025 - Jul 2025
7.38
Total Trades 11
Won Trades 9
Lost trades 2
Win Rate 81.82 %
Expected payoff 106.09
Gross Profit 1350.00
Gross Loss -183.00
Total Net Profit 1167.00
-100%
-50%
0%
50%
100%
USD/CHF Jul 2025 - Sep 2025
3.62
Total Trades 4
Won Trades 3
Lost trades 1
Win Rate 75.00 %
Expected payoff 80.37
Gross Profit 444.11
Gross Loss -122.64
Total Net Profit 321.47
-100%
-50%
0%
50%
100%
USD/CHF Jul 2025 - Sep 2025
3.39
Total Trades 4
Won Trades 3
Lost trades 1
Win Rate 75.00 %
Expected payoff 74.78
Gross Profit 424.32
Gross Loss -125.18
Total Net Profit 299.14
-100%
-50%
0%
50%
100%
NZD/USD Jul 2025 - Sep 2025
2.73
Total Trades 6
Won Trades 4
Lost trades 2
Win Rate 66.67 %
Expected payoff 57.65
Gross Profit 545.90
Gross Loss -200.00
Total Net Profit 345.90
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
2.12
Total Trades 16
Won Trades 9
Lost trades 7
Win Rate 56.25 %
Expected payoff 29.40
Gross Profit 890.96
Gross Loss -420.60
Total Net Profit 470.36
-100%
-50%
0%
50%
100%
NZD/USD Jul 2025 - Sep 2025
1.56
Total Trades 5
Won Trades 3
Lost trades 2
Win Rate 60.00 %
Expected payoff 22.36
Gross Profit 311.80
Gross Loss -200.00
Total Net Profit 111.80
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
1.53
Total Trades 13
Won Trades 7
Lost trades 6
Win Rate 53.85 %
Expected payoff 24.34
Gross Profit 916.40
Gross Loss -600.00
Total Net Profit 316.40
-100%
-50%
0%
50%
100%
EUR/USD Jul 2025 - Sep 2025
1.51
Total Trades 129
Won Trades 65
Lost trades 64
Win Rate 50.39 %
Expected payoff 25.27
Gross Profit 9659.50
Gross Loss -6400.00
Total Net Profit 3259.50
-100%
-50%
0%
50%
100%
AUD/USD Jan 2025 - Jul 2025
1.25
Total Trades 11
Won Trades 5
Lost trades 6
Win Rate 45.45 %
Expected payoff 13.64
Gross Profit 750.00
Gross Loss -600.00
Total Net Profit 150.00
-100%
-50%
0%
50%
100%
USD/JPY Jul 2025 - Sep 2025
1.24
Total Trades 13
Won Trades 6
Lost trades 7
Win Rate 46.15 %
Expected payoff 8.87
Gross Profit 590.25
Gross Loss -474.95
Total Net Profit 115.30
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
1.15
Total Trades 19
Won Trades 8
Lost trades 11
Win Rate 42.11 %
Expected payoff 5.45
Gross Profit 781.34
Gross Loss -677.70
Total Net Profit 103.64
-100%
-50%
0%
50%
100%
GBP/USD Jul 2025 - Sep 2025
1.14
Total Trades 11
Won Trades 5
Lost trades 6
Win Rate 45.45 %
Expected payoff 7.83
Gross Profit 686.10
Gross Loss -600.00
Total Net Profit 86.10
-100%
-50%
0%
50%
100%
USD/CAD Jul 2025 - Sep 2025
1.08
Total Trades 4
Won Trades 2
Lost trades 2
Win Rate 50.00 %
Expected payoff 3.03
Gross Profit 156.21
Gross Loss -144.08
Total Net Profit 12.13
-100%
-50%
0%
50%
100%
GBP/AUD Jan 2025 - Jul 2025
1.00
Total Trades 57
Won Trades 23
Lost trades 34
Win Rate 40.35 %
Expected payoff 0.17
Gross Profit 2274.80
Gross Loss -2264.88
Total Net Profit 9.92
-100%
-50%
0%
50%
100%
GBP/USD Jan 2025 - Jul 2025
0.96
Total Trades 29
Won Trades 11
Lost trades 18
Win Rate 37.93 %
Expected payoff -2.16
Gross Profit 1650.00
Gross Loss -1712.70
Total Net Profit -62.70
-100%
-50%
0%
50%
100%
EUR/USD Jul 2025 - Sep 2025
0.87
Total Trades 347
Won Trades 128
Lost trades 219
Win Rate 36.89 %
Expected payoff -8.01
Gross Profit 19119.70
Gross Loss -21900.00
Total Net Profit -2780.30
-100%
-50%
0%
50%
100%
USD/JPY Jul 2025 - Sep 2025
0.86
Total Trades 22
Won Trades 8
Lost trades 14
Win Rate 36.36 %
Expected payoff -6.14
Gross Profit 813.03
Gross Loss -948.18
Total Net Profit -135.15
-100%
-50%
0%
50%
100%
GBP/USD Jul 2025 - Sep 2025
0.83
Total Trades 16
Won Trades 6
Lost trades 10
Win Rate 37.50 %
Expected payoff -10.42
Gross Profit 833.20
Gross Loss -1000.00
Total Net Profit -166.80
-100%
-50%
0%
50%
100%
GBP/CAD Oct 2024 - Jan 2025
0.80
Total Trades 19
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -9.25
Gross Profit 693.44
Gross Loss -869.25
Total Net Profit -175.81
-100%
-50%
0%
50%
100%
EUR/USD Jan 2025 - Jul 2025
0.77
Total Trades 207
Won Trades 70
Lost trades 137
Win Rate 33.82 %
Expected payoff -15.46
Gross Profit 10500.00
Gross Loss -13700.00
Total Net Profit -3200.00
-100%
-50%
0%
50%
100%
USD/CAD Jan 2025 - Jul 2025
0.59
Total Trades 28
Won Trades 8
Lost trades 20
Win Rate 28.57 %
Expected payoff -20.36
Gross Profit 836.16
Gross Loss -1406.26
Total Net Profit -570.10
-100%
-50%
0%
50%
100%
GBP/CAD Jan 2025 - Jul 2025
0.50
Total Trades 42
Won Trades 11
Lost trades 31
Win Rate 26.19 %
Expected payoff -26.60
Gross Profit 1121.84
Gross Loss -2238.98
Total Net Profit -1117.14
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
0.50
Total Trades 10
Won Trades 3
Lost trades 7
Win Rate 30.00 %
Expected payoff -25.48
Gross Profit 251.42
Gross Loss -506.18
Total Net Profit -254.76
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
0.50
Total Trades 14
Won Trades 4
Lost trades 10
Win Rate 28.57 %
Expected payoff -25.33
Gross Profit 359.57
Gross Loss -714.15
Total Net Profit -354.58
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
0.46
Total Trades 5
Won Trades 1
Lost trades 4
Win Rate 20.00 %
Expected payoff -35.32
Gross Profit 150.00
Gross Loss -326.60
Total Net Profit -176.60
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
0.45
Total Trades 2
Won Trades 1
Lost trades 1
Win Rate 50.00 %
Expected payoff -27.65
Gross Profit 44.70
Gross Loss -100.00
Total Net Profit -55.30
-100%
-50%
0%
50%
100%
USD/CHF Jan 2025 - Jul 2025
0.28
Total Trades 20
Won Trades 3
Lost trades 17
Win Rate 15.00 %
Expected payoff -71.54
Gross Profit 544.50
Gross Loss -1975.31
Total Net Profit -1430.81
-100%
-50%
0%
50%
100%
USD/CAD 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 Jul 2025 - Sep 2025
0.00
Total Trades 2
Won Trades 2
Lost trades 0
Win Rate 100.00 %
Expected payoff 62.23
Gross Profit 124.47
Gross Loss 0.00
Total Net Profit 124.47
-100%
-50%
0%
50%
100%

Comments