Blessing 2 v5.0

Download script
Author: Copyright FiFtHeLeMeNt/J Talon LLC � 2007-2009, .
Profit factor:
2.60

Professional Logic Overview: Blessing 2 v5.0

This document provides a non-technical explanation of the operational logic used by the Blessing 2 v5.0 trading script. This script is an automated trading system designed to manage market positions using a grid-based strategy, integrated with sophisticated risk management and trend analysis.


1. Core Trading Strategy: Grid Management

The primary mechanism of this script is a "Grid" system. Instead of opening a single trade and hoping for the best, the script places multiple orders at specific intervals (the "Grid").

  • Dynamic Spacing: The distance between these orders is not always fixed. The script can automatically calculate the spacing based on market volatility (using the ATR indicator) or use predefined levels.
  • Tiered Execution: The system uses three distinct "Sets" of grid parameters. As the number of open positions increases, the script switches to wider grid spacings and larger profit targets to account for significant price swings.
  • Position Sizing: When the market moves against an initial position, the script opens subsequent orders. These subsequent lots are calculated using a multiplier (Hedge Multiplier) to increase the size of the trades, aiming to recover losses more quickly once the price reverses.

2. Market Analysis & Trend Detection

The script does not trade blindly; it attempts to understand the "environment" of the market:

  • Market Condition Monitoring: It identifies three main states: Uptrend, Downtrend, and Ranging (Sideways).
  • Moving Average Integration: It can use an Exponential Moving Average (EMA) to automatically determine the trend. If the price is above the EMA, it prioritizes "Long" (Buy) positions; if below, it prioritizes "Short" (Sell) positions.
  • Execution Bias: Depending on the detected condition, the script chooses whether to place "Limit" orders (waiting for the price to return to a specific level) or "Stop" orders (buying into a breakout).

3. Money Management & Risk Controls

A significant portion of the code is dedicated to preserving capital and managing the size of exposure:

  • Dynamic Lot Sizing: If enabled, the script calculates the number of lots to trade based on your account balance. It ensures that the trade size remains proportionate to the available funds.
  • Portioning: You can designate a specific "portion" of your total account balance for this specific pair, allowing you to isolate risk.
  • Equity Protection: This is a "fail-safe" mechanism. If the floating loss (unrealized loss) exceeds a pre-defined percentage of your account portion, the script will automatically close all open positions to prevent further depletion of funds.
  • Power Out Stop Loss: A unique feature that calculates a stop-loss distance based on the current volume of trades and the value of each pip. It dynamically "syncs" these stop-losses across all active orders.

4. Operational Safeguards

To ensure stability during high-frequency market activity, the script includes several "filters":

  • Time Grid: A mandatory cooling-off period between opening new grid levels. This prevents the script from opening an excessive number of trades in a split second during a flash crash or rapid price spike.
  • Slippage Tolerance: Defines the acceptable difference between the requested price and the executed price to ensure orders are filled correctly.
  • Maximum Levels & Break-Even: The script has a hard limit on how many grid levels it will open. Additionally, it features a "Break-Even" level where it can automatically close all positions if a certain number of levels are reached (prioritizing capital preservation over maximizing profit).

5. Summary of Workflow

  1. Analyze: The script checks the trend via Moving Averages and determines the market condition.
  2. Calculate: It determines the appropriate lot size based on your balance and identifies the next "Grid" point.
  3. Execute: It places a Buy or Sell order (Limit/Stop) based on the spacing rules.
  4. Monitor: As prices move, it either manages existing trades (adjusting Take Profits to stay synchronized) or opens new grid levels with increased lot sizes.
  5. Protect: Constantly monitors equity; if losses hit the safety threshold, it closes everything to protect the remaining balance.
Orders Execution
Checks for the total of open ordersIt can change open orders parameters, due to possible stepping strategyIt Closes Orders by itself It automatically opens orders when conditions are reached
Indicators Used
Indicator of the average true rangeMoving average indicator
Miscellaneous
It plays sound alertsIt opens Message Boxes to the user
23 Views
1 Downloads
0 Favorites
Blessing 2 v5.0
//+------------------------------------------------------------------+
//|                                                  Blessing 2 v5.0 |
//|                              Copyright © 2007-2008, MQLCoder.com |
//|                          jta@jtatoday.com , support@mqlcoder.com |
//+------------------------------------------------------------------+
#property copyright "Copyright FiFtHeLeMeNt/J Talon LLC © 2007-2009, ."
#property link      "http://www.mqlcoder.com"
#define  NL    "\n"

extern string  InitialAccountSet   = "Initial account balance";
extern int     InitialAccount      = 2500; 

extern string  TradeComment        = "Blessing";

