nemox-0001_133

Download script
Author: Copyright � 2005, MetaQuotes Software Corp.
Profit factor:
3.64

This script is an automated trading tool designed to execute trades based on specific price patterns and profit targets. Below is a detailed breakdown of its operational logic:

Core Operational Logic

The script monitors the market for specific "Fractal" price points—these are peaks and valleys in the price action that indicate potential reversal points. When these points are identified, the script follows a structured process of risk management, trade execution, and automated profit harvesting.

Key Features and Workflows

1. Profit Target & Auto-Closure

The system continuously calculates the total profit of all currently open positions.

  • Global Take Profit: If the combined profit of all active trades exceeds a user-defined threshold (ProfitLevel), the script automatically triggers a "Close All" command.
  • Execution Delay: After closing all positions, the script pauses for a short duration before allowing new trades to be opened, ensuring the market stabilizes.

2. Safety and Risk Management

  • Margin Check: Before opening any new trade, the script verifies that the account has sufficient free margin. If funds are insufficient, it will issue an alert and halt trading activity.
  • Stop Loss & Take Profit: Every trade is automatically equipped with a specific Stop Loss (to limit losses) and Take Profit (to secure gains) based on user-defined settings.
  • Time Restrictions: The script includes a hardcoded date check; it is programmed not to run before July 2005.

3. Trade Execution Strategy

The script identifies two specific market conditions to initiate trades:

  • Bearish Sentiment (Sell Signal): When a new high price peak (Upper Fractal) is detected, the system initiates a multi-step sell sequence. It first places a "Stop" order at a specific distance above the peak and then follows up with a primary Sell position.
  • Bullish Sentiment (Buy Signal): When a new low price valley (Lower Fractal) is detected, the system initiates a multi-step buy sequence. It first places a "Stop" order at a specific distance below the valley and then follows up with a primary Buy position.

4. Technical Timing

To prevent the script from spamming orders or crashing during high volatility, it employs several timing mechanisms:

  • Cooldown Periods: It enforces a small waiting window between individual order attempts.
  • Sequence Delays: There is a specific 10-second delay between the placement of the "Stop" order and the primary trade to ensure the correct market conditions are met.

Summary for the User

In essence, this script acts as an automated "reversal" trader. It looks for price extremes (fractals), sets up a two-step entry process (a stop order followed by a market order), manages your risk automatically via fixed stops and profits, and has a built-in "emergency exit" that closes everything once your total profit reaches a desired level.

Orders Execution
Checks for the total of open ordersIt Closes Orders by itself It automatically opens orders when conditions are reached
Indicators Used
Fractals
Miscellaneous
It issuies visual alerts to the screen
14 Views
0 Downloads
0 Favorites
nemox-0001_133
//+------------------------------------------------------------------+
//|                                                   ShadowTrader   |
//|                      Copyright © 2005, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//|                                                             v1.2 |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

extern double Lots     = 0.1;
extern int TakeProfit  =  500;
extern int StopLoss    =  500;
extern int limit       =   5; // Óðîâåíü óñòàíîâêè îòëîæåííîãî îðäåðà
extern int ProfitLevel =  30; // Îáùèé ïðîôèò äëÿ âñåõ ïîçèöèé ïðè êîòîðîì îíè çàêðûâàþòñÿ

static int magicNumber = 23456;
static datetime prev_min = D'1.1.1'; // Ïðåäûäóùèé ìèíèìóì
static datetime prev_max = D'1.1.1'; // Ïðåäûäóùèé ìàêñèìóì

bool AllowTrade,NewBar,OrdersClose,OpenSell,OpenBuy;
datetime LastTrade;
int ticket,n;

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
{
   AllowTrade=True;OrdersClose=false;OpenSell=false;OpenBuy=false;
   LastTrade=CurTime();
   ticket=0;n=0;
   return(0);
}

//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
{
   return(0);
}


