MultiPairWPR

Download script
Author: WPR for Multi Pair, Copyright � 2005, Gary Hensley
Profit factor:
0.66

This automated trading tool is designed to manage and execute trades by analyzing a specific set of currency pairs to determine market sentiment. Instead of relying on a single chart, it gathers data from four primary currency pairs—GBPUSD, EURUSD, USDCHF, and USDJPY—to calculate a unified directional signal.

Core Logic and Strategy

1. Sentiment Analysis (BSI Calculation) The script monitors the Williams Percent Range (WPR) indicator across the four specified currency pairs. It looks for specific conditions where these currencies drop below a certain threshold. By combining these movements, the tool generates a "Trigger" value.

  • If the sentiment leans strongly in one direction based on these combined movements, it produces a Buy or Sell signal.
  • The logic also includes a "Pair Correction" feature: if you are trading a pair where the USD is not the base currency (e.g., an AUD/USD type scenario), the script automatically flips the signal to ensure it remains aligned with your specific trade direction.

2. Automated Trade Execution Once a clear signal is identified by the sentiment analysis, the tool manages the lifecycle of the trades:

  • Entry: If no trades are currently open and a signal appears, the script will automatically enter a new position at the current market price.
  • Exit: If there is already an active trade open, the script continuously monitors the sentiment. If the signal flips (for example, you have a "Buy" trade open but the sentiment shifts to a "Sell"), the tool will immediately close the existing position.

3. Dynamic Position Sizing The script includes a built-in calculator to determine how much capital to risk on each trade. You can set the software to calculate your lot sizes based on a percentage of your total account balance. It also features a safety cap to ensure that no single trade exceeds a maximum pre-defined lot size, helping to maintain disciplined risk management.

4. Real-Time Monitoring The tool provides a live "Comment" readout on the chart. This allows you to see the current direction of the market sentiment, the strength of the trigger, and the status of your active orders at a glance, ensuring transparency in how the script is making decisions.

Orders Execution
Checks for the total of open ordersIt Closes Orders by itself It automatically opens orders when conditions are reached
Indicators Used
Larry William percent range indicator
13 Views
0 Downloads
0 Favorites
MultiPairWPR
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+-----------------------------------------+
//|GH.mq4   WPR for Multi Pair              |
//|Copyright © 2005, Gary Hensley           |
//+-----------------------------------------+
//
//		Modifications                                                         
//		-------------                                                       
//		DATE       	MOD #    	DESCRIPTION                		        
//		---------- 	-------- 	---------------------------------------------------------------
//		01 Jul 2005 1   		   GaryH: Converted Original M3 version of MultiPairWPR script.

#property copyright "WPR for Multi Pair, Copyright © 2005, Gary Hensley"
//#property link      "http://www.metaquotes.net/"

#define MAGICMA  20050610

//---- input parameters
extern int       UsePct=0;
extern int       MaxLots=100;

//---- global variables
int bsi=0;
int dir=0;
int vTrig=0;
int openorders=0;
string pair;
double vSL=0,vTP=0;

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
   pair = Symbol();
   return(0);
  } 

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

//+------------------------------------------------------------------+
//| Calculate open positions                                         |
//+------------------------------------------------------------------+
int GetCurrentOrders()
  {
  //---- calc open OrderSelect
   openorders=0;
   dir=0;
   for(int i=0;i<OrdersTotal();i++)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
      //if(OrderSymbol()==Symbol() && OrderMagicNumber()==MAGICMA)
      if(OrderSymbol()==Symbol())
      {
        openorders+=1;
        if(OrderType()==OP_BUY) dir=1;
        if(OrderType()==OP_SELL) dir=-1;
      }  
   }
}