extern string  NumberPortionSet    = "Account Portion";
extern int     Portion             = 1;    // Portion of account you want to trade on this pair

extern bool    UseEquityProtection = true; // Close all orders when negative Float is excessive.
extern double  FloatPercent        = 50;   // Percent of portion for max Float level.
extern bool    UsePowerOutSL       = false;   

extern bool    UseMM               = 1;    // Money Management - 1 = true & 0 = false.

extern string  LotAdjustmentSet    = "Only with MM enabled. (.01 - 5.0)";
extern double  LAF                 = 1.0;  // Adjusts MM base lot for large accounts

extern string  AccountTypeSet      = "1=standard, 10=micro for penny/pip)";
extern int     Accounttype         = 1;    // Used in Money Management feature only.

extern string  ManuallotSet        = "Lots used if MM is off";
extern double  lot                 = 0.01; // Starting lots if Money Management is off

extern string  LotHedgeSet         = "Hedge Multiplier.  Adjust by +/-.01 intervals ";
extern double  Multiplier          = 1.4;  // Multiplier on each level

extern string  AutoParametersSet   = "Autocalculates the Grid based on ATR";
extern bool    AutoCal             = false; // Auto calculation of TakeProfit and Grid size;

extern string  AutoGridAdjust      = "Widens/squishes grid (.5 - 3.0)";
extern double  GAF                 = 1.0;  // Widens/Squishes Grid on increments/decrements of .1

extern string  GridSet             = "Default Grid size in Pips";
extern int     GridSet1            = 25;   // Set 1 Grid Size
extern int     TP_Set1             = 50;   // Set 1 Take Profit
extern int     GridSet2            = 50;   // Level 2 Grid Size
extern int     TP_Set2             = 100;  // Level 2 Take Profit
extern int     GridSet3            = 100;  // Level 3 Grid Size
extern int     TP_Set3             = 200;  // Level 3 Take Profit

extern string  TimeGridSet         = "Default grid set time in seconds";
extern int     TimeGrid            = 2400; // Time Grid in seconds , to avoid opening of lots of levels in fast market

extern string  MarketConditionSet  = "Set MC to 2 for Ranging Market";
extern int     MC                  = 2;    // Market condition 0=uptrend 1=downtrend 2=range

extern string  MovingAverageSet    = "Changes MC for correct trend (up/down)";
extern bool    MCbyMA              = true; // Defines market condition by EMA , if price is above EMA,
                                           // it will take it as an uptrend and goes only long,
                                           // vice versa for below the EMA
extern int     MA_Period           = 100;   // Period of MA

extern string  MaxLevelSet         = "Default of 4 on each level, change sparingly";
extern int     Set1Count           = 4;    // Level 1 max levels
extern int     Set2Count           = 4;    // Level 2 max levels
extern int     MaxLevel            = 99;   // Level 2 max levels (stops placing orders when reaches maxlvl2)
extern int     BELevel             = 12;   // Close All level , when reaches this level, doesn't wait for TP to be hit

extern int     slippage            = 5.0; // Tolerance of order slips/requotes for closing

//+------------------------------------------------------------------+
//| Internal Parameters Set                                          |
//+------------------------------------------------------------------+

bool           ca                  = false;
string         EA_name             = "Blessing © FiFtHeLeMeNt/J Talon LLC";
int            magic               = 0;
double         slip                = 0;       
int            d                   = 5;      // Used to offset entry to round numbers , for example if you set d=5,
                                             // it will place its sell order on 1.5795 instead of 1.5780
double         LotInc              = 0;      // Lot Increment on each level, very dangerous
string         Filename;
int            BrokerDecimal       = 1;
string         POSL_On             = "No";
int            count;

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+

int init()
  {
   if (Symbol() == "AUDCADm" || Symbol() == "AUDCAD") magic = 101101;
   if (Symbol() == "AUDJPYm" || Symbol() == "AUDJPY") magic = 101102;
   if (Symbol() == "AUDNZDm" || Symbol() == "AUDNZD") magic = 101103;
   if (Symbol() == "AUDUSDm" || Symbol() == "AUDUSD") magic = 101104;
   if (Symbol() == "CHFJPYm" || Symbol() == "CHFJPY") magic = 101105;
   if (Symbol() == "EURAUDm" || Symbol() == "EURAUD") magic = 101106;
   if (Symbol() == "EURCADm" || Symbol() == "EURCAD") magic = 101107;
   if (Symbol() == "EURCHFm" || Symbol() == "EURCHF") magic = 101108;
   if (Symbol() == "EURGBPm" || Symbol() == "EURGBP") magic = 101109;
   if (Symbol() == "EURJPYm" || Symbol() == "EURJPY") magic = 101110;
   if (Symbol() == "EURUSDm" || Symbol() == "EURUSD") magic = 101111;
   if (Symbol() == "GBPCHFm" || Symbol() == "GBPCHF") magic = 101112;
   if (Symbol() == "GBPJPYm" || Symbol() == "GBPJPY") magic = 101113;
   if (Symbol() == "GBPUSDm" || Symbol() == "GBPUSD") magic = 101114;
   if (Symbol() == "NZDJPYm" || Symbol() == "NZDJPY") magic = 101115;
   if (Symbol() == "NZDUSDm" || Symbol() == "NZDUSD") magic = 101116;
   if (Symbol() == "USDCHFm" || Symbol() == "USDCHF") magic = 101117;
   if (Symbol() == "USDJPYm" || Symbol() == "USDJPY") magic = 101118;
   if (Symbol() == "USDCADm" || Symbol() == "USDCAD") magic = 101119;
   
   if (magic == 0) magic = 701999;
   
   if(Digits==3 || Digits==5) BrokerDecimal = 10;
   
   Filename = StringConcatenate(EA_name+"_",Symbol(),"_",Period(),"_M",".txt");
   
   return(0);
  }