//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
{
if ((Year()<2005) || (Month()<7)) return (0);

double iFractals_up = 0; // Ìàêñèìóì
double iFractals_lo = 0; // Ìèíèìóì
double TP =0,SL=0,price=0,totalprofit=0;
int cnt=0,i=0,totalcountpos=0;

   
//Òèïû îòêðûòûõ îðäåðîâ
int ps=0,pb=0,ss=0,sb=0,ls=0,lb=0;
   

//+------------------------------------------------------------------------------------------------+
//| Ìîäóëü ïîäñ÷¸òà îòêðûòûõ îðäåðîâ                                           
//+------------------------------------------------------------------------------------------------+
//Åñëè åñòü õîòü îäèí îòêðûòûé îðäåð, îïðåäåëÿåì òèï îòêðûòîãî îðäåðà
for (cnt=OrdersTotal()-1;cnt>=0;cnt--)
{  
   OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
       
   if (OrderType()==OP_SELL && OrderSymbol()==Symbol())
   {  //åñòü îòêðûòàÿ êîðîòêàÿ ïîçèöèÿ
      ps=ps+1;totalcountpos=totalcountpos+1;
      totalprofit=totalprofit+OrderProfit();
   }
   if (OrderType()==OP_BUY  && OrderSymbol()==Symbol())
   {  //åñòü îòêðûòàÿ äëèííàÿ ïîçèöèÿ
      pb=pb+1;totalcountpos=totalcountpos+1;
      totalprofit=totalprofit+OrderProfit();
   }
   if (OrderType()==OP_SELLSTOP && OrderSymbol()==Symbol())
   {  //åñòü îòëîæåííûé îðäåð SellStop
      ss=ss+1;totalcountpos=totalcountpos+1;
   }
   if (OrderType()==OP_BUYSTOP && OrderSymbol()==Symbol())
   {  //åñòü îòëîæåííûé îðäåð BuyStop
      sb=sb+1;totalcountpos=totalcountpos+1;
   }
} 
//+------------------------------------------------------------------------------------------------+
//| Êîíåö ìîäóëÿ ïîäñ÷¸òà îòêðûòûõ îðäåðîâ                                           
//+------------------------------------------------------------------------------------------------+

//+------------------------------------------------------------------------------------------------+
//| Åñëè îáùèé ïðîôèò ïî âñåì îòêðûòûì ïðåâûøàåò íàø óðîâåíü, äàåì ïðèêàç íà çàêðûòèå âñåõ îðäåðîâ                                           
//+------------------------------------------------------------------------------------------------+
if (totalprofit>ProfitLevel)
{
AllowTrade=false;
OrdersClose=true;
}
//+------------------------------------------------------------------------------------------------+
//| Ìîäóëü çàêðûòèÿ âñåõ îðäåðîâ                                           
//+------------------------------------------------------------------------------------------------+

//+------------------------------------------------------------------------------------------------+
//| Ìîäóëü çàêðûòèÿ âñåõ îðäåðîâ                                           
//+------------------------------------------------------------------------------------------------+
if (OrdersClose)
{
AllowTrade=false;
bool result=false;

for (cnt=OrdersTotal()-1;cnt>=0;cnt--)
{  
   if (((CurTime()-LastTrade)<10) || (LastTrade==0)) return (0);
   result=false;
   OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
   RefreshRates();
   {
      if ((OrderSymbol()==Symbol()) && (OrderType()==OP_BUY))
      {
         result=OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Bid,Digits),5,Yellow);  
         if (result){ LastTrade=CurTime();break; }
      }
      if ((OrderSymbol()==Symbol()) && (OrderType()==OP_SELL))
      {
         result=OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Ask,Digits),5,Blue );  
         if (result){ LastTrade=CurTime();break; }
      }
      if ((OrderSymbol()==Symbol()) && (OrderType()==OP_BUYSTOP) && (OrderMagicNumber()== magicNumber))
      {
         result=OrderDelete(OrderTicket());  
         if (result){ LastTrade=CurTime();break; }
      }   
      if ((OrderSymbol()==Symbol()) && (OrderType()==OP_SELLSTOP) && (OrderMagicNumber()== magicNumber))
      {
         result=OrderDelete(OrderTicket());  
         if (result){ LastTrade=CurTime();break; }
      }   
   
   }
}

if(result==false)
{
   Alert("Order " , OrderTicket() , " failed to close. Error:" , GetLastError() );
   Sleep(3000);
}   
}
//+------------------------------------------------------------------------------------------------+
//| Êîíåö ìîäóëÿ çàêðûòèÿ âñåõ îðäåðîâ                                           
//+------------------------------------------------------------------------------------------------+