//+------------------------------------------------------------------+
//| Calculate Lot Sizes                                              |
//+------------------------------------------------------------------+
int LotCalc(double Risk)
  {
   int vLots=0;
   if (UsePct >0 && Risk>0) vLots=MathFloor(AccountBalance()*(UsePct/100)/((Risk/MarketInfo (Symbol(), MODE_POINT))*10));
   if (UsePct >0 && Risk==0)  vLots = MathFloor(AccountBalance()*(UsePct/100)/1000);
   if (vLots>MaxLots) vLots=MaxLots;
   if (vLots<1) vLots=1;
   return(vLots);
}

//+------------------------------------------------------------------+
//| Close Open Position                                              |
//+------------------------------------------------------------------+
int CloseTrade()
  { 
  for(int i=0;i<OrdersTotal();i++)
    {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false)        break;
      //if(OrderMagicNumber()!=MAGICMA || OrderSymbol()!=Symbol()) continue;
      if(OrderSymbol()==Symbol())
      {
        if(OrderType()==OP_BUY) OrderClose(OrderTicket(),OrderLots(),Bid,3,White);
        if(OrderType()==OP_SELL) OrderClose(OrderTicket(),OrderLots(),Ask,3,White);
      }  
  }
}

//+------------------------------------------------------------------+
//| Open Trade Position                                              |
//+------------------------------------------------------------------+
int OpenTrade()
  {
   int vLots=LotCalc(0);
   if (bsi>0) OrderSend(Symbol(),OP_BUY,vLots,Ask,3,0,0,0,0,Blue);
   if (bsi<0) OrderSend(Symbol(),OP_SELL,vLots,Bid,3,0,0,0,0,Red);
}

//+------------------------------------------------------------------+
//| Buy/Sell Indicator                                               |
//+------------------------------------------------------------------+
int CalcBSI()
  {
  //---- calc current indicators
  int GU_Trig=1,EU_Trig=1,UC_Trig=1,UJ_Trig=1;
  if (iWPR("GBPUSD",0,14,0)<-50) GU_Trig=-1;
  if (iWPR("EURUSD",0,14,0)<-50) EU_Trig=-1;
  if (iWPR("USDCHF",0,14,0)<-50) UC_Trig=-1;
  if (iWPR("USDJPY",0,14,0)<-50) UJ_Trig=-1;
  vTrig=GU_Trig+EU_Trig-UC_Trig-UJ_Trig;

  bsi=0;
  if (vTrig>2) bsi=1;
  if (vTrig<-2) bsi=-1;
  if (pair>"USD") bsi=bsi*(-1);

}

//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
  GetCurrentOrders();
  CalcBSI();
  Comment("Dir: ",dir,"\nBSI: ",bsi,"\nTrig: ",vTrig);
   
  //---- exit trades
  if (openorders!=0) {
     if ((bsi>0) && (dir<0)) CloseTrade();
     if ((bsi<0) && (dir>0)) CloseTrade();
  }   
  //---- open trades
  else {
   if (bsi!=0) OpenTrade();
  }   
}

Profitability Reports

PERFORMANCE BY SYMBOL

Expected payoff

Average expected payoff across the available backtests for each symbol.

