Profit factor:
0.63
Orders Execution
Checks for the total of open ordersIt automatically opens orders when conditions are reachedIt Closes Orders by itself It can change open orders parameters, due to possible stepping strategy
Indicators Used
Moving average indicator
4 Views
0 Downloads
0 Favorites
up3x1
//+------------------------------------------------------------------+
//|                                                        up3x1.mq4 |
//|                                Copyright © 2006, izhutov aKa PPP |
//|                                                izhutov@yandex.ru |
//+------------------------------------------------------------------+
#define MAGICMA  20050610
extern double Lots               = 0.1;
extern double TakeProfit         = 150;
extern double StopLoss           = 100;
extern double TrailingStop       = 100;
double Points;
int init ()
  {
   Points = MarketInfo (Symbol(), MODE_POINT);
   return(0);
  }
int CalculateCurrentOrders(string symbol)
  {
   int buys=0,sells=0;
   for(int i=0;i<OrdersTotal();i++)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
      if(OrderSymbol()==Symbol() && OrderMagicNumber()==MAGICMA)
        {
         if(OrderType()==OP_BUY)  buys++;
         if(OrderType()==OP_SELL) sells++;
        }
     }
   if(buys>0) return(buys);
   else       return(-sells);
  }
double LotsOptimized()
  {
   double lot=Lots;
   int    orders=HistoryTotal();  
   int    losses=0;                 
   lot=NormalizeDouble(AccountFreeMargin()*0.02/1000.0,1);
   if(3>0)
     {
      for(int i=orders-1;i>=0;i--)
        {
         if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false) { Print("Error in history!"); break; }
         if(OrderSymbol()!=Symbol() || OrderType()>OP_SELL) continue;
         //----
         if(OrderProfit()>0) break;
         if(OrderProfit()<0) losses++;
        }
      if(losses>1) lot=NormalizeDouble(lot-lot*losses/3,1);
     }
   if(lot<0.1) lot=0.1;
   return(lot);
  }
void CheckForOpen()
  {
   double ma1;
   double ma2;
   double ma3;
   double ma4;
   double ma5;
   double ma6;
   int    res;
   if(Volume[0]>1) return;
   ma1=iMA(NULL,0,24,6,0,PRICE_CLOSE,1);
   ma4=iMA(NULL,0,24,6,0,PRICE_CLOSE,0);
   ma2=iMA(NULL,0,60,6,0,PRICE_CLOSE,1);
   ma5=iMA(NULL,0,60,6,0,PRICE_CLOSE,0);
   ma3=iMA(NULL,0,120,6,0,PRICE_CLOSE,1);
   ma6=iMA(NULL,0,120,6,0,PRICE_CLOSE,0);
     if (ma1<ma2 && ma2<ma3 && ma5<ma4 && ma4<ma6)
     {
      res=OrderSend(Symbol(),OP_BUY,LotsOptimized(),Ask,3,Ask-StopLoss*Points,Ask+TakeProfit*Points,"",MAGICMA,0,Blue);
      return;
     }
     if (ma1>ma2 && ma2>ma3 && ma5>ma4 && ma4>ma6)  
     {
      res=OrderSend(Symbol(),OP_SELL,LotsOptimized(),Bid,3,Bid+StopLoss*Points,Bid-TakeProfit*Points,"",MAGICMA,0,Red);
      return;
     }
  }
void CheckForClose()
  {
   double ma1;
   double ma2;
   double ma3;
   double ma4;
   double ma5;
   double ma6;
   if(Volume[0]>1) return;
   ma1=iMA(NULL,0,24,6,0,PRICE_CLOSE,1);
   ma4=iMA(NULL,0,24,6,0,PRICE_CLOSE,0);
   ma2=iMA(NULL,0,60,6,0,PRICE_CLOSE,1);
   ma5=iMA(NULL,0,60,6,0,PRICE_CLOSE,0);
   ma3=iMA(NULL,0,120,6,0,PRICE_CLOSE,1);
   ma6=iMA(NULL,0,120,6,0,PRICE_CLOSE,0);
   for(int i=0;i<OrdersTotal();i++)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false)        break;
      if(OrderMagicNumber()!=MAGICMA || OrderSymbol()!=Symbol()) continue;
      if(OrderType()==OP_BUY)
        {
        if(ma1>ma2>ma3 && ma6<ma4<ma5) OrderClose(OrderTicket(),OrderLots(),Bid,3,White);
        break;
        }
