Author:
Profit factor:
1.96

Grizli Strategy Logic Overview

This document provides a non-technical explanation of the logic used by the "Grizli" trading script. The script is designed to automate trade execution based on price trends, momentum indicators, and risk management rules.


1. Core Trading Signal (The "When" to Trade)

The script determines whether to enter a trade by analyzing three distinct factors:

  • Trend Identification (Fractals): The system uses a mathematical indicator called "Fractals" to identify historical price peaks and valleys. It looks at these patterns across different timeframes (specifically the current chart and a 60-minute timeframe) to determine if the market is currently in an upward or downward trend.
  • Momentum Analysis (RSI): The script uses a Relative Strength Index (RSI) on a daily timeframe. It looks for "overextended" conditions—essentially checking if the price movement has become too strong or weak relative to its average.
  • Combined Signal:
    • A Buy signal is generated if the trend indicators show upward movement and the RSI indicates the market is sufficiently low.
    • A Sell signal is generated if the trend indicators show downward movement and the RSI indicates the market is sufficiently high.

2. Trade Management (The "How" to Manage Trades)

Once a trade is opened, the script monitors it using three specific rules:

  • Time Limit: If a trade remains open for longer than the pre-defined expiration time (set by the user), the script will automatically close the position.
  • Early Exit (Closeby): There is an optional "closeby" feature. If this is enabled, the script will close a Buy position early if the price turns downward, or close a Sell position early if the price turns upward, attempting to protect profits or limit losses during a trend reversal.
  • Automatic Targets: Every trade is assigned a fixed Take Profit (the target gain) and a Stop Loss (the maximum allowed loss) based on the user's input settings.

3. Dynamic Lot Sizing (Risk Management)

The script does not always trade the same amount of money; it calculates the size of each trade based on:

  • Account Balance: It looks at the available "Free Margin" in your trading account to determine how much capital is available for risk.
  • Risk Percentage: It calculates a position size based on a specific percentage of the account balance.
  • Loss Recovery (Lot Scaling): The script tracks your trading history. If it detects a string of recent losses, it applies a "Decrease Factor" to modify the lot size. This is intended to adjust the position sizing based on the most recent performance in the account history.

4. Execution Flow

  1. Time Check: The script only runs its logic once per minute (it checks if the current minute has changed).
  2. Status Scan: It first scans any existing open trades to see if they need to be closed due to time limits or trend reversals.
  3. Entry Scan: If no trade is currently open for this specific script, it calculates the signals.
  4. Execution: If a Buy or Sell signal is confirmed, it executes the trade immediately with the calculated lot size and predefined safety levels (Stop Loss and Take Profit).
Price Data Components
Series array that contains open time 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
FractalsRelative strength index
21 Views
1 Downloads
0 Favorites
ComFracti
//+------------------------------------------------------------------+
//|                                                  Grizli.mq4      |
//+------------------------------------------------------------------+
#property copyright ""
#property link      ""

//---- input parameters
extern double       tp1 = 700;
extern double       sl1 = 2500;
extern int          Expimin = 5555;
extern double       lots = 0.1;
extern double       Risk= 0.05;
extern double       multilot=1;
extern bool         closeby = false;
extern int          mn = 88;
static int          prevtime = 0;


extern int          sh2 = 3;
extern int          sh3 = 3;
extern int          sh4 = 3;
extern int          sh5 = 3;
extern int          levelb = 3;
extern int          levels = 3;

static double       sl = 10;
static double       tp = 10;

//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
   if (Time[0] == prevtime) return(0);
   prevtime = Time[0];
   
   if (! IsTradeAllowed()) {
      again();
      return(0);
   }
