Profit factor:
0.96
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
1 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

EUR/USD Jan 2025 - Jul 2025
0.00
Total Trades 214
Won Trades 152
Lost trades 62
Win Rate 71.03 %
Expected payoff -7590.32
Gross Profit 895.40
Gross Loss -1625223.80
Total Net Profit -1624328.40
-100%
-50%
0%
50%
100%
AUD/USD Jan 2025 - Jul 2025
1.74
Total Trades 662
Won Trades 492
Lost trades 170
Win Rate 74.32 %
Expected payoff 1.99
Gross Profit 3081.60
Gross Loss -1766.50
Total Net Profit 1315.10
-100%
-50%
0%
50%
100%
USD/CAD Oct 2024 - Jan 2025
1.22
Total Trades 324
Won Trades 211
Lost trades 113
Win Rate 65.12 %
Expected payoff 1.48
Gross Profit 2665.27
Gross Loss -2185.06
Total Net Profit 480.21
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
0.00
Total Trades 79
Won Trades 15
Lost trades 64
Win Rate 18.99 %
Expected payoff -94.70
Gross Profit 34.70
Gross Loss -7515.70
Total Net Profit -7481.00
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
1.25
Total Trades 324
Won Trades 243
Lost trades 81
Win Rate 75.00 %
Expected payoff 2.29
Gross Profit 3653.70
Gross Loss -2912.10
Total Net Profit 741.60
-100%
-50%
0%
50%
100%
AUD/USD Oct 2024 - Jan 2025
1.56
Total Trades 322
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff 2.10
Gross Profit 1883.50
Gross Loss -1208.80
Total Net Profit 674.70
-100%
-50%
0%
50%
100%

Comments