Profit factor:
1.09

Here's a breakdown of what the trading script does, explained without technical jargon:

This script is designed to automatically place buy or sell orders in the trading market based on a set of rules.

  1. Initialization and Memory:

    • The script starts by remembering the most recent market bar it analyzed. This helps it avoid re-analyzing the same data repeatedly.
  2. Order Management:

    • The script first checks if there are any existing open orders. If there aren't any, it proceeds to look for opportunities to open new ones.
  3. Opportunity Identification (Entry Logic):

    • Position Calculation:

      • The script calculates a number (OPEN_POS()) to determine possible entries.
      • It looks at the high, low, and closing prices of the most recent market bar.
      • It calculates the relative position of the close to the high and low.
      • If the closing price is relatively high, it returns 1, suggesting a possible buy. If relatively low, it returns -1, suggesting a possible sell.
    • VSA Consideration (Optional):

      • The script optionally uses a Volume Spread Analysis (vsa()) function to refine entry consideration.
      • The vsa() function looks at recent market volatility by calculating the difference between values of Average True Range over different timeframes, multiplied by input weights.
      • If VSA is enabled (mod_vsa = true), the script needs vsa() to return a positive value for a buy or a negative value for a sell.
    • Time Restriction:

      • The script has certain hours of the day where it will not place trades. This is controlled by the hh, hn, hb, hc, and n parameters.
  4. Order Placement:

    • If the calculated position suggests a buy (OPEN_POS() > 0), and the VSA, if enabled, confirms, and the current hour is not restricted, the script places a buy order.
    • If the calculated position suggests a sell (OPEN_POS() < 0), and the VSA, if enabled, confirms, and the current hour is not restricted, the script places a sell order.
  5. Order Parameters:

    • Lot Size: The script uses a specified lots size for each order.
    • Stop Loss: It sets a stop_loss to automatically close the order if the market moves against the trade by a certain amount.
    • Take Profit: It sets a take_profit to automatically close the order and secure profits if the market moves in the trade's favor by a certain amount.
    • Magic Number: It assigns a unique "magic number" to each trade so the script can identify and manage its own trades separately from any other trading activity. Buy orders use the MAGIC number, while sell orders use MAGIC+1.
Price Data Components
Series array that contains the lowest prices of each barSeries array that contains the highest prices of each barSeries array that contains close prices for each bar
Orders Execution
Checks for the total of open ordersIt automatically opens orders when conditions are reached
Indicators Used
Indicator of the average true range
10 Views
0 Downloads
0 Favorites
vsa_test

int MAGIC = 1234;

extern double  lots           =0.1;
extern double  hh          = 4;
extern double  hn          = 4;
extern double  hb          = 4;
extern double  hc          = 4;
extern double  n           = 4;
extern double  p          = 65;
extern double  stop_loss      = 1000;   //100 for 4 Digits 
extern double  take_profit    = 700;    //70
extern bool mod_vsa = false;
extern int v1 = 100;
extern int v2 = 100;
extern int v3 = 100;
extern int v4 = 100;
extern int p2 = 10;
int            last_bar       = 0;

int start(){
   if (last_bar == Bars) return(0);
   last_bar = Bars;
   if (OrdersTotal() <= 0 ){
 
    if( OPEN_POS()>0&&(!mod_vsa || vsa()>0)  
    && Hour()!=hh&& Hour()!=hn&& Hour()!=hb&& Hour()!=hc&& Hour()!=hb+n&& Hour()!=hc+n)OrderSend(Symbol(), OP_BUY, lots ,Ask, 3, Ask - stop_loss * Point, Bid + take_profit * Point, WindowExpertName(), MAGIC, 0, Blue);
         
    if( OPEN_POS()<0 &&(!mod_vsa || vsa()<0) 
    && Hour()!=hh&& Hour()!=hn&& Hour()!=hb&& Hour()!=hc&& Hour()!=hb+n&& Hour()!=hc+n)OrderSend(Symbol(), OP_SELL, lots ,Bid, 3, Bid + stop_loss * Point, Ask - take_profit * Point, WindowExpertName(), MAGIC+1, 0, Red);
   } 
   return(0);
}

  double OPEN_POS() 
  {
   
   
   double L = iLow(NULL, 0, 1);
   double H = iHigh(NULL, 0, 1);
   double C = iClose(NULL, 0, 1);
   
   
  
   if( ((H-C) / (H-L+0.00001))*100 > p  ) {    return(1); }  
   
                                                
  
 
   if( ((C-L) / (H-L+0.00001))*100 > p  ) {    return(-1);}
   
                                               
     return(0);
     
  }


