EuroBull_v1

Author: Zonker
Profit factor:
59.75

Here's a breakdown of what this trading script does, explained in plain language:

This script, called "EuroBull," is designed to automatically buy and sell Euros (specifically, it's intended for the EURUSD currency pair). It tries to take advantage of what it believes are favorable trends for the Euro. Here's how it works:

1. Initial Setup and Checks:

  • "Happyness" Check: Before doing anything, the script checks if it's in the right "mood" to trade. This means:
    • Is it connected to the internet?
    • Is the script actually enabled to trade?
    • Has the account balance not exceeded a certain limit to stop being greedy or fallen below a level considered a loss?

2. Deciding When to Buy:

  • SMA Comparison: The script calculates a "Simple Moving Average" (SMA). This is a way to see the average price of the EURUSD over the past 10 days, using daily data. It then compares this SMA to the current price (Ask price).
  • Buy Logic: The script buys Euros based on the following rules:
    • If the SMA is higher than the current price, the script sees Euros as "going cheap" and wants to buy.
    • If the SMA is lower than the current price, the script sees momentum in favor of the Euro and wants to buy.
    • If the SMA is equal to the current price, the script really wants to buy. Essentially it considers that buying is always good in this case

3. Managing Existing Euro Positions:

  • Checking Existing Orders: If the script already has open Euro positions (meaning it has already bought Euros), it checks if it should buy more or sell and rebuy.
  • Evaluate situation: It checks how much equity is on the account. If there is enough equity to buy again, it does
  • Lots Size Evaluation: The lots size is defined based on a set of conditions regarding the Equity size, a minimum and a max number.

4. Placing Orders:

  • Deciding How Much to Buy: If the script has decided to buy Euros, it calculates how many "lots" (standard trading units) to purchase. The amount is based on a proportion of the account balance.
  • Placing the Buy Order: The script then sends a "buy" order to the trading platform. It tries to determine a tinyLots size if it finds the AccountBalance over a defined threshold.

5. Functions Used:

  • Happyness(): Checks if the script is allowed to trade.
  • CloseOrders(): Closes all existing orders.
  • MyOrderSend(): Sends a new buy order to the platform.
  • MyOrderClose(): Closes an existing order at the current price.

In short, this script is a simple automated trading system that buys Euros based on a comparison between the current price and a moving average, with some additional checks to manage risk and existing positions. It's designed to continuously buy Euros if it believes the price is favorable.

Orders Execution
Checks for the total of open ordersIt automatically opens orders when conditions are reachedIt Closes Orders by itself
Indicators Used
Moving average indicator
10 Views
0 Downloads
1 Favorites
EuroBull_v1
//+------------------------------------------------------------------+
//|                                                     EuroBull.mq4 |
//|                                                           Zonker |
//|                                        http://www.greenpeace.org |
//+------------------------------------------------------------------+
//
//The EuroBull, tends to favour markets that trend in favour of Euro:).
//Designed to run on EURUSD.

#property copyright "Zonker"
#property link      "http://www.greenpeace.org"

#define MAXLOTSIZE 5
#define MAXPOS 3
#define SLIP 1
#define SL 100
int myMagic = 88888888;//very lucky, yes?

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

int start()
{  double sma;
   bool BuyEuros = false;
   int LotsToBuy,Lots; 
   int i;

   if(!Happyness()) return(0);

   sma = iMA(NULL,PERIOD_D1,10,0,MODE_SMA,PRICE_CLOSE,0);//Must respect the sma.
   
   if(sma > Ask) //Euros going cheap! BUY!
      BuyEuros = true;
   
   if(sma < Ask) //Momentum in our favour! BUY!!
      BuyEuros = true;
      
   if(sma == Ask) //BuY EUROS NOW!!!, BUY MORE!!!
      BuyEuros = true;
   
   if(OrdersTotal()>0)
   {  //We have Euros! Do we need any more?
      Lots=0;
      for(i=0;i<OrdersTotal();i++)
      {  OrderSelect(i,SELECT_BY_POS,MODE_TRADES); 
         Lots += OrderLots();
      }
      if(AccountEquity() > (Lots*2000 + MathMin(5,(Lots+1)/2)*2000 + 100) && Lots < MAXLOTSIZE*MAXPOS && Lots >= 1.0)
         CloseOrders(OP_BUY); //Sell up and buy more Euros   
      else 
         return(0);
      
   }
    
   if(BuyEuros)
   {  //We don't have any Euros?!!? How many Euros should we buy?
      LotsToBuy = AccountBalance()/2000;
      
      if(LotsToBuy == 0 && AccountBalance() > 100)
      {  //Ok, getting desparate..
         double tinyLots = NormalizeDouble(AccountBalance()/2000.0-0.1,1);
         if(tinyLots>0)
            MyOrderSend(Symbol(),OP_BUY,tinyLots,Ask,SLIP,Ask-SL*Point,Ask+SL*Point,"",myMagic,0,Blue);    
         return(0);
      }
      
      for(i=0;i<MAXPOS;i++)
      {  if(LotsToBuy>MAXLOTSIZE) Lots = MAXLOTSIZE;
         else Lots = LotsToBuy;
         
         MyOrderSend(Symbol(),OP_BUY,Lots,Ask,SLIP,Ask-SL*Point,0,"",myMagic,0,Blue);
         
         LotsToBuy -= MAXLOTSIZE;
         if(LotsToBuy <= 0) break;
      } 
   }  


   return(0);
}
  
//+------------------------------------------------------------------- 
bool Happyness() //Are we in the right mood to trade?
{  
   if(!IsConnected()) 
   {  Print("Yo man, we are not connected!");
      return(false);
   }
   if(!IsExpertEnabled())
   {  Print("Hey, we are not enabled!");
      return(false);
   }
   
   if(AccountEquity() > 98800) //Stop at 888%, lets not be greedy.
   {  if(OrdersTotal() > 0) 
         CloseOrders(OP_BUY); 
      return(false);
   }
   
   if(AccountBalance() < 200) return(false); //Ok, we  lost.
   
   return(true);
}
  
//+-------------------------------------------------------------------  
int CloseOrders(int cmd)
{  int i;
   double price;
   if(cmd == OP_SELL) price = Ask;
   else price = Bid;

   for(i=OrdersTotal()-1;i>=0;i--)
   {  OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
      if(OrderType() == cmd)
         MyOrderClose(OrderTicket(),OrderLots(),price,SLIP,CLR_NONE);
   }
}
//+------------------------------------------------------------------- 
int MyOrderSend(string sym, int cmd, double vol, double price, int slip, double sl, double tp, string comment="", int magic=0, datetime exp=0, color cl=CLR_NONE)
{  int err;
   bool isAsk=false;
 
   if(price == Ask) isAsk = true;   

   for(int z=0;z<10;z++)
   {  if(OrderSend(sym,cmd,vol,price,slip,sl,tp,comment,magic,exp,cl)<0)
      {  err = GetLastError();
         Print("OrderSend failed, Error: ", err);
         if(err>4000) break;
         RefreshRates();
         if(isAsk) price = Ask;
         else price = Bid;
      }
      else
         break;
   }

}
//+------------------------------------------------------------------+
bool MyOrderClose(int ticket, double lots, double price, int slip, color cl=CLR_NONE)
{  int err;
   bool isAsk=false;
   
   if(price == Ask) isAsk = true; 

   for(int z=0;z<10;z++)
   {
      if(!OrderClose(ticket,lots,price,slip,cl))
      {  err = GetLastError();
         Print("OrderClose failed, Error: ", err);
         if(err>4000) break;
         RefreshRates();
         if(isAsk) price = Ask;
         else price = Bid;
      }
      else
         break;
   }

} 
//+------------------------------------------------------------------- 

Profitability Reports

GBP/CAD Jan 2025 - Jul 2025
0.18
Total Trades 207
Won Trades 28
Lost trades 179
Win Rate 13.53 %
Expected payoff -46.88
Gross Profit 2159.53
Gross Loss -11864.72
Total Net Profit -9705.19
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 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%
EUR/USD Jul 2025 - Sep 2025
811.82
Total Trades 12
Won Trades 1
Lost trades 11
Win Rate 8.33 %
Expected payoff 263515.00
Gross Profit 3166080.00
Gross Loss -3900.00
Total Net Profit 3162180.00
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
0.64
Total Trades 90
Won Trades 17
Lost trades 73
Win Rate 18.89 %
Expected payoff -64.34
Gross Profit 10309.00
Gross Loss -16100.00
Total Net Profit -5791.00
-100%
-50%
0%
50%
100%
USD/JPY Jan 2025 - Jul 2025
0.61
Total Trades 702
Won Trades 253
Lost trades 449
Win Rate 36.04 %
Expected payoff -13.82
Gross Profit 15235.68
Gross Loss -24936.54
Total Net Profit -9700.86
-100%
-50%
0%
50%
100%
USD/CHF Jan 2025 - Jul 2025
0.72
Total Trades 295
Won Trades 82
Lost trades 213
Win Rate 27.80 %
Expected payoff -32.91
Gross Profit 24651.72
Gross Loss -34359.65
Total Net Profit -9707.93
-100%
-50%
0%
50%
100%
USD/CAD Jan 2025 - Jul 2025
0.73
Total Trades 548
Won Trades 156
Lost trades 392
Win Rate 28.47 %
Expected payoff -17.70
Gross Profit 25632.76
Gross Loss -35334.81
Total Net Profit -9702.05
-100%
-50%
0%
50%
100%
NZD/USD Jan 2025 - Jul 2025
0.71
Total Trades 665
Won Trades 261
Lost trades 404
Win Rate 39.25 %
Expected payoff -14.59
Gross Profit 23345.00
Gross Loss -33050.00
Total Net Profit -9705.00
-100%
-50%
0%
50%
100%
GBP/USD Jan 2025 - Jul 2025
0.23
Total Trades 175
Won Trades 36
Lost trades 139
Win Rate 20.57 %
Expected payoff -55.48
Gross Profit 2911.00
Gross Loss -12620.00
Total Net Profit -9709.00
-100%
-50%
0%
50%
100%
GBP/AUD Jan 2025 - Jul 2025
0.18
Total Trades 248
Won Trades 45
Lost trades 203
Win Rate 18.15 %
Expected payoff -39.12
Gross Profit 2149.93
Gross Loss -11852.41
Total Net Profit -9702.48
-100%
-50%
0%
50%
100%

Comments