//+------------------------------------------------------------------------------------------------+
//| Åñëè îðäåðîâ áîëüøå íå îñòàëîñü, ÷åðåç 5 ñåêóíä íà÷èíàåì òîðãîâëþ çàíîâî                                         
//+------------------------------------------------------------------------------------------------+
if (totalcountpos==0)
{
    OrdersClose=false;
    Sleep(5000);
    AllowTrade=true;
}
//+------------------------------------------------------------------------------------------------+
//|                                          
//+------------------------------------------------------------------------------------------------+
   
// Åñëè ñâîáîäíûé îñòàòîê ìåíüøå íåîáõîäèìîãî, òî âûõîäèì
if (AccountFreeMargin() < ((1000*Ask)*Lots)+100 ) 
{
Alert("Íåäîñòàòî÷íî äåíåã!");
return (0);
}
//+------------------------------------------------------------------------------------------------+
//| Ìîäóëÿ èíäèêàòîðà                                           
//+------------------------------------------------------------------------------------------------+
for (i = 0; i < 300; i++)   
{
   iFractals_up = iFractals(NULL, 0, MODE_UPPER, i);
   iFractals_lo = iFractals(NULL, 0, MODE_LOWER, i);
   if ((iFractals_up != 0) || (iFractals_lo != 0)) break;
}

// Íîâûé ìàêñèìóì ?
if ((iFractals_up != 0) && (Time[i] != prev_max) && (i < 3))
{
   OpenSell=true;prev_max = Time[i];
}
// Íîâûé ìèíèìóì ?
if ((iFractals_lo != 0) && (Time[i] != prev_min) && (i < 3))
{ 
   OpenBuy=true;prev_min = Time[i];
}   
//+------------------------------------------------------------------------------------------------+
//| Êîíåö ìîäóëÿ èíäèêàòîðà                                           
//+------------------------------------------------------------------------------------------------+

//+------------------------------------------------------------------------------------------------+
//| Îòêðûòèå îðäåðîâ                                          
//+------------------------------------------------------------------------------------------------+
if (OpenSell && AllowTrade)
{
   if ((CurTime()-LastTrade)<10) return (0);
   ticket=0;
   // Îòêðîåì îòëîæåííûé îðäåð.
   while (ticket==0)
   {
      RefreshRates();
      price = NormalizeDouble(High[i]+(limit*Point),Digits);
      SL    = price - StopLoss   * Point;
      TP    = price + TakeProfit * Point;      
      ticket=OrderSend(Symbol(), OP_BUYSTOP, Lots, price, 3, SL, TP, "OP_BUYSTOP", magicNumber, 0, Pink);
      Sleep(1000);
   }
   
   Sleep(10000);
      
   ticket=0;
   // Îòêðîåì îñíîâíîé îðäåð.
   while (ticket==0)
   {
      RefreshRates();
      SL = NormalizeDouble(Bid,Digits) + StopLoss   * Point;
      TP = NormalizeDouble(Bid,Digits) - TakeProfit * Point;
      ticket=OrderSend(Symbol(),OP_SELL,Lots,NormalizeDouble(Bid,Digits),3,SL,TP,"OP_SELL",magicNumber,0,Blue);   
      Sleep(1000);
   }
   LastTrade=CurTime();
   OpenSell=false;
}

if (OpenBuy && AllowTrade)
{
   if ((CurTime()-LastTrade)<10) return (0);
   ticket=0;
   // Îòêðîåì îòëîæåííûé îðäåð.
   while (ticket==0)
   {   
   RefreshRates();
   price = NormalizeDouble(Low[i]-(limit*Point),Digits);
   SL    = price + StopLoss   * Point;
   TP    = price - TakeProfit * Point;
   ticket=OrderSend(Symbol(), OP_SELLSTOP, Lots, price, 3, SL, TP, "OP_SELLSTOP", magicNumber, 0, SkyBlue);      
   Sleep(1000);
   }

   Sleep(10000);

   ticket=0;
   // Îòêðîåì îñíîâíîé îðäåð.
   while (ticket==0)
   {
   RefreshRates();
   SL = NormalizeDouble(Ask,Digits) - StopLoss   * Point;
   TP = NormalizeDouble(Ask,Digits) + TakeProfit * Point;
   ticket=OrderSend(Symbol(),OP_BUY,Lots,NormalizeDouble(Ask,Digits),3,SL,TP,"OP_BUY",magicNumber,0,Yellow);
   Sleep(1000);
   }
   LastTrade=CurTime();
   OpenBuy=false;
}
//+------------------------------------------------------------------------------------------------+
//| Êîíåö îòêðûòèÿ îðäåðîâ                                          
//+------------------------------------------------------------------------------------------------+

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

