Profit factor:
0.91

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
7 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/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%
USD/CAD Jan 2025 - Jul 2025
1.03
Total Trades 68
Won Trades 41
Lost trades 27
Win Rate 60.29 %
Expected payoff 0.79
Gross Profit 1958.06
Gross Loss -1904.02
Total Net Profit 54.04
-100%
-50%
0%
50%
100%
GBP/USD Jan 2025 - Jul 2025
0.88
Total Trades 76
Won Trades 43
Lost trades 33
Win Rate 56.58 %
Expected payoff -5.09
Gross Profit 2859.50
Gross Loss -3246.10
Total Net Profit -386.60
-100%
-50%
0%
50%
100%
GBP/CAD Jan 2025 - Jul 2025
1.01
Total Trades 116
Won Trades 70
Lost trades 46
Win Rate 60.34 %
Expected payoff 0.29
Gross Profit 3355.89
Gross Loss -3321.92
Total Net Profit 33.97
-100%
-50%
0%
50%
100%
GBP/AUD Jan 2025 - Jul 2025
0.97
Total Trades 191
Won Trades 114
Lost trades 77
Win Rate 59.69 %
Expected payoff -0.69
Gross Profit 4973.11
Gross Loss -5104.14
Total Net Profit -131.03
-100%
-50%
0%
50%
100%
EUR/USD Jan 2025 - Jul 2025
0.73
Total Trades 113
Won Trades 58
Lost trades 55
Win Rate 51.33 %
Expected payoff -13.29
Gross Profit 3961.40
Gross Loss -5463.60
Total Net Profit -1502.20
-100%
-50%
0%
50%
100%
AUD/USD Jan 2025 - Jul 2025
1.37
Total Trades 41
Won Trades 27
Lost trades 14
Win Rate 65.85 %
Expected payoff 12.17
Gross Profit 1836.00
Gross Loss -1337.10
Total Net Profit 498.90
-100%
-50%
0%
50%
100%
USD/CAD Oct 2024 - Jan 2025
0.95
Total Trades 18
Won Trades 10
Lost trades 8
Win Rate 55.56 %
Expected payoff -1.53
Gross Profit 479.39
Gross Loss -506.97
Total Net Profit -27.58
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
1.17
Total Trades 30
Won Trades 19
Lost trades 11
Win Rate 63.33 %
Expected payoff 6.16
Gross Profit 1284.90
Gross Loss -1100.00
Total Net Profit 184.90
-100%
-50%
0%
50%
100%
GBP/CAD Oct 2024 - Jan 2025
0.62
Total Trades 53
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -11.39
Gross Profit 994.82
Gross Loss -1598.26
Total Net Profit -603.44
-100%
-50%
0%
50%
100%

Comments