X trader v2

Author: Copyright � 2012, www.FxAutomated.com
Profit factor:
33.35
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
11 Views
0 Downloads
0 Favorites
X trader v2
//+------------------------------------------------------------------+
//|                                                  X trader v2.mq4 |
//|                            Copyright © 2013, 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;

string Trend;

//+------------------------------------------------------------------+
//| expert starts                                  |
//+------------------------------------------------------------------+
int start()
  {
//----
int StopMultd,Slip=5;


StopMultd=10;
double TP=NormalizeDouble(TakeProfit*StopMultd,Digits);
// stop loss
double SL=NormalizeDouble(StopLoss*StopMultd,Digits); 

double Slippage=NormalizeDouble(Slip*StopMultd,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&&OrderSymbol()==Symbol()) {int halt1=1;}
 
        }
     }
}
//-------------------------------------------------------------------+

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


if(halt1!=1){// halt1

// Sell criteria
if ((MA1_bc>MA2_bc)&&(MA1_bp>MA2_bp)&&(MA1_bl<MA2_bl)&&Trend!="SELL") //Signal Sell
 {
   int opensell=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,0,0,"X trader 2 trade ",MagicNumber,0,Green);
   if(opensell<1){int sellfail=1;}
   Trend="SELL";
 }
 
 // Buy criteria
 if ((MA1_bc<MA2_bc)&&(MA1_bp<MA2_bp)&&(MA1_bl>MA2_bl)&&Trend!="BUY") //Signal Buy
 {
   int openbuy=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,0,0,"X trader 2 trade ",MagicNumber,0,Blue);
   if(openbuy<1){int buyfail=1;}
   Trend="BUY";
 }
 
 }// 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
      
                // Calculate take profit
                double tpb=NormalizeDouble(OrderOpenPrice()+TP*Point,Digits);
                double tps=NormalizeDouble(OrderOpenPrice()-TP*Point,Digits);
                // Calculate stop loss
                double slb=NormalizeDouble(OrderOpenPrice()-SL*Point,Digits);
                double sls=NormalizeDouble(OrderOpenPrice()+SL*Point,Digits);
        
          if((OrderMagicNumber()==MagicNumber&&OrderType()==OP_BUY)&&(OrderTakeProfit()==0||OrderStopLoss()==0)&&OrderSymbol()==Symbol()) { OrderModify(OrderTicket(),0,slb,tpb,0,CLR_NONE); }
          if((OrderMagicNumber()==MagicNumber&&OrderType()==OP_SELL)&&(OrderTakeProfit()==0||OrderStopLoss()==0)&&OrderSymbol()==Symbol()) { 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);
  }
//+----------------------END-------------


































































int init()
{
Alert("Visit www.FxAutomated.com for more goodies!");
return(0);
}

Profitability Reports