//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+

int deinit()
  {
//----
   
//----
   return(0);
  }

//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+

int start()
  {
   int y;
   int cb=0; // Count buy
   int cs=0; // Count sell
   int cbl=0; // Count buy limit
   int csl=0; // Count sell limit
   int cbs=0; // Count buy limit
   int css=0; // Count sell limit
   double tbl=0; //Count lot size
   double tsl=0; //Count lot size
   double tl=0; //total lots out
   double to=0; //total buy and sell order out
   double buysl=0; //stop losses are set to zero if POSL off
   double sellsl=0; //stop losses are set to zero if POSL off
   double POSL=0; //Initialize POSL
   double m,lot2;
   double lp; // last buy price
   double ll; //last lot
   double ltp; //last tp
   double lopt; // last open time
   double g2;
   double tp2;
   double entry;
   double pr=0; // profit;
   double sumlot;
   int lticket;
   double mp,mp2; // median price
  
//+------------------------------------------------------------------+
//| Calculate Total Profits and Total Orders                         |
//+------------------------------------------------------------------+ 

for (y = 0; y < OrdersTotal(); y++)
   {
      OrderSelect (y, SELECT_BY_POS, MODE_TRADES);
      if ((OrderMagicNumber()==magic) && (OrderSymbol()==Symbol()) && (OrderType()==OP_BUY)) {
        cb++;
        pr=pr+OrderProfit();
        tbl=tbl+OrderLots();
      }
      if ((OrderMagicNumber()==magic) && (OrderSymbol()==Symbol()) && (OrderType()==OP_SELL)) {
        cs++;
        pr=pr+OrderProfit();
        tsl=tsl+OrderLots();
      }
      if ((OrderMagicNumber()==magic) && (OrderSymbol()==Symbol()) && (OrderType()==OP_BUYLIMIT)) cbl++;
      if ((OrderMagicNumber()==magic) && (OrderSymbol()==Symbol()) && (OrderType()==OP_SELLLIMIT)) csl++;
      if ((OrderMagicNumber()==magic) && (OrderSymbol()==Symbol()) && (OrderType()==OP_BUYSTOP)) cbs++;
      if ((OrderMagicNumber()==magic) && (OrderSymbol()==Symbol()) && (OrderType()==OP_SELLSTOP)) css++;
      tl=tbl+tsl;
      to=cb+cs;
   }
//+------------------------------------------------------------------+
//| Account Protection                                               |
//+------------------------------------------------------------------+ 

if(UseEquityProtection) EquityProtection(NormalizeDouble(pr,0));

//+------------------------------------------------------------------+
//| Trading with EA Criteria                                         |
//+------------------------------------------------------------------+

double PortionBalancetrade, InitialAccountMultiPortion;
PortionBalancetrade = NormalizeDouble(AccountBalance()/Portion,0);
InitialAccountMultiPortion = InitialAccount/Portion;

if (PortionBalancetrade < InitialAccountMultiPortion){ 

//+------------------------------------------------------------------+
//| Alert for Account Balance below Initial Balance                  |
//+------------------------------------------------------------------+

  PlaySound("alert.wav"); 
  MessageBox( "Account Balance is less than Initial Account Balance on " + Symbol()+ Period(), "Blessing 2: Warning", 48 );

return(0);}

//+------------------------------------------------------------------+
//| Power Out Stop Loss Protection                                   |
//+------------------------------------------------------------------+ 

  if(UsePowerOutSL) {
     
     POSL_On = "Yes";
     int correct = 1;
     double pipvalue=MarketInfo(Symbol(),MODE_TICKVALUE);
     if(Accounttype == 1 && pipvalue < 5) correct = 10;
     if(tl == 0){
       POSL = 600;
       if(Digits==3 || Digits==5) POSL = POSL * 10;
       buysl = Ask - POSL * Point;
       sellsl= Bid + POSL * Point;
       }
     if(tl > 0){
       POSL =  NormalizeDouble((PortionBalancetrade * (FloatPercent + 1)/100)/(pipvalue * tl * correct),0);
       if(POSL > 600) POSL = 600;
       if(Digits==3 || Digits==5) POSL = POSL * 10;
       buysl = Ask - POSL * Point;
       sellsl= Bid + POSL * Point;}
       
     if(to == 0) count = 0;
     if(to > 0 && to > count){
     
     // sync up order stop losses
     for (int q = 0; q < OrdersTotal(); q++) {
        OrderSelect (q, SELECT_BY_POS, MODE_TRADES);
        if ((OrderMagicNumber()==magic) && (OrderSymbol()==Symbol()) && (OrderType()==OP_BUY)) {
            OrderModify(OrderTicket(), OrderOpenPrice(), buysl, OrderTakeProfit(), 0, Purple);
        }
        if ((OrderMagicNumber()==magic) && (OrderSymbol()==Symbol()) && (OrderType()==OP_SELL)) {
            OrderModify(OrderTicket(), OrderOpenPrice(), sellsl, OrderTakeProfit(), 0, Purple);} } } 
        count = to;
     }

//+------------------------------------------------------------------+
//| Money Management and Lot size coding                             |
//+------------------------------------------------------------------+
   
if(UseMM){

double Contracts, Factor, Lotsize;

          Contracts = (AccountBalance()/10000)/Portion;
          Factor    = Multiplier+
                MathPow(Multiplier,2)+
                MathPow(Multiplier,3)+
                MathPow(Multiplier,4)+
                MathPow(Multiplier,5)+
                MathPow(Multiplier,6);

          Lotsize=LAF*Accounttype*(Contracts/(1.0 + Factor));

    //Determine Lot size boundries from minimum to maximum

          lot=NormalizeDouble(Lotsize,2);

          if(Lotsize<0.01) lot=0.01;
          if(Lotsize>100/MathPow(Multiplier,6) && Accounttype == 1) lot=NormalizeDouble(100/MathPow(Multiplier,6),2);
          if(Lotsize>50/MathPow(Multiplier,6)  && Accounttype == 10) lot=NormalizeDouble(50/MathPow(Multiplier,6),2);
}

//+------------------------------------------------------------------+
//| ATR to autocalculate the Grid                                    | 
//+------------------------------------------------------------------+     

double GridStart,value1;
double atrvalue = iATR(NULL,PERIOD_D1,21,0);
    if(AutoCal==True){
      if(Digits == 2 || Digits == 3) value1 = atrvalue*100;
      if(Digits == 4 || Digits == 5) value1 = atrvalue*10000;
      GridStart = value1*2/10;
      GridSet1  = GridStart;
      TP_Set1   = GridStart + GridSet1;
      GridSet2  = TP_Set1;
      TP_Set2   = (GridStart + GridSet1) * 2;
      GridSet3  = TP_Set2;
      TP_Set3   = (GridStart + GridSet1) * 4;}       
 
//+------------------------------------------------------------------+
//| Moving Average Indicator for Calculation of Trend Direction      |
//+------------------------------------------------------------------+      

if (MCbyMA) {
     MC=-1;
     if (Bid<iMA(Symbol(),0,MA_Period,0,MODE_EMA,PRICE_CLOSE,0)) MC=1;
     if (Bid>iMA(Symbol(),0,MA_Period,0,MODE_EMA,PRICE_CLOSE,0)) MC=0;}

//+------------------------------------------------------------------+
//| Blessing Code!                                                   |
//+------------------------------------------------------------------+   
   
if (cs==0 && cb==0 && cbs==0 && cbl==0 && css==0 && csl==0) ca=false;
   
   
   
   slip = NormalizeDouble((slippage * BrokerDecimal),0);
  
   if (((cb>=BELevel || cs>=BELevel) && pr>0) || ca) {
     ca=true;
     for (y = 0; y < OrdersTotal(); y++)
     {
       OrderSelect (y, SELECT_BY_POS, MODE_TRADES);
       if ((OrderMagicNumber()==magic) && (OrderSymbol()==Symbol()) && (OrderType()==OP_BUY || OrderType()==OP_SELL)) OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),slip,Lime);
       if ((OrderMagicNumber()==magic) && (OrderSymbol()==Symbol()) && (OrderType()==OP_BUYLIMIT || OrderType()==OP_SELLLIMIT || OrderType()==OP_BUYSTOP || OrderType()==OP_SELLSTOP)) OrderDelete(OrderTicket(),White);
     }
     return;
   }

      d = d;
      if (BrokerDecimal == 10) d=50;
      g2=GridSet1;
      tp2=TP_Set1;

   if (cb>=Set1Count || cs>=Set1Count) {
     g2=GridSet2;
     tp2=TP_Set2;
   }

   if (cb>=Set2Count+Set1Count || cs>=Set2Count+Set1Count) {
     g2=GridSet3;
     tp2=TP_Set3;
   }
   
