Author: xxx
Profit factor:
18.28

This automated trading script is designed to manage and execute trades based on trend analysis, price action signals, and dynamic risk management. It operates by monitoring the live market to identify specific entry points while automatically closing existing positions when certain technical conditions are met.

Automated Trade Management

The system begins by assessing your account's financial status to determine the appropriate position size. It offers two main methods:

  • Fixed Lot Sizing: A standard approach where every trade uses a pre-defined, constant amount of capital.
  • Dynamic Risk Management: A more sophisticated mode that calculates your trade size based on a percentage of your current account balance. This ensures that the volume traded is proportional to your available funds, helping to maintain consistent risk levels across different account sizes.

Trade Execution Logic

The script focuses on finding high-probability entries by combining two types of market data: moving averages (which indicate the general trend) and "highest/lowest" price points (which identify immediate price extremes).

For Buying Positions (Long):

  • The system looks for a "Bullish" trend, defined as a short-term fast average crossing above a longer-term slower average.
  • Simultaneously, it waits for the current price to drop to its lowest point over a specific recent period. This creates a "buy the dip" scenario where the script enters a trade only when the market shows strength but offers a temporary price discount.

For Selling Positions (Short):

  • The system looks for a "Bearish" trend, defined as a short-term fast average crossing below a longer-term slower average.
  • It then waits for the current price to rise to its highest point over a specific recent period. This allows the script to enter a trade on the "pullback," selling when the market is showing weakness but at a temporary peak.

Automated Exit Strategy

One of the primary functions of this script is its proactive exit logic. It continuously monitors any open positions to see if the market direction has shifted significantly:

  • For Buy Orders: If the price climbs above a recent high point, the script assumes the move may have peaked or changed character and will automatically close the position to secure the trade.
  • For Sell Orders: If the price drops below a recent low point, the script identifies this as a potential reversal and closes the sell position accordingly.

Safety Features

To protect your capital, every trade initiated by the system is automatically equipped with a "Stop Loss." This ensures that if a trade moves against your ожидания (expectations), the system will automatically exit the position at a pre-determined price point to limit potential losses.

Price Data Components
Series array that contains the highest prices of each barSeries array that contains the lowest prices of each bar
Orders Execution
Checks for the total of open ordersIt Closes Orders by itself It automatically opens orders when conditions are reached
Indicators Used
Moving average indicator
17 Views
0 Downloads
0 Favorites
TrendS
//+------------------------------------------------------------------+
//|                                                       TrendS.mq4 |
//|                                      Copyright © 2006, xxx |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "xxx"
#property link      "http://www.xxx.ru/"


extern double    LotsIfNoMM=0.1;
extern int       StopLoss=50;
extern int       Slip=5;
extern int       MM_Mode=0;
extern int       MM_Risk=40;

double Opentrades,orders,first,mode,Ilo,sym,b,tmp,GridCellPoint,OpenOrderStopLoss;
double b4signal,Signal,Triggerline,b4Triggerline,Nowsignal,NowTriggerline,sl,LastOpByExpert,LastBarChecked;
int cnt,cnt2,OpenPosition,notouchbar,PendingOrderTicket,OpenOrderTicket; 
bool test;


//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//---- 


//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
  
//return(0);
   
   //if ( ! IsTesting() ) Comment(" Trailingstop    ",  b, "\n","      Tick no. ", iVolume(NULL,0,0),"\n"," Lots    ",Ilo);


  

   if (MM_Mode < 0)  {
   Ilo = MathCeil(AccountBalance()*MM_Risk/10000)/10;
     if (Ilo > 100) {  
     Ilo = 100;  
     }
   } else {
   Ilo = LotsIfNoMM;
   }
   if (MM_Mode > 0)  
    {
   Ilo = MathCeil(AccountBalance()*MM_Risk/10000)/10;
    if (Ilo > 1)  
    {
    Ilo = MathCeil(Ilo);
    }
    if (Ilo < 1)  
    {
    Ilo = 1;
    }
    if (Ilo > 100)  
    {  
     Ilo = 100;  
     }
   }
 	      
Opentrades=0;
for (cnt=0;cnt<OrdersTotal();cnt++) 
   {
   if ( OrderSelect (cnt, SELECT_BY_POS) == false )  continue;
   if ( OrderSymbol()==Symbol()) 
      {
      Opentrades=Opentrades+1;
      }
   }

if (Opentrades!=0)
   {
   if (OrderType()==OP_BUY) 
      {
      if (Bid>=iHigh(Symbol(),0,Highest(Symbol(),0,MODE_HIGH,6,1)))
         {
         OrderClose(OrderTicket(),OrderLots(),Bid,Slip,Red); 
         Opentrades--;
         }
      }
      else if (OrderType()==OP_SELL)
      {
      if (Bid<=iLow(Symbol(),0,Lowest(Symbol(),0,MODE_LOW,6,1)))
         {
         OrderClose(OrderTicket(),OrderLots(),Ask,Slip,Red); 
         Opentrades--;
         }
      }
   }