AUD/USD Jul 2025 - Sep 2025
1000.00
Total Trades 3
Won Trades 2
Lost trades 1
Win Rate 66.67 %
Expected payoff 99.90
Gross Profit 300.00
Gross Loss -0.30
Total Net Profit 299.70
-100%
-50%
0%
50%
100%
NZD/USD Jan 2025 - Jul 2025
3.89
Total Trades 11
Won Trades 8
Lost trades 3
Win Rate 72.73 %
Expected payoff 78.93
Gross Profit 1168.20
Gross Loss -300.00
Total Net Profit 868.20
-100%
-50%
0%
50%
100%
USD/CHF Jul 2025 - Sep 2025
2.93
Total Trades 3
Won Trades 2
Lost trades 1
Win Rate 66.67 %
Expected payoff 82.05
Gross Profit 373.65
Gross Loss -127.49
Total Net Profit 246.16
-100%
-50%
0%
50%
100%
EUR/USD Jul 2025 - Sep 2025
2.35
Total Trades 11
Won Trades 7
Lost trades 4
Win Rate 63.64 %
Expected payoff 48.93
Gross Profit 938.20
Gross Loss -400.00
Total Net Profit 538.20
-100%
-50%
0%
50%
100%
GBP/USD Jul 2025 - Sep 2025
2.27
Total Trades 13
Won Trades 8
Lost trades 5
Win Rate 61.54 %
Expected payoff 48.72
Gross Profit 1133.30
Gross Loss -500.00
Total Net Profit 633.30
-100%
-50%
0%
50%
100%
GBP/USD Jan 2025 - Jul 2025
1.73
Total Trades 27
Won Trades 14
Lost trades 13
Win Rate 51.85 %
Expected payoff 32.91
Gross Profit 2100.00
Gross Loss -1211.30
Total Net Profit 888.70
-100%
-50%
0%
50%
100%
USD/CAD Jul 2025 - Sep 2025
1.62
Total Trades 3
Won Trades 2
Lost trades 1
Win Rate 66.67 %
Expected payoff 14.91
Gross Profit 116.85
Gross Loss -72.12
Total Net Profit 44.73
-100%
-50%
0%
50%
100%
GBP/CAD Oct 2024 - Jan 2025
1.57
Total Trades 17
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff 19.48
Gross Profit 910.75
Gross Loss -579.51
Total Net Profit 331.24
-100%
-50%
0%
50%
100%
USD/JPY Jul 2025 - Sep 2025
1.34
Total Trades 17
Won Trades 8
Lost trades 9
Win Rate 47.06 %
Expected payoff 12.13
Gross Profit 814.84
Gross Loss -608.61
Total Net Profit 206.23
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
1.32
Total Trades 5
Won Trades 2
Lost trades 3
Win Rate 40.00 %
Expected payoff 14.68
Gross Profit 300.00
Gross Loss -226.60
Total Net Profit 73.40
-100%
-50%
0%
50%
100%
USD/JPY Jul 2025 - Sep 2025
1.25
Total Trades 11
Won Trades 5
Lost trades 6
Win Rate 45.45 %
Expected payoff 9.07
Gross Profit 506.87
Gross Loss -407.12
Total Net Profit 99.75
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
1.23
Total Trades 10
Won Trades 5
Lost trades 5
Win Rate 50.00 %
Expected payoff 11.64
Gross Profit 616.40
Gross Loss -500.00
Total Net Profit 116.40
-100%
-50%
0%
50%
100%
GBP/AUD Jan 2025 - Jul 2025
1.20
Total Trades 54
Won Trades 24
Lost trades 30
Win Rate 44.44 %
Expected payoff 7.40
Gross Profit 2397.56
Gross Loss -1998.01
Total Net Profit 399.55
-100%
-50%
0%
50%
100%
EUR/USD Jan 2025 - Jul 2025
1.12
Total Trades 25
Won Trades 11
Lost trades 14
Win Rate 44.00 %
Expected payoff 6.79
Gross Profit 1569.80
Gross Loss -1400.00
Total Net Profit 169.80
-100%
-50%
0%
50%
100%
GBP/USD Jul 2025 - Sep 2025
1.07
Total Trades 12
Won Trades 5
Lost trades 7
Win Rate 41.67 %
Expected payoff 4.17
Gross Profit 750.00
Gross Loss -700.00
Total Net Profit 50.00
-100%
-50%
0%
50%
100%
EUR/USD Jul 2025 - Sep 2025
1.02
Total Trades 19
Won Trades 8
Lost trades 11
Win Rate 42.11 %
Expected payoff 1.04
Gross Profit 1119.80
Gross Loss -1100.00
Total Net Profit 19.80
-100%
-50%
0%
50%
100%
USD/CHF Jul 2025 - Sep 2025
1.01
Total Trades 4
Won Trades 2
Lost trades 2
Win Rate 50.00 %
Expected payoff 0.84
Gross Profit 251.55
Gross Loss -248.18
Total Net Profit 3.37
-100%
-50%
0%
50%
100%
GBP/CAD Jan 2025 - Jul 2025
0.94
Total Trades 38
Won Trades 15
Lost trades 23
Win Rate 39.47 %
Expected payoff -2.79
Gross Profit 1555.24
Gross Loss -1661.18
Total Net Profit -105.94
-100%
-50%
0%
50%
100%
USD/JPY Jan 2025 - Jul 2025
0.71
Total Trades 48
Won Trades 16
Lost trades 32
Win Rate 33.33 %
Expected payoff -13.36
Gross Profit 1544.56
Gross Loss -2186.00
Total Net Profit -641.44
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
0.71
Total Trades 13
Won Trades 4
Lost trades 9
Win Rate 30.77 %
Expected payoff -13.79
Gross Profit 428.50
Gross Loss -607.80
Total Net Profit -179.30
-100%
-50%
0%
50%
100%
NZD/USD Jul 2025 - Sep 2025
0.66
Total Trades 4
Won Trades 1
Lost trades 3
Win Rate 25.00 %
Expected payoff -19.62
Gross Profit 150.00
Gross Loss -228.50
Total Net Profit -78.50
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
0.60
Total Trades 18
Won Trades 5
Lost trades 13
Win Rate 27.78 %
Expected payoff -17.75
Gross Profit 488.37
Gross Loss -807.96
Total Net Profit -319.59
-100%
-50%
0%
50%
100%
NZD/USD Jul 2025 - Sep 2025
0.60
Total Trades 4
Won Trades 1
Lost trades 3
Win Rate 25.00 %
Expected payoff -25.38
Gross Profit 150.00
Gross Loss -251.50
Total Net Profit -101.50
-100%
-50%
0%
50%
100%
USD/CHF Jan 2025 - Jul 2025
0.56
Total Trades 17
Won Trades 5
Lost trades 12
Win Rate 29.41 %
Expected payoff -36.83
Gross Profit 782.66
Gross Loss -1408.83
Total Net Profit -626.17
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
0.49
Total Trades 9
Won Trades 2
Lost trades 7
Win Rate 22.22 %
Expected payoff -25.50
Gross Profit 216.94
Gross Loss -446.47
Total Net Profit -229.53
-100%
-50%
0%
50%
100%
USD/CAD Jan 2025 - Jul 2025
0.47
Total Trades 27
Won Trades 7
Lost trades 20
Win Rate 25.93 %
Expected payoff -27.76
Gross Profit 666.32
Gross Loss -1415.80
Total Net Profit -749.48
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
0.41
Total Trades 21
Won Trades 5
Lost trades 16
Win Rate 23.81 %
Expected payoff -29.90
Gross Profit 427.84
Gross Loss -1055.71
Total Net Profit -627.87
-100%
-50%
0%
50%
100%
AUD/USD Jan 2025 - Jul 2025
0.38
Total Trades 10
Won Trades 2
Lost trades 8
Win Rate 20.00 %
Expected payoff -48.05
Gross Profit 300.00
Gross Loss -780.50
Total Net Profit -480.50
-100%
-50%
0%
50%
100%
USD/CAD Jul 2025 - Sep 2025
0.38
Total Trades 5
Won Trades 1
Lost trades 4
Win Rate 20.00 %
Expected payoff -36.22
Gross Profit 108.81
Gross Loss -289.90
Total Net Profit -181.09
-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%
AUD/USD Jul 2025 - Sep 2025
0.00
Total Trades 2
Won Trades 0
Lost trades 2
Win Rate 0.00 %
Expected payoff -77.00
Gross Profit 0.00
Gross Loss -154.00
Total Net Profit -154.00
-100%
-50%
0%
50%
100%

Comments