//+------------------------------------------------------------------+
//| Broker Decimal Selection                                         |
//+------------------------------------------------------------------+ 

  if (BrokerDecimal == 10){
     g2 *= 10;
     tp2 *= 10;}

//+------------------------------------------------------------------+
//| Adjust Grid and Normalize Values                                 |
//+------------------------------------------------------------------+

  g2  = NormalizeDouble(g2*GAF,0);
  tp2 = NormalizeDouble(tp2*GAF,0);
  
//+------------------------------------------------------------------+
//| Trade Selection Logic                                            |
//+------------------------------------------------------------------+ 

   if ((cb==0) && (cs==0)) {
     for (y = 0; y < OrdersTotal(); y++)
     {
       OrderSelect (y, SELECT_BY_POS, MODE_TRADES);
       if ((OrderMagicNumber()==magic) && (OrderSymbol()==Symbol()) && (OrderLots()>lot)) OrderDelete(OrderTicket());
     }


     if (MC==0) {
        if (cbs==0) {
          m=MathMod(Ask/Point,g2);
          if ((g2-m+d)>MarketInfo(Symbol(),MODE_STOPLEVEL)) {
            OrderSend(Symbol(),OP_BUYSTOP,lot,Ask*2-Bid+(g2-m+d)*Point,0,buysl,Ask*2-Bid+(g2-m+d+tp2)*Point,TradeComment,magic,0,CLR_NONE);
            Print("s2");
            return;
          }
        }
        if (cbl==0) {
          m=MathMod(Ask/Point,g2);
          if ((m+d)>MarketInfo(Symbol(),MODE_STOPLEVEL)) {
            OrderSend(Symbol(),OP_BUYLIMIT,lot,Ask*2-Bid-(m+d)*Point,0,buysl,Ask*2-Bid-(m+d-tp2)*Point,TradeComment,magic,0,CLR_NONE);
            Print("s1");
            return;
          }
        }
     }

     if (MC==1) {
        if (csl==0) {
          m=MathMod(Bid/Point,g2);
          if ((g2-m-d)>MarketInfo(Symbol(),MODE_STOPLEVEL)) {
            OrderSend(Symbol(),OP_SELLLIMIT,lot,Bid+(g2-m-d)*Point,0,sellsl,Bid+(g2-m-d-tp2)*Point,TradeComment,magic,0,CLR_NONE);
            Print("s2");
            return;
          }
        }
        if (css==0) {
          m=MathMod(Bid/Point,g2);
          if ((m+d)>MarketInfo(Symbol(),MODE_STOPLEVEL)) {
            OrderSend(Symbol(),OP_SELLSTOP,lot,Bid-(m+d)*Point,0,sellsl,Bid-(m+d+tp2)*Point,TradeComment,magic,0,CLR_NONE);
            Print("s1");
            return;
          }
        }
     }
        
     
     if (MC==2) {
        if (css==0) {
          m=MathMod(Bid/Point,g2);
          if ((m+d)>MarketInfo(Symbol(),MODE_STOPLEVEL)) {
            OrderSend(Symbol(),OP_SELLSTOP,lot,Bid-(m+d)*Point,0,sellsl,Bid-(m+d+tp2)*Point,TradeComment,magic,0,CLR_NONE);
            Print("s1");
            return;
          }
        }
        if (cbs==0) {
          m=MathMod(Ask/Point,g2);
          if ((g2-m+d)>MarketInfo(Symbol(),MODE_STOPLEVEL)) {
            OrderSend(Symbol(),OP_BUYSTOP,lot,Ask*2-Bid+(g2-m+d)*Point,0,buysl,Ask*2-Bid+(g2-m+d+tp2)*Point,TradeComment,magic,0,CLR_NONE);
            Print("s2");
            return;
          }
        }
      }

   }

   if (cb>0 || cs>0) {
     for (y = 0; y < OrdersTotal(); y++)
     {
        OrderSelect (y, SELECT_BY_POS, MODE_TRADES);
        if ((OrderMagicNumber()==magic) && (OrderSymbol()==Symbol()) && (OrderType()!=OP_SELL) && (OrderType()!=OP_BUY) && OrderLots()==lot) OrderDelete(OrderTicket());
     }
   }
   
   
   if (cb>0) {
     sumlot=0;
     mp=0;
     for (y = 0; y < OrdersTotal(); y++)
     {
       OrderSelect (y, SELECT_BY_POS, MODE_TRADES);
       if ((OrderMagicNumber() != magic) || (OrderType()!=OP_BUY) || (OrderSymbol()!=Symbol())) { continue; }
       lp=OrderOpenPrice();
       ll=OrderLots();
       ltp=OrderTakeProfit();
       lopt=OrderOpenTime();
       lticket=OrderTicket();
       sumlot=sumlot+ll;
       mp=mp+ll*lp;
     }
     mp=mp/sumlot;
     

       if ((TimeCurrent()-TimeGrid>lopt) && (cb<MaxLevel)) {
         if (lp>Ask) entry=NormalizeDouble(lp-(MathRound((lp-Ask)/Point/g2)+1)*g2*Point,Digits); else entry=NormalizeDouble(lp-g2*Point,Digits);
         if (ll <= 0.01) lot2=NormalizeDouble(ll*2+LotInc,2); else lot2=NormalizeDouble(ll*Multiplier+LotInc,2);
         
         if (cbl==0) {
           OrderSend(Symbol(),OP_BUYLIMIT,lot2,entry,0,buysl,entry+tp2*Point,TradeComment,magic);
           Print("s3");
           return;
         }

         if (cbl==1) {
           for (y = 0; y < OrdersTotal(); y++)
           {
              OrderSelect (y, SELECT_BY_POS, MODE_TRADES);
              if (OrderType()==OP_BUYLIMIT && OrderMagicNumber()==magic && (OrderSymbol()==Symbol()) && entry-OrderOpenPrice()>g2/2*Point) {
                OrderModify(OrderTicket(),entry,buysl,entry+tp2*Point,0);
                Print("mo1");
              }
            }
         }
         
       } 


     for (y = 0; y < OrdersTotal(); y++) // Sync TPs
     {
       OrderSelect (y, SELECT_BY_POS, MODE_TRADES);
       if ((OrderMagicNumber() != magic) || (OrderType()!=OP_BUY) || (MathAbs(OrderTakeProfit()-ltp)<Point) || (OrderSymbol()!=Symbol())) { continue; }
       OrderModify(OrderTicket(),OrderOpenPrice(),buysl,ltp,0,Blue);
       Print("m1");
       return;
     }
     
   }

   if (cs>0) {
     sumlot=0;
     mp=0;
     for (y = 0; y < OrdersTotal(); y++)
     {
       OrderSelect (y, SELECT_BY_POS, MODE_TRADES);
       if ((OrderMagicNumber() != magic) || (OrderType()!=OP_SELL) || (OrderSymbol()!=Symbol())) { continue; }
       lp=OrderOpenPrice();
       ll=OrderLots();
       ltp=OrderTakeProfit();
       lopt=OrderOpenTime();
       lticket=OrderTicket();
       sumlot=sumlot+ll;
       mp=mp+ll*lp;
     }
     mp=mp/sumlot;
     

       if ((TimeCurrent()-TimeGrid>lopt) && (cs<MaxLevel)) {

         if (Bid>lp) entry=NormalizeDouble(lp+(MathRound((-lp+Bid)/Point/g2)+1)*g2*Point,Digits); else entry=NormalizeDouble(lp+g2*Point,Digits);
         if (ll <= 0.01) lot2=NormalizeDouble(ll*2+LotInc,2); else lot2=NormalizeDouble(ll*Multiplier+LotInc,2);
         
         if (csl==0) {
            OrderSend(Symbol(),OP_SELLLIMIT,lot2,entry,0,sellsl,entry-tp2*Point,TradeComment,magic);
            Print("s4");
            return;
         }

         if (csl==1) {
           for (y = 0; y < OrdersTotal(); y++)
           {
              OrderSelect (y, SELECT_BY_POS, MODE_TRADES);
              if (OrderType()==OP_SELLLIMIT && OrderMagicNumber()==magic && (OrderSymbol()==Symbol()) && OrderOpenPrice()-entry>g2/2*Point) {
                OrderModify(OrderTicket(),entry,sellsl,entry-tp2*Point,0);
                Print("mo2");
              }
            }
         }
      }

     for (y = 0; y < OrdersTotal(); y++) // Sync TPs
     {
       OrderSelect (y, SELECT_BY_POS, MODE_TRADES);
       if ((OrderMagicNumber() != magic) || (OrderType()!=OP_SELL) || (MathAbs(OrderTakeProfit()-ltp)<Point) || (OrderSymbol()!=Symbol())) { continue; }
       OrderModify(OrderTicket(),OrderOpenPrice(),sellsl,ltp,0,Blue);
       Print("m2");
       return;
     }
   }
   