//----
   int total = OrdersTotal();
   for (int i = 0; i < total; i++) {
      OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == mn) {
      
      if(TimeCurrent()-OrderOpenTime()>=Expimin*60)
          {
             
              OrderClose(OrderTicket(),LotSize(),MarketInfo(Symbol(),MODE_BID),30,GreenYellow);

          }
          
           if(OrderType() == OP_BUY && psv()  < 0 && closeby )
          {
             
              OrderClose(OrderTicket(),LotSize(),MarketInfo(Symbol(),MODE_BID),30,GreenYellow);

          }
          if(OrderType() == OP_SELL && psv()  > 0 && closeby)
          {
             
              OrderClose(OrderTicket(),LotSize(),MarketInfo(Symbol(),MODE_BID),30,GreenYellow);

          }
         return(0);
      } 
   }
   
   sl = sl1;
   tp = tp1;
   
   int ticket = -1;
   
   RefreshRates();
   
   if (psv()  > 0) {
      ticket = OrderSend(Symbol(), OP_BUY, LotSize(), Ask, 30, Bid - sl * Point, Bid + tp * Point, WindowExpertName(), mn, 0, Blue); 
      if (ticket < 0) {
         again();      
      }
   } if (psv()  < 0) {
      ticket = OrderSend(Symbol(), OP_SELL, LotSize(), Bid, 30, Ask + sl * Point, Ask - tp * Point, WindowExpertName(), mn, 0, Red); 
      if (ticket < 0) {
         again();
      }
   }
//-- Exit --
   return(0);
}
//+--------------------------- getLots ----------------------------------+
      
 double LotSize2(){
   double lotMM = MathCeil(AccountFreeMargin() * Risk / 1000)/10;  
   if (lotMM < 0.1) lotMM = lots;
   if (lotMM > 1.0) lotMM = MathCeil(lotMM);
   if  (lotMM > 50) lotMM = 50;
   return (lotMM);  }
   
  double LotSize()
  {
  double DecreaseFactor=multilot;
  
   double lot=lots;
   int    orders=HistoryTotal();     // history orders total
   int    losses=0;                  // number of losses orders without a break
//---- select lot size
   lot=MathCeil(AccountFreeMargin() * Risk / 1000)/10;
//---- calcuulate number of losses orders without a break
   if(DecreaseFactor>0)
     {
      for(int i=orders-1;i>=0;i--)
        {
         if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false) { Print("Error in history!"); break; }
         if(OrderSymbol()!=Symbol() || OrderType()>OP_SELL) continue;
         //----
         if(OrderProfit()>0) break;
         if(OrderProfit()<0) losses++;
        }
      if(losses>0) lot=NormalizeDouble(lot-(-1)*lot*DecreaseFactor,1);
     }
//---- return lot size
   if(lot<0.1) lot=0.1;
   return(lot);
  }

 double Crof(int t , int s)
    
    
   {
     
   double frup = iFractals(NULL, t, MODE_UPPER, s);
   double frdw = iFractals(NULL, t, MODE_LOWER, s);
  // double frup2 = iFractals(NULL, t, MODE_UPPER, s2);
   //double frdw2 = iFractals(NULL, t, MODE_LOWER, s2);
  
    
    if ( (frup==0 ) && frdw!=0 ) return (1); //up trend|| High[1] > frup
    if ( (frdw==0 ) && frup!=0 ) return (-1); //down trend|| Low[1]  < frdw
   
    
     
     return (0); //elsewhere
   }    


 

 

      

double psv()   {

 
 double m6=iRSI(NULL, 1440, 3, PRICE_OPEN, 0);

   if ( Crof(0 , sh2)>0  && Crof(60 , sh3)>0  && m6<50-levelb ) return(1);
    
   if ( Crof(0 , sh4)<0  && Crof(60 , sh5)<0  && m6>50+levels ) return(-1);
      
      
   return(0);
  
}





void again() {
   prevtime = Time[1];
   Sleep(30000);
}

Profitability Reports

