newgrid_002

Download script
Author: Expert for tests
Profit factor:
0.02

This automated trading tool operates on a systematic "Grid Trading" logic. Instead of trying to predict market direction based on complex indicators, it focuses on capturing price movements within a predefined geographical range on the currency chart.

Core Operational Logic

1. The Grid Framework The script establishes a centered trading zone based on a specific price point (the RangeMid). From this center, it projects a series of "grid lines" in both directions (up and down). The distance between each of these lines is fixed by the user. This creates a structured map where the bot knows exactly at which price levels it should look to execute trades.

2. Trade Execution Strategy The bot constantly monitors the current market price. It looks for the price to touch any of the pre-defined grid lines:

  • Buy Orders: If the market price drops down to a lower grid line, the bot triggers a "Buy" position.
  • Sell Orders: If the market price rises up to an upper grid line, the bot triggers a "Sell" position.

By doing this, the system attempts to profit from market volatility—buying when the price hits a lower threshold and selling when it hits a higher one.

3. Safety and Volume Controls To ensure the account is not over-leveraged, the script includes several built-in safeguards:

  • Maximum Capacity: The user can set a limit on the total number of open trades. Once this limit is reached, the bot will stop opening new positions until existing ones are closed.
  • Take Profit: Every trade opened automatically includes a specific profit target (expressed in points). This ensures that once a trade moves favorably, it closes out to secure the gains.
  • Position Tracking: The script uses "Global Variables" to remember which grid lines have already been activated. This prevents the bot from repeatedly opening multiple trades on the exact same price point simultaneously.

4. User Feedback While running, the script provides a live status update directly on the trading screen. It displays the current trading range, identifies the very next price level it is watching for a trade, confirms the distance between grid lines, and alerts the user if the maximum trade capacity has been reached.

Orders Execution
Checks for the total of open ordersIt automatically opens orders when conditions are reached
3 Views
0 Downloads
0 Favorites
newgrid_002
#property copyright "Expert for tests"

extern double Lots = 0.1 ;
extern int max_trades = 10 ;
extern int grid_lines = 30 ;
extern double RangeMid = 1.5465 ;
extern double grid_separation = 0.0100 ;
extern double TP = 50 ;
extern int slip = 3 ;
   
int BarCount;
int Current;
bool TickCheck = False;
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init() {

   return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit() {
   return(0);
}
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start() {
 
   int Entertradebuy =0 ;
   int Entertradesell =0 ;
   double level ;
   
   if(OrdersTotal()==0)
   GlobalVariableSet("level", 0) ; 
   
    level=GlobalVariableGet("level") ;
   
   if(OrdersTotal()<max_trades)
   {
  for (int i = 1; i<grid_lines; i++)
   
   {
   if (Ask == RangeMid - grid_separation*i && level != RangeMid - grid_separation*i)
   {
   GlobalVariableSet("level", RangeMid - grid_separation*i) ;
   Entertradebuy=1 ;
   }
   if (Bid == RangeMid + grid_separation*i && level != RangeMid + grid_separation*i)
   {
   GlobalVariableSet("level", RangeMid + grid_separation*i) ;
   Entertradesell=1 ; 
   Print(i);
   }
   }
   }
  
   
   if(Entertradebuy==1)
   {
   double Ticket1 = OrderSend(Symbol(), OP_BUY, Lots, Ask, 5, 0, Ask+TP*Point, "Buy(#" + 1 + ")", 1, 0, DodgerBlue) ;         
   }
   
   
   if(Entertradesell==1)
   {
   double Ticket2 = OrderSend(Symbol(), OP_SELL, Lots, Bid, slip, 0, Bid-TP*Point, "Sell(#" + 1 + ")", 1, 0, DeepPink) ;
   }
   
for (i = 1; i<grid_lines; i++)
{
if(Ask - (RangeMid - grid_separation*i) < grid_separation && level != RangeMid - grid_separation*i)
GlobalVariableSet("next_level", RangeMid - grid_separation*i) ;
if(RangeMid + grid_separation*i - Bid < grid_separation && level != RangeMid + grid_separation*i)
GlobalVariableSet("next_level", RangeMid + grid_separation*i) ;
}

double next_level=GlobalVariableGet("next_level") ;

if(OrdersTotal() < max_trades)
Comment("I am trading a grid from ", RangeMid-grid_separation*grid_lines, " to ", RangeMid+grid_separation*grid_lines, "\n",
        "closest grid line to enter trade is ", next_level , "\n", 
        "distance between grid lines is ", grid_separation*10000, " pips", "\n",
        "number of grid lines is ", grid_lines, "\n",
        "maximum number of trades is ", max_trades, "\n",
        "TP is ", TP) ;     
        
if(OrdersTotal() >= max_trades)
Comment("I am full, I have ", max_trades, " positions opened");
        

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

Profitability Reports

PERFORMANCE BY SYMBOL

Expected payoff

Average expected payoff across the available backtests for each symbol.

Positive Negative
4 reports
GBP/USD Oct 2024 - Jan 2025
0.08
Total Trades 18
Won Trades 16
Lost trades 2
Win Rate 88.89 %
Expected payoff -49.88
Gross Profit 80.00
Gross Loss -977.80
Total Net Profit -897.80
-100%
-50%
0%
50%
100%
AUD/USD Oct 2024 - Jan 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%
NZD/USD Oct 2024 - Jan 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%
USD/CAD Oct 2024 - Jan 2025
0.00
Total Trades 38
Won Trades 38
Lost trades 0
Win Rate 100.00 %
Expected payoff 3.58
Gross Profit 136.18
Gross Loss 0.00
Total Net Profit 136.18
-100%
-50%
0%
50%
100%

Comments