//+------------------------------------------------------------------+
//| External Script Code                                             |
//+------------------------------------------------------------------+

string Message;

   Message = "                "+EA_name + NL +
             "                            Current Time is      " +  TimeToStr(TimeCurrent(), TIME_SECONDS) + NL + NL +                        
             "                            Initial Account Set              " + DoubleToStr(InitialAccount, 0) + NL +
             "                            Equity Protection % Set      " + DoubleToStr(FloatPercent, 0) + NL + NL +
             "                            Power Off Stop Loss on?         " + POSL_On + NL + NL +
             "                            Starting lot size                   " + DoubleToStr(lot, 2) + NL + NL +

             "                            Portion P/L                        " + DoubleToStr(pr, 2) + NL + NL +     
             
             "                            Buy   " + cb + "  Sell   " + cs + NL + NL +
             "                            Account Portion   " + DoubleToStr(Portion, 0) + "   Total Risk on Account Percent  " + DoubleToStr(FloatPercent/Portion, 0) + NL +                
             "                            Portion Balance      " + DoubleToStr(PortionBalancetrade, 2);
             

   Comment(Message);  
      
      return(0);
  }
 
//+------------------------------------------------------------------+
//| Equity Protection Function                                       |
//+------------------------------------------------------------------+ 
  
 void EquityProtection(int Profit) { 
      
      double PortionBalance, PortionEquity;
      PortionBalance = NormalizeDouble(AccountBalance()/Portion,0);
      PortionEquity  = NormalizeDouble(PortionBalance + Profit,0);
      
      for (int i=0; i<OrdersTotal(); i++) {  
      if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {  
         if ( (OrderSymbol()==Symbol()) && (OrderMagicNumber()==magic) && (OrderComment()==TradeComment) ) {  
                        
            slip = NormalizeDouble((slippage * BrokerDecimal),0);
            
            if (OrderType()==OP_BUY)  
               if ( PortionBalance - PortionEquity >= (PortionBalance * FloatPercent/100) )  
                 OrderClose(OrderTicket(),OrderLots(),Bid,slip,Red); 
            if (OrderType()==OP_SELL)  
               if ( PortionBalance - PortionEquity >= (PortionBalance * FloatPercent/100) )  
                 OrderClose(OrderTicket(),OrderLots(),Ask,slip,Red); 
     
         
         } 
      } 
   } 
}  
//+------------------------------------------------------------------+
//| expert end function                                              |
//+------------------------------------------------------------------+