Positive Negative
17 reports
USD/JPY Jul 2025 - Sep 2025
1.12
Total Trades 168
Won Trades 66
Lost trades 102
Win Rate 39.29 %
Expected payoff 12.51
Gross Profit 19730.04
Gross Loss -17628.21
Total Net Profit 2101.83
-100%
-50%
0%
50%
100%
GBP/AUD Oct 2025 - Feb 2026
0.97
Total Trades 252
Won Trades 111
Lost trades 141
Win Rate 44.05 %
Expected payoff -3.86
Gross Profit 33211.00
Gross Loss -34183.55
Total Net Profit -972.55
-100%
-50%
0%
50%
100%
EUR/USD Oct 2025 - Feb 2026
0.89
Total Trades 260
Won Trades 93
Lost trades 167
Win Rate 35.77 %
Expected payoff -9.99
Gross Profit 20732.00
Gross Loss -23329.00
Total Net Profit -2597.00
-100%
-50%
0%
50%
100%
USD/CAD Jul 2025 - Sep 2025
0.85
Total Trades 158
Won Trades 57
Lost trades 101
Win Rate 36.08 %
Expected payoff -9.22
Gross Profit 8052.39
Gross Loss -9508.99
Total Net Profit -1456.60
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
0.75
Total Trades 158
Won Trades 63
Lost trades 95
Win Rate 39.87 %
Expected payoff -29.82
Gross Profit 14107.15
Gross Loss -18818.01
Total Net Profit -4710.86
-100%
-50%
0%
50%
100%
NZD/USD Jul 2025 - Sep 2025
0.74
Total Trades 158
Won Trades 58
Lost trades 100
Win Rate 36.71 %
Expected payoff -21.83
Gross Profit 9935.00
Gross Loss -13384.00
Total Net Profit -3449.00
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
0.70
Total Trades 158
Won Trades 58
Lost trades 100
Win Rate 36.71 %
Expected payoff -25.22
Gross Profit 9456.00
Gross Loss -13441.00
Total Net Profit -3985.00
-100%
-50%
0%
50%
100%
AUD/USD Oct 2025 - Feb 2026
0.70
Total Trades 252
Won Trades 102
Lost trades 150
Win Rate 40.48 %
Expected payoff -25.85
Gross Profit 15368.00
Gross Loss -21883.00
Total Net Profit -6515.00
-100%
-50%
0%
50%
100%
GBP/USD Jul 2025 - Sep 2025
0.68
Total Trades 168
Won Trades 56
Lost trades 112
Win Rate 33.33 %
Expected payoff -43.68
Gross Profit 15353.00
Gross Loss -22691.00
Total Net Profit -7338.00
-100%
-50%
0%
50%
100%
USD/CHF Jul 2025 - Sep 2025
0.64
Total Trades 168
Won Trades 55
Lost trades 113
Win Rate 32.74 %
Expected payoff -41.30
Gross Profit 12200.87
Gross Loss -19139.30
Total Net Profit -6938.43
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
0.63
Total Trades 71
Won Trades 24
Lost trades 47
Win Rate 33.80 %
Expected payoff -50.73
Gross Profit 6104.00
Gross Loss -9706.00
Total Net Profit -3602.00
-100%
-50%
0%
50%
100%
GBP/CAD Oct 2025 - Feb 2026
0.61
Total Trades 196
Won Trades 65
Lost trades 131
Win Rate 33.16 %
Expected payoff -49.11
Gross Profit 15328.65
Gross Loss -24953.81
Total Net Profit -9625.16
-100%
-50%
0%
50%
100%
USD/CAD Oct 2024 - Jan 2025
0.59
Total Trades 71
Won Trades 26
Lost trades 45
Win Rate 36.62 %
Expected payoff -51.92
Gross Profit 5362.73
Gross Loss -9048.92
Total Net Profit -3686.19
-100%
-50%
0%
50%
100%
AUD/USD Oct 2024 - Jan 2025
0.53
Total Trades 71
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -70.61
Gross Profit 5561.00
Gross Loss -10574.00
Total Net Profit -5013.00
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
0.45
Total Trades 60
Won Trades 16
Lost trades 44
Win Rate 26.67 %
Expected payoff -160.43
Gross Profit 7733.00
Gross Loss -17359.00
Total Net Profit -9626.00
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
0.29
Total Trades 70
Won Trades 16
Lost trades 54
Win Rate 22.86 %
Expected payoff -137.51
Gross Profit 3964.01
Gross Loss -13589.68
Total Net Profit -9625.67
-100%
-50%
0%
50%
100%
EUR/USD Jul 2025 - Sep 2025
0.00
Total Trades 20
Won Trades 6
Lost trades 14
Win Rate 30.00 %
Expected payoff -52751.30
Gross Profit 1208.00
Gross Loss -1056234.00
Total Net Profit -1055026.00
-100%
-50%
0%
50%
100%

Comments