if (Opentrades==0)
   {
   
   if (iMA(Symbol(),0,6,0,MODE_EMA,PRICE_CLOSE,1)>iMA(Symbol(),0,12,0,MODE_SMA,PRICE_CLOSE,1) && Bid<=iLow(Symbol(),0,Lowest(Symbol(),0,MODE_LOW,6,1)))
      {
      OrderSend(Symbol(),OP_BUY,Ilo,Ask,Slip,Ask-StopLoss*Point,0,"CP",0,0,Blue);
      }
      
   if (iMA(Symbol(),0,6,0,MODE_EMA,PRICE_CLOSE,1)<iMA(Symbol(),0,12,0,MODE_SMA,PRICE_CLOSE,1) && Bid>=iHigh(Symbol(),0,Highest(Symbol(),0,MODE_HIGH,6,1)))
      {
      OrderSend(Symbol(),OP_SELL,Ilo,Bid,Slip,Bid+StopLoss*Point,0,"CP",0,0,Blue);
      }
  
   }

   return(0);
  }


Profitability Reports

PERFORMANCE BY SYMBOL

Expected payoff

Average expected payoff across the available backtests for each symbol.

Positive Negative
17 reports
EUR/USD Jul 2025 - Sep 2025
304.72
Total Trades 648
Won Trades 93
Lost trades 555
Win Rate 14.35 %
Expected payoff 1300.65
Gross Profit 845594.30
Gross Loss -2775.00
Total Net Profit 842819.30
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
0.67
Total Trades 407
Won Trades 105
Lost trades 302
Win Rate 25.80 %
Expected payoff -1.24
Gross Profit 1004.60
Gross Loss -1510.00
Total Net Profit -505.40
-100%
-50%
0%
50%
100%
AUD/USD Oct 2024 - Jan 2025
0.65
Total Trades 344
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -1.49
Gross Profit 942.80
Gross Loss -1455.00
Total Net Profit -512.20
-100%
-50%
0%
50%
100%
NZD/USD Jul 2025 - Sep 2025
0.62
Total Trades 411
Won Trades 110
Lost trades 301
Win Rate 26.76 %
Expected payoff -1.39
Gross Profit 935.50
Gross Loss -1505.00
Total Net Profit -569.50
-100%
-50%
0%
50%
100%
GBP/USD Jul 2025 - Sep 2025
0.60
Total Trades 676
Won Trades 107
Lost trades 569
Win Rate 15.83 %
Expected payoff -1.69
Gross Profit 1703.30
Gross Loss -2845.00
Total Net Profit -1141.70
-100%
-50%
0%
50%
100%
USD/CAD Oct 2024 - Jan 2025
0.57
Total Trades 393
Won Trades 49
Lost trades 344
Win Rate 12.47 %
Expected payoff -1.33
Gross Profit 698.63
Gross Loss -1222.62
Total Net Profit -523.99
-100%
-50%
0%
50%
100%
USD/CAD Jul 2025 - Sep 2025
0.56
Total Trades 528
Won Trades 97
Lost trades 431
Win Rate 18.37 %
Expected payoff -1.32
Gross Profit 870.34
Gross Loss -1566.69
Total Net Profit -696.35
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
0.55
Total Trades 356
Won Trades 52
Lost trades 304
Win Rate 14.61 %
Expected payoff -1.91
Gross Profit 840.20
Gross Loss -1520.00
Total Net Profit -679.80
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
0.52
Total Trades 492
Won Trades 42
Lost trades 450
Win Rate 8.54 %
Expected payoff -2.21
Gross Profit 1163.90
Gross Loss -2250.00
Total Net Profit -1086.10
-100%
-50%
0%
50%
100%
USD/CHF Jul 2025 - Sep 2025
0.46
Total Trades 606
Won Trades 107
Lost trades 499
Win Rate 17.66 %
Expected payoff -2.77
Gross Profit 1430.56
Gross Loss -3110.15
Total Net Profit -1679.59
-100%
-50%
0%
50%
100%
USD/JPY Jul 2025 - Sep 2025
0.37
Total Trades 1263
Won Trades 90
Lost trades 1173
Win Rate 7.13 %
Expected payoff -2.00
Gross Profit 1453.22
Gross Loss -3980.88
Total Net Profit -2527.66
-100%
-50%
0%
50%
100%
GBP/CAD Oct 2025 - Feb 2026
0.26
Total Trades 2365
Won Trades 146
Lost trades 2219
Win Rate 6.17 %
Expected payoff -2.47
Gross Profit 2072.42
Gross Loss -7919.95
Total Net Profit -5847.53
-100%
-50%
0%
50%
100%
AUD/USD Oct 2025 - Feb 2026
0.14
Total Trades 2230
Won Trades 170
Lost trades 2060
Win Rate 7.62 %
Expected payoff -3.98
Gross Profit 1416.00
Gross Loss -10296.40
Total Net Profit -8880.40
-100%
-50%
0%
50%
100%
GBP/AUD Oct 2025 - Feb 2026
0.09
Total Trades 3149
Won Trades 44
Lost trades 3105
Win Rate 1.40 %
Expected payoff -3.16
Gross Profit 942.22
Gross Loss -10904.95
Total Net Profit -9962.73
-100%
-50%
0%
50%
100%
EUR/USD Oct 2025 - Feb 2026
0.04
Total Trades 2129
Won Trades 50
Lost trades 2079
Win Rate 2.35 %
Expected payoff -4.67
Gross Profit 461.50
Gross Loss -10394.60
Total Net Profit -9933.10
-100%
-50%
0%
50%
100%
GBP/AUD 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%
GBP/CAD 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