Profitability Reports

PERFORMANCE BY SYMBOL

Expected payoff

Average expected payoff across the available backtests for each symbol.

Positive Negative
23 reports
NZD/USD Oct 2024 - Jan 2025
12.69
Total Trades 49
Won Trades 43
Lost trades 6
Win Rate 87.76 %
Expected payoff 17.42
Gross Profit 926.46
Gross Loss -73.02
Total Net Profit 853.44
-100%
-50%
0%
50%
100%
AUD/USD Oct 2025 - Feb 2026
9.63
Total Trades 28
Won Trades 22
Lost trades 6
Win Rate 78.57 %
Expected payoff 23.14
Gross Profit 722.92
Gross Loss -75.10
Total Net Profit 647.82
-100%
-50%
0%
50%
100%
USD/CHF Jan 2025 - Jul 2025
5.24
Total Trades 198
Won Trades 166
Lost trades 32
Win Rate 83.84 %
Expected payoff 32.50
Gross Profit 7952.59
Gross Loss -1517.87
Total Net Profit 6434.72
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
4.59
Total Trades 39
Won Trades 29
Lost trades 10
Win Rate 74.36 %
Expected payoff 24.93
Gross Profit 1243.02
Gross Loss -270.86
Total Net Profit 972.16
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
4.59
Total Trades 39
Won Trades 29
Lost trades 10
Win Rate 74.36 %
Expected payoff 24.93
Gross Profit 1243.02
Gross Loss -270.86
Total Net Profit 972.16
-100%
-50%
0%
50%
100%
USD/CHF Jul 2025 - Sep 2025
3.44
Total Trades 38
Won Trades 28
Lost trades 10
Win Rate 73.68 %
Expected payoff 25.82
Gross Profit 1384.01
Gross Loss -402.84
Total Net Profit 981.17
-100%
-50%
0%
50%
100%
USD/CAD Jul 2025 - Sep 2025
3.15
Total Trades 41
Won Trades 26
Lost trades 15
Win Rate 63.41 %
Expected payoff 16.29
Gross Profit 979.07
Gross Loss -311.25
Total Net Profit 667.82
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
2.68
Total Trades 136
Won Trades 103
Lost trades 33
Win Rate 75.74 %
Expected payoff 19.67
Gross Profit 4263.91
Gross Loss -1589.28
Total Net Profit 2674.63
-100%
-50%
0%
50%
100%
USD/CAD Jul 2025 - Sep 2025
2.42
Total Trades 45
Won Trades 29
Lost trades 16
Win Rate 64.44 %
Expected payoff 14.84
Gross Profit 1138.56
Gross Loss -470.87
Total Net Profit 667.69
-100%
-50%
0%
50%
100%
GBP/AUD Jan 2025 - Jul 2025
2.27
Total Trades 592
Won Trades 442
Lost trades 150
Win Rate 74.66 %
Expected payoff 16.95
Gross Profit 17910.84
Gross Loss -7875.38
Total Net Profit 10035.46
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
1.99
Total Trades 85
Won Trades 65
Lost trades 20
Win Rate 76.47 %
Expected payoff 17.87
Gross Profit 3045.91
Gross Loss -1527.11
Total Net Profit 1518.80
-100%
-50%
0%
50%
100%
USD/JPY Jan 2025 - Jul 2025
1.77
Total Trades 505
Won Trades 381
Lost trades 124
Win Rate 75.45 %
Expected payoff 18.40
Gross Profit 21403.61
Gross Loss -12113.88
Total Net Profit 9289.73
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
1.47
Total Trades 58
Won Trades 41
Lost trades 17
Win Rate 70.69 %
Expected payoff 11.13
Gross Profit 2005.95
Gross Loss -1360.16
Total Net Profit 645.79
-100%
-50%
0%
50%
100%
EUR/USD Oct 2025 - Feb 2026
1.01
Total Trades 73
Won Trades 51
Lost trades 22
Win Rate 69.86 %
Expected payoff 0.42
Gross Profit 4402.50
Gross Loss -4372.11
Total Net Profit 30.39
-100%
-50%
0%
50%
100%
GBP/AUD Oct 2025 - Feb 2026
0.88
Total Trades 265
Won Trades 192
Lost trades 73
Win Rate 72.45 %
Expected payoff -3.90
Gross Profit 7905.81
Gross Loss -8939.40
Total Net Profit -1033.59
-100%
-50%
0%
50%
100%
USD/CAD Jan 2025 - Jul 2025
0.70
Total Trades 206
Won Trades 156
Lost trades 50
Win Rate 75.73 %
Expected payoff -7.87
Gross Profit 3775.38
Gross Loss -5397.06
Total Net Profit -1621.68
-100%
-50%
0%
50%
100%
GBP/CAD Oct 2025 - Feb 2026
0.61
Total Trades 146
Won Trades 100
Lost trades 46
Win Rate 68.49 %
Expected payoff -15.74
Gross Profit 3527.53
Gross Loss -5825.58
Total Net Profit -2298.05
-100%
-50%
0%
50%
100%
GBP/USD Jan 2025 - Jul 2025
0.32
Total Trades 107
Won Trades 67
Lost trades 40
Win Rate 62.62 %
Expected payoff -75.75
Gross Profit 3870.00
Gross Loss -11975.01
Total Net Profit -8105.01
-100%
-50%
0%
50%
100%
GBP/CAD Jan 2025 - Jul 2025
0.23
Total Trades 80
Won Trades 49
Lost trades 31
Win Rate 61.25 %
Expected payoff -101.37
Gross Profit 2487.82
Gross Loss -10597.60
Total Net Profit -8109.78
-100%
-50%
0%
50%
100%
GBP/USD Jul 2025 - Sep 2025
0.19
Total Trades 57
Won Trades 37
Lost trades 20
Win Rate 64.91 %
Expected payoff -99.08
Gross Profit 1282.60
Gross Loss -6929.99
Total Net Profit -5647.39
-100%
-50%
0%
50%
100%
AUD/USD Jan 2025 - Jul 2025
0.00
Total Trades 81
Won Trades 55
Lost trades 26
Win Rate 67.90 %
Expected payoff -17996.99
Gross Profit 2272.50
Gross Loss -1460028.65
Total Net Profit -1457756.15
-100%
-50%
0%
50%
100%
EUR/USD Jul 2025 - Sep 2025
0.00
Total Trades 8
Won Trades 6
Lost trades 2
Win Rate 75.00 %
Expected payoff -5259.37
Gross Profit 130.00
Gross Loss -42204.96
Total Net Profit -42074.96
-100%
-50%
0%
50%
100%
GBP/USD Jul 2025 - Sep 2025
0.00
Total Trades 15
Won Trades 1
Lost trades 14
Win Rate 6.67 %
Expected payoff -550.48
Gross Profit 20.00
Gross Loss -8277.19
Total Net Profit -8257.19
-100%
-50%
0%
50%
100%

Comments