Profitability Reports

PERFORMANCE BY SYMBOL

Expected payoff

Average expected payoff across the available backtests for each symbol.

Positive Negative
15 reports
EUR/USD Jul 2025 - Sep 2025
44.48
Total Trades 1700
Won Trades 949
Lost trades 751
Win Rate 55.82 %
Expected payoff 743.12
Gross Profit 1292364.30
Gross Loss -29054.00
Total Net Profit 1263310.30
-100%
-50%
0%
50%
100%
EUR/USD Oct 2025 - Feb 2026
0.95
Total Trades 1937
Won Trades 1061
Lost trades 876
Win Rate 54.78 %
Expected payoff -0.80
Gross Profit 30484.20
Gross Loss -32029.50
Total Net Profit -1545.30
-100%
-50%
0%
50%
100%
AUD/USD Oct 2025 - Feb 2026
0.93
Total Trades 2027
Won Trades 1090
Lost trades 937
Win Rate 53.77 %
Expected payoff -1.29
Gross Profit 32414.90
Gross Loss -35023.50
Total Net Profit -2608.60
-100%
-50%
0%
50%
100%
USD/CAD Oct 2024 - Jan 2025
0.92
Total Trades 841
Won Trades 479
Lost trades 362
Win Rate 56.96 %
Expected payoff -0.99
Gross Profit 9635.46
Gross Loss -10465.94
Total Net Profit -830.48
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
0.92
Total Trades 1785
Won Trades 953
Lost trades 832
Win Rate 53.39 %
Expected payoff -1.43
Gross Profit 28904.30
Gross Loss -31451.80
Total Net Profit -2547.50
-100%
-50%
0%
50%
100%
USD/CHF Jul 2025 - Sep 2025
0.91
Total Trades 1682
Won Trades 912
Lost trades 770
Win Rate 54.22 %
Expected payoff -2.06
Gross Profit 33713.29
Gross Loss -37173.62
Total Net Profit -3460.33
-100%
-50%
0%
50%
100%
NZD/USD Jul 2025 - Sep 2025
0.87
Total Trades 1793
Won Trades 944
Lost trades 849
Win Rate 52.65 %
Expected payoff -2.29
Gross Profit 27673.20
Gross Loss -31777.10
Total Net Profit -4103.90
-100%
-50%
0%
50%
100%
GBP/AUD Oct 2025 - Feb 2026
0.82
Total Trades 1780
Won Trades 977
Lost trades 803
Win Rate 54.89 %
Expected payoff -2.50
Gross Profit 20195.40
Gross Loss -24650.36
Total Net Profit -4454.96
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
0.80
Total Trades 1660
Won Trades 898
Lost trades 762
Win Rate 54.10 %
Expected payoff -2.55
Gross Profit 16468.18
Gross Loss -20703.53
Total Net Profit -4235.35
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
0.77
Total Trades 931
Won Trades 491
Lost trades 440
Win Rate 52.74 %
Expected payoff -4.32
Gross Profit 13274.60
Gross Loss -17294.30
Total Net Profit -4019.70
-100%
-50%
0%
50%
100%
GBP/CAD Oct 2025 - Feb 2026
0.66
Total Trades 1840
Won Trades 928
Lost trades 912
Win Rate 50.43 %
Expected payoff -5.15
Gross Profit 18746.94
Gross Loss -28222.08
Total Net Profit -9475.14
-100%
-50%
0%
50%
100%
AUD/USD Oct 2024 - Jan 2025
0.65
Total Trades 822
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -7.12
Gross Profit 10831.60
Gross Loss -16684.40
Total Net Profit -5852.80
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
0.57
Total Trades 802
Won Trades 408
Lost trades 394
Win Rate 50.87 %
Expected payoff -9.44
Gross Profit 10132.70
Gross Loss -17705.60
Total Net Profit -7572.90
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
0.42
Total Trades 944
Won Trades 433
Lost trades 511
Win Rate 45.87 %
Expected payoff -10.36
Gross Profit 6975.27
Gross Loss -16759.62
Total Net Profit -9784.35
-100%
-50%
0%
50%
100%
USD/JPY Jul 2025 - Sep 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%

Comments