AUD/USD Jul 2025 - Sep 2025
9.87
Total Trades 5
Won Trades 4
Lost trades 1
Win Rate 80.00 %
Expected payoff 49.32
Gross Profit 274.40
Gross Loss -27.80
Total Net Profit 246.60
-100%
-50%
0%
50%
100%
USD/CHF Jul 2025 - Sep 2025
5.16
Total Trades 6
Won Trades 5
Lost trades 1
Win Rate 83.33 %
Expected payoff 49.80
Gross Profit 370.60
Gross Loss -71.82
Total Net Profit 298.78
-100%
-50%
0%
50%
100%
EUR/USD Jul 2025 - Sep 2025
4.46
Total Trades 6
Won Trades 5
Lost trades 1
Win Rate 83.33 %
Expected payoff 44.35
Gross Profit 343.00
Gross Loss -76.90
Total Net Profit 266.10
-100%
-50%
0%
50%
100%
AUD/USD Oct 2025 - Feb 2026
3.81
Total Trades 5
Won Trades 4
Lost trades 1
Win Rate 80.00 %
Expected payoff 42.76
Gross Profit 289.80
Gross Loss -76.00
Total Net Profit 213.80
-100%
-50%
0%
50%
100%
EUR/USD Oct 2025 - Feb 2026
1.33
Total Trades 9
Won Trades 6
Lost trades 3
Win Rate 66.67 %
Expected payoff 15.20
Gross Profit 548.80
Gross Loss -412.00
Total Net Profit 136.80
-100%
-50%
0%
50%
100%
GBP/CAD Oct 2025 - Feb 2026
1.18
Total Trades 14
Won Trades 11
Lost trades 3
Win Rate 78.57 %
Expected payoff 6.45
Gross Profit 592.42
Gross Loss -502.06
Total Net Profit 90.36
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
0.85
Total Trades 4
Won Trades 3
Lost trades 1
Win Rate 75.00 %
Expected payoff -7.05
Gross Profit 160.26
Gross Loss -188.45
Total Net Profit -28.19
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
0.68
Total Trades 12
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -26.67
Gross Profit 682.00
Gross Loss -1002.10
Total Net Profit -320.10
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
0.65
Total Trades 9
Won Trades 5
Lost trades 4
Win Rate 55.56 %
Expected payoff -20.14
Gross Profit 340.83
Gross Loss -522.09
Total Net Profit -181.26
-100%
-50%
0%
50%
100%
GBP/AUD Oct 2025 - Feb 2026
0.51
Total Trades 15
Won Trades 11
Lost trades 4
Win Rate 73.33 %
Expected payoff -34.82
Gross Profit 554.03
Gross Loss -1076.27
Total Net Profit -522.24
-100%
-50%
0%
50%
100%
GBP/USD Jul 2025 - Sep 2025
0.47
Total Trades 7
Won Trades 5
Lost trades 2
Win Rate 71.43 %
Expected payoff -57.03
Gross Profit 358.30
Gross Loss -757.50
Total Net Profit -399.20
-100%
-50%
0%
50%
100%
NZD/USD Jul 2025 - Sep 2025
0.33
Total Trades 2
Won Trades 1
Lost trades 1
Win Rate 50.00 %
Expected payoff -38.55
Gross Profit 38.30
Gross Loss -115.40
Total Net Profit -77.10
-100%
-50%
0%
50%
100%
USD/CAD Oct 2024 - Jan 2025
0.09
Total Trades 6
Won Trades 1
Lost trades 5
Win Rate 16.67 %
Expected payoff -155.97
Gross Profit 97.21
Gross Loss -1033.05
Total Net Profit -935.84
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
0.00
Total Trades 4
Won Trades 1
Lost trades 3
Win Rate 25.00 %
Expected payoff -279.80
Gross Profit 5.00
Gross Loss -1124.20
Total Net Profit -1119.20
-100%
-50%
0%
50%
100%
USD/JPY Jul 2025 - Sep 2025
0.00
Total Trades 11
Won Trades 11
Lost trades 0
Win Rate 100.00 %
Expected payoff 46.50
Gross Profit 511.49
Gross Loss 0.00
Total Net Profit 511.49
-100%
-50%
0%
50%
100%

Comments