if(TrailingStop>0)  
              {                
               if(Bid-OrderOpenPrice()>Points*TrailingStop)
                 {
                  if(OrderStopLoss()<Bid-Points*TrailingStop)
                    {
                     OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Points*TrailingStop,OrderTakeProfit(),0,Red);
                     return(0);
                    }
                 }
              }        
      if(OrderType()==OP_SELL)
        {
        if(ma1<ma2<ma3 && ma6>ma4>ma5) OrderClose(OrderTicket(),OrderLots(),Ask,3,White);
        break;
        }
if(TrailingStop>0)  
              {                 
               if((OrderOpenPrice()-Ask)>(Points*TrailingStop))
                 {
                  if(OrderStopLoss()==0.0 || 
                     OrderStopLoss()>(Ask+Points*TrailingStop))
                    {
                     OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Points*TrailingStop,OrderTakeProfit(),0,Red);
                     return(0);
                    }
                 }
              }     
     }
  }
void start()
  {
   if(Bars<100 || IsTradeAllowed()==false) return;
   if(CalculateCurrentOrders(Symbol())==0) CheckForOpen();
   else                                    CheckForClose();
  }

Profitability Reports

USD/JPY Jan 2025 - Jul 2025
0.92
Total Trades 38
Won Trades 14
Lost trades 24
Win Rate 36.84 %
Expected payoff -0.52
Gross Profit 234.94
Gross Loss -254.74
Total Net Profit -19.80
-100%
-50%
0%
50%
100%
USD/CAD Jan 2025 - Jul 2025
0.97
Total Trades 40
Won Trades 15
Lost trades 25
Win Rate 37.50 %
Expected payoff -0.25
Gross Profit 274.29
Gross Loss -284.23
Total Net Profit -9.94
-100%
-50%
0%
50%
100%
NZD/USD Jan 2025 - Jul 2025
0.42
Total Trades 42
Won Trades 13
Lost trades 29
Win Rate 30.95 %
Expected payoff -5.56
Gross Profit 171.90
Gross Loss -405.50
Total Net Profit -233.60
-100%
-50%
0%
50%
100%
GBP/USD Jan 2025 - Jul 2025
0.70
Total Trades 42
Won Trades 13
Lost trades 29
Win Rate 30.95 %
Expected payoff -3.10
Gross Profit 300.00
Gross Loss -430.00
Total Net Profit -130.00
-100%
-50%
0%
50%
100%
GBP/CAD Jan 2025 - Jul 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%
GBP/AUD Jan 2025 - Jul 2025
0.32
Total Trades 38
Won Trades 7
Lost trades 31
Win Rate 18.42 %
Expected payoff -5.00
Gross Profit 89.94
Gross Loss -279.82
Total Net Profit -189.88
-100%
-50%
0%
50%
100%
EUR/USD Jan 2025 - Jul 2025
0.41
Total Trades 41
Won Trades 8
Lost trades 33
Win Rate 19.51 %
Expected payoff -6.34
Gross Profit 180.00
Gross Loss -440.00
Total Net Profit -260.00
-100%
-50%
0%
50%
100%
AUD/USD Jan 2025 - Jul 2025
1.03
Total Trades 43
Won Trades 18
Lost trades 25
Win Rate 41.86 %
Expected payoff 0.25
Gross Profit 335.60
Gross Loss -325.00
Total Net Profit 10.60
-100%
-50%
0%
50%
100%
USD/CAD Oct 2024 - Jan 2025
0.17
Total Trades 14
Won Trades 2
Lost trades 12
Win Rate 14.29 %
Expected payoff -7.14
Gross Profit 21.08
Gross Loss -121.01
Total Net Profit -99.93
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
1.71
Total Trades 16
Won Trades 9
Lost trades 7
Win Rate 56.25 %
Expected payoff 4.19
Gross Profit 161.20
Gross Loss -94.20
Total Net Profit 67.00
-100%
-50%
0%
50%
100%

Comments