Profit factor:
1.28
Price Data Components
Series array that contains open time of each bar
Orders Execution
Checks for the total of open ordersIt Closes Orders by itself It automatically opens orders when conditions are reached
9 Views
0 Downloads
0 Favorites
sell_buy
//+------------------------------------------------------------------+
//|                                                     sell&buy.mq4 |
//+------------------------------------------------------------------+

extern double lots=0.1;
extern double target=4;
int cbars=0;
int magic=9348670;
int dist=24;

int start() {

 double profit=0;
 int j=OrdersTotal()-1;
 for (int i=j;i>=0;i--)
  {
   OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
   if(OrderMagicNumber()==magic && OrderSymbol()==Symbol())
   profit=OrderProfit()+OrderSwap()+profit;
  }
 
 if (profit>=target)
  {
   j=OrdersTotal()-1;
   for (i=j;i>=0;i--)
    {
     OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
     RefreshRates();
     if(OrderType()==OP_BUY && OrderMagicNumber()==magic && OrderSymbol()==Symbol())
      OrderClose(OrderTicket(),OrderLots(),Bid,3,Blue);
    }
  }
 
 double sig = Lowest(NULL,0,MODE_LOW,dist,0);
 if(cbars!=Bars && sig==1)
  {
   RefreshRates();
   OrderSend(Symbol(),OP_BUY,lots,Ask,3,0,0,"buy",magic,0,Blue);
   string AN="ArrBuy "+TimeToStr(CurTime());
   ObjectCreate(AN,OBJ_ARROW,0,Time[1],Low[1]-6*Point,0,0,0,0);
   ObjectSet(AN, OBJPROP_ARROWCODE, 233);
   ObjectSet(AN, OBJPROP_COLOR , Blue);
  }

 profit=0;
 j=OrdersTotal()-1;
 for (i=j;i>=0;i--)
  {
   OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
   if(OrderType()==OP_SELL && OrderMagicNumber()==magic && OrderSymbol()==Symbol())
   profit=OrderProfit()+OrderSwap()+profit;
  }
 
 if (profit>=target)
  {
   j=OrdersTotal()-1;
   for (i=j;i>=0;i--)
    {
     OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
     RefreshRates();
     if(OrderType()==OP_SELL && OrderMagicNumber()==magic && OrderSymbol()==Symbol())
      OrderClose(OrderTicket(),OrderLots(),Ask,3,Magenta);
    }
  }
 
 sig = Highest(NULL,0,MODE_HIGH,dist,0);
 if(cbars!=Bars && sig==1)
  {
   RefreshRates();
   OrderSend(Symbol(),OP_SELL,lots,Bid,3,0,0,"sell",magic,0,Magenta);
   AN="ArrSell "+TimeToStr(CurTime());
   ObjectCreate(AN,OBJ_ARROW,0,Time[1],High[1]+6*Point,0,0,0,0);
   ObjectSet(AN, OBJPROP_ARROWCODE, 234);
   ObjectSet(AN, OBJPROP_COLOR , Magenta);
  }

 cbars=Bars;
 
 return(0);
}

Profitability Reports

USD/JPY Jul 2025 - Sep 2025
1.58
Total Trades 330
Won Trades 250
Lost trades 80
Win Rate 75.76 %
Expected payoff 2.23
Gross Profit 1995.86
Gross Loss -1260.50
Total Net Profit 735.36
-100%
-50%
0%
50%
100%
USD/CHF Jul 2025 - Sep 2025
1.87
Total Trades 269
Won Trades 208
Lost trades 61
Win Rate 77.32 %
Expected payoff 2.43
Gross Profit 1401.08
Gross Loss -748.05
Total Net Profit 653.03
-100%
-50%
0%
50%
100%
USD/CAD Jul 2025 - Sep 2025
1.31
Total Trades 315
Won Trades 220
Lost trades 95
Win Rate 69.84 %
Expected payoff 1.47
Gross Profit 1980.84
Gross Loss -1517.75
Total Net Profit 463.09
-100%
-50%
0%
50%
100%
NZD/USD Jul 2025 - Sep 2025
1.13
Total Trades 338
Won Trades 247
Lost trades 91
Win Rate 73.08 %
Expected payoff 0.52
Gross Profit 1558.10
Gross Loss -1383.30
Total Net Profit 174.80
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
1.73
Total Trades 293
Won Trades 209
Lost trades 84
Win Rate 71.33 %
Expected payoff 1.87
Gross Profit 1296.44
Gross Loss -749.56
Total Net Profit 546.88
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
1.36
Total Trades 324
Won Trades 228
Lost trades 96
Win Rate 70.37 %
Expected payoff 1.83
Gross Profit 2248.21
Gross Loss -1654.29
Total Net Profit 593.92
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
1.70
Total Trades 326
Won Trades 236
Lost trades 90
Win Rate 72.39 %
Expected payoff 1.90
Gross Profit 1507.50
Gross Loss -887.60
Total Net Profit 619.90
-100%
-50%
0%
50%
100%
USD/JPY Jan 2025 - Jul 2025
1.60
Total Trades 667
Won Trades 515
Lost trades 152
Win Rate 77.21 %
Expected payoff 2.46
Gross Profit 4358.67
Gross Loss -2719.85
Total Net Profit 1638.82
-100%
-50%
0%
50%
100%
USD/CHF Jan 2025 - Jul 2025
1.32
Total Trades 638
Won Trades 479
Lost trades 159
Win Rate 75.08 %
Expected payoff 2.45
Gross Profit 6447.96
Gross Loss -4882.96
Total Net Profit 1565.00
-100%
-50%
0%
50%
100%
USD/CAD Jan 2025 - Jul 2025
1.66
Total Trades 660
Won Trades 495
Lost trades 165
Win Rate 75.00 %
Expected payoff 2.30
Gross Profit 3803.79
Gross Loss -2288.80
Total Net Profit 1514.99
-100%
-50%
0%
50%
100%

Comments