double vsa()    {

  
  
   double w1 = v1 - 50;
   double w2 = v2 - 50;
   double w3 = v3 - 50;
   double w4 = v4 - 50;
   
   
   double a1 = (iATR(NULL,60,1,p2 *1) - iATR(NULL,60,1,p2 *2));
   double a2 = (iATR(NULL,60,1,p2 *2) - iATR(NULL,60,1,p2 *3));
   double a3 = (iATR(NULL,60,1,p2 *3) - iATR(NULL,60,1,p2 *4));
   double a4 = (iATR(NULL,60,1,p2 *4) - iATR(NULL,60,1,p2 *5));
   
   return(w1 * a1 + w2 * a2 + w3 * a3 + w4 * a4);
   
  
}  


Profitability Reports

USD/JPY Jul 2025 - Sep 2025
0.83
Total Trades 52
Won Trades 30
Lost trades 22
Win Rate 57.69 %
Expected payoff -4.62
Gross Profit 1204.79
Gross Loss -1445.04
Total Net Profit -240.25
-100%
-50%
0%
50%
100%
USD/CAD Jul 2025 - Sep 2025
2.79
Total Trades 11
Won Trades 9
Lost trades 2
Win Rate 81.82 %
Expected payoff 23.60
Gross Profit 404.84
Gross Loss -145.29
Total Net Profit 259.55
-100%
-50%
0%
50%
100%
NZD/USD Jul 2025 - Sep 2025
1.27
Total Trades 7
Won Trades 4
Lost trades 3
Win Rate 57.14 %
Expected payoff 8.29
Gross Profit 273.20
Gross Loss -215.20
Total Net Profit 58.00
-100%
-50%
0%
50%
100%
GBP/USD Jul 2025 - Sep 2025
2.26
Total Trades 31
Won Trades 24
Lost trades 7
Win Rate 77.42 %
Expected payoff 28.45
Gross Profit 1582.10
Gross Loss -700.00
Total Net Profit 882.10
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
1.19
Total Trades 32
Won Trades 20
Lost trades 12
Win Rate 62.50 %
Expected payoff 4.69
Gross Profit 947.64
Gross Loss -797.45
Total Net Profit 150.19
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
1.04
Total Trades 45
Won Trades 28
Lost trades 17
Win Rate 62.22 %
Expected payoff 1.03
Gross Profit 1168.20
Gross Loss -1121.80
Total Net Profit 46.40
-100%
-50%
0%
50%
100%
EUR/USD Jul 2025 - Sep 2025
0.83
Total Trades 37
Won Trades 20
Lost trades 17
Win Rate 54.05 %
Expected payoff -7.48
Gross Profit 1374.00
Gross Loss -1650.90
Total Net Profit -276.90
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
0.62
Total Trades 12
Won Trades 6
Lost trades 6
Win Rate 50.00 %
Expected payoff -18.44
Gross Profit 360.00
Gross Loss -581.30
Total Net Profit -221.30
-100%
-50%
0%
50%
100%
USD/JPY Jan 2025 - Jul 2025
0.87
Total Trades 156
Won Trades 87
Lost trades 69
Win Rate 55.77 %
Expected payoff -3.86
Gross Profit 4029.28
Gross Loss -4631.23
Total Net Profit -601.95
-100%
-50%
0%
50%
100%
USD/CHF Jan 2025 - Jul 2025
0.73
Total Trades 43
Won Trades 22
Lost trades 21
Win Rate 51.16 %
Expected payoff -15.02
Gross Profit 1761.89
Gross Loss -2407.71
Total Net Profit -645.82
-100%
-50%
0%
50%
100%

Comments