Super Signals EA

Author: Bluto
Profit factor:
1.08

Okay, here's a breakdown of what this trading script does, explained in plain language.

Overall Goal:

This script is designed to automatically trade currencies in the Forex market based on signals from a custom indicator. Think of it as a robot that watches for certain patterns and then buys or sells a currency, trying to make a profit.

Here's how it works, step-by-step:

  1. Setup:

    • When the script starts, it first figures out which currency pair it's running on (like EURUSD, or GBPJPY). Based on the currency pair, it assigns a unique "Magic Number". This is like a secret code so the script only manages trades it has opened itself.
    • It also gets information about the trading account and the currency pair, like how much leverage the account has, the minimum and maximum trade sizes allowed, and the smallest trade size increment.
  2. Money Management (Optional):

    • The script can manage the trade size automatically, based on how much money is in the account and a specified "Risk Percent". For example, if you set RiskPercent to 2.0, the script will risk 2% of the account balance on each trade.
    • If automatic money management is turned off, the script will use a fixed "LotSize" for each trade.
  3. Signal Check:

    • The script uses a custom indicator (named "super-signals_v2b") to generate buy or sell signals. It checks the values of this indicator to determine if it should buy or sell.
  4. Trade Management:

    • Closing Existing Trades: Before opening any new trades, the script will close any existing trades opened by itself (identified by the Magic Number) that are in the opposite direction of the new signal. For example, if the script receives a buy signal, it will first close any existing sell trades.
    • Opening New Trades: If the script sees a "buy" signal and no "buy" orders are already open, it opens a new "buy" order. If the script sees a "sell" signal and no "sell" orders are already open, it opens a new "sell" order. The trade size is determined by either the money management calculations or the fixed lot size.
    • When it opens an order, it includes:
      • Stop Loss: an order to automatically close the trade if the price moves against you by a certain amount, limiting potential losses.
      • Take Profit: an order to automatically close the trade if the price moves in your favor by a certain amount, locking in profits.
      • Slippage: the maximum acceptable difference between the requested price of the trade and the actual price when the order is executed.
  5. Error Handling:

    • The script includes basic error handling. If there's a problem opening a trade (e.g., connection issues, invalid trade size), it will print an error message. It also retries a few times if the error is related to the server being busy.

In Summary:

The script is an automated trading system that uses a custom indicator to generate buy and sell signals. It manages the trade size, stop loss, and take profit levels. It aims to automatically trade a currency pair based on the signals from the indicator, closing opposite trades before entering a new one.

Orders Execution
Checks for the total of open ordersIt Closes Orders by itself It automatically opens orders when conditions are reached
4 Views
0 Downloads
0 Favorites
Super Signals EA
//+------------------------------------------------------------------+
//|                                                                  |
//|        Super Signals EA.mq4 - Ver 1.1 @ 02/11/2007 by Bluto      |
//|                                                                  |
//+------------------------------------------------------------------+

//  2/22/2007 Ver 1.2 Commented out OrderModify and Changed StopLoss from 20 to 200

#property copyright "Bluto"
#property link      "None"

extern double LotSize=5;
extern int    Slippage=3;
extern double StopLoss=200;  //original 20
extern double TakeProfit=500;
extern double RiskPercent=2.0;
extern bool   UseMoneyMgmt=true;

int           MagicNumber=0;
int           ticket;
int           BuyOrders=0;
int           SellOrders=0;
int           i;

double        SS_SELL_0=0, SS_SELL_1=0, SS_BUY_0=0, SS_BUY_1=0;
double        MM_MinLotSize=0;
double        MM_MaxLotSize=0;
double        MM_LotStep=0;
double        MM_Decimals=0;
double        MM_OrderLotSize=0;
int           MM_AcctLeverage=0;
int           MM_CurrencyLotSize=0;
bool          SSIsBuy=false, SSIsSell=false;


int init()
{
   if (Symbol()=="AUDCADm" || Symbol()=="AUDCAD") {MagicNumber=200001;}
   if (Symbol()=="AUDJPYm" || Symbol()=="AUDJPY") {MagicNumber=200002;}
   if (Symbol()=="AUDNZDm" || Symbol()=="AUDNZD") {MagicNumber=200003;}
   if (Symbol()=="AUDUSDm" || Symbol()=="AUDUSD") {MagicNumber=200004;}
   if (Symbol()=="CHFJPYm" || Symbol()=="CHFJPY") {MagicNumber=200005;}
   if (Symbol()=="EURAUDm" || Symbol()=="EURAUD") {MagicNumber=200006;}
   if (Symbol()=="EURCADm" || Symbol()=="EURCAD") {MagicNumber=200007;}
   if (Symbol()=="EURCHFm" || Symbol()=="EURCHF") {MagicNumber=200008;}
   if (Symbol()=="EURGBPm" || Symbol()=="EURGBP") {MagicNumber=200009;}
   if (Symbol()=="EURJPYm" || Symbol()=="EURJPY") {MagicNumber=200010;}
   if (Symbol()=="EURUSDm" || Symbol()=="EURUSD") {MagicNumber=200011;}
   if (Symbol()=="GBPCHFm" || Symbol()=="GBPCHF") {MagicNumber=200012;}   
   if (Symbol()=="GBPJPYm" || Symbol()=="GBPJPY") {MagicNumber=200013;}
   if (Symbol()=="GBPUSDm" || Symbol()=="GBPUSD") {MagicNumber=200014;}
   if (Symbol()=="NZDJPYm" || Symbol()=="NZDJPY") {MagicNumber=200015;}
   if (Symbol()=="NZDUSDm" || Symbol()=="NZDUSD") {MagicNumber=200016;}
   if (Symbol()=="USDCHFm" || Symbol()=="USDCHF") {MagicNumber=200017;}
   if (Symbol()=="USDJPYm" || Symbol()=="USDJPY") {MagicNumber=200018;}
   if (Symbol()=="USDCADm" || Symbol()=="USDCAD") {MagicNumber=200019;}
   if (MagicNumber==0) {MagicNumber = 200999;}  
 
 return(0);
}

int deinit()
{
 return(0);
}

int start()
{ 

  MM_AcctLeverage = AccountLeverage();
  MM_MinLotSize = MarketInfo(Symbol(),MODE_MINLOT);
  MM_MaxLotSize = MarketInfo(Symbol(),MODE_MAXLOT);
  MM_LotStep = MarketInfo(Symbol(),MODE_LOTSTEP);
  MM_CurrencyLotSize = MarketInfo(Symbol(),MODE_LOTSIZE);

  if(MM_LotStep == 0.01) {MM_Decimals = 2;}
  if(MM_LotStep == 0.1) {MM_Decimals = 1;}

  if (UseMoneyMgmt == true)
   {
    MM_OrderLotSize = AccountEquity() * (RiskPercent * 0.01) / (MM_CurrencyLotSize / MM_AcctLeverage);
    MM_OrderLotSize = StrToDouble(DoubleToStr(MM_OrderLotSize,MM_Decimals));
   }
    else
   {
    MM_OrderLotSize = LotSize;
   }

  if (MM_OrderLotSize < MM_MinLotSize) {MM_OrderLotSize = MM_MinLotSize;}
  if (MM_OrderLotSize > MM_MaxLotSize) {MM_OrderLotSize = MM_MaxLotSize;}
  
  
  SS_SELL_0 = iCustom(Symbol(),Period(),"super-signals_v2b",4,0,0);
  SS_SELL_1 = iCustom(Symbol(),Period(),"super-signals_v2b",4,0,1);
  SS_BUY_0 = iCustom(Symbol(),Period(),"super-signals_v2b",4,1,0);
  SS_BUY_1 = iCustom(Symbol(),Period(),"super-signals_v2b",4,1,1);
  
  if (SS_SELL_0 > 0 || SS_SELL_1 > 0) {SSIsSell=true;SSIsBuy=false;}
  if (SS_BUY_0 > 0 || SS_BUY_1 > 0) {SSIsSell=false;SSIsBuy=true;}
  
  
  BuyOrders=0;
  SellOrders=0; 
  
  for(i=OrdersTotal();i >= 0;i--) 
   {
    OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
    if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) 
     {
      if (OrderType() == OP_BUY)
       {
        BuyOrders++;
        if (StopLoss > 0 && Bid - (StopLoss * Point) > OrderStopLoss())
         {
//          OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(Bid - (StopLoss * Point),Digits),OrderTakeProfit(),0);
         }
       }   
      if (OrderType() == OP_SELL)
       {
        SellOrders++;
        if (StopLoss > 0 && Ask + (StopLoss * Point) < OrderStopLoss())
         {
//          OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(Ask + (StopLoss * Point),Digits),OrderTakeProfit(),0);
         }
       }  
     }
   } 
    
   
  if (SSIsBuy==true) 
   {
    if(SellOrders > 0)
     {
      CloseShorts(MagicNumber);
      SellOrders = 0; 
     }
    if(BuyOrders == 0)
     {    
      ticket = OpenPendingOrder(OP_BUY,MM_OrderLotSize,Ask,Slippage,Bid,StopLoss,TakeProfit,"Super Signals",MagicNumber,0,Lime);
      if(ticket<0)
       {
        Print("OrderSend failed with error #",GetLastError());
        return(0);
       }
      else
       {
        BuyOrders++;
       }    
     }
   }
   
  if (SSIsSell==true) 
   {
    if(BuyOrders > 0)
     {
      CloseLongs(MagicNumber);
      BuyOrders = 0;
     }  
    if (SellOrders == 0) 
     { 
      ticket = OpenPendingOrder(OP_SELL,MM_OrderLotSize,Bid,Slippage,Ask,StopLoss,TakeProfit,"Super Signals",MagicNumber,0,HotPink);
      if(ticket<0)
       {
        Print("OrderSend failed with error #",GetLastError());
        return(0);
       }
      else
       {
        SellOrders++;
       }    
     }
   }
   
  return(0);
}

//----- Order Processing Functions

void CloseLongs(int MagicNumber)
{
 int trade;
 for(trade=OrdersTotal()-1;trade>=0;trade--)
 {
  if(OrderSelect(trade,SELECT_BY_POS,MODE_TRADES)==false)
   continue;

  if(OrderSymbol()!=Symbol()||OrderMagicNumber()!=MagicNumber)
   continue;
   
  if(OrderSymbol()==Symbol()&&OrderMagicNumber()==MagicNumber)
  if(OrderType()==OP_BUY)
   OrderClose(OrderTicket(),OrderLots(),Bid,Slippage,Blue);
 }//for
}

void CloseShorts(int MagicNumber)
{
 int trade;
 for(trade=OrdersTotal()-1;trade>=0;trade--)
 {
  if(OrderSelect(trade,SELECT_BY_POS,MODE_TRADES)==false)
   continue;

  if(OrderSymbol()!=Symbol()||OrderMagicNumber()!=MagicNumber)
   continue;
   
  if(OrderSymbol()==Symbol()&&OrderMagicNumber()==MagicNumber)
  if(OrderType()==OP_SELL)
   OrderClose(OrderTicket(),OrderLots(),Ask,Slippage,Red);
 }//for
}

int OpenPendingOrder(int pType,double pLots,double pLevel,int sp, double pr, int sl, int tp,string pComment,int pMagic,datetime pExpiration,color pColor)
{
  int ticket=0;
  int err=0;
  int c = 0;
  int NumberOfTries = 10;
  switch (pType)
  {
      case OP_BUY:
         for(c = 0 ; c < NumberOfTries ; c++)
         {  
            RefreshRates();
            ticket=OrderSend(Symbol(),OP_BUY,pLots,Ask,sp,StopLong(Bid,sl),TakeLong(Bid,tp),pComment,pMagic,pExpiration,pColor);
            if (ticket > 0) break;
            err=GetLastError();
            if(err==0)
            { 
               break;
            }
            else
            {
               if(err==4 || err==137 ||err==146 || err==136) //Busy errors
               {
                  Sleep(5000);
                  continue;
               }
               else //normal error
               {
                  Print("Error Code= ", err);
                  break;
               }  
            }
         } 
         break;
      case OP_SELL:
         for(c = 0 ; c < NumberOfTries ; c++)
         {
            RefreshRates();
            ticket=OrderSend(Symbol(),OP_SELL,pLots,Bid,sp,StopShort(Ask,sl),TakeShort(Ask,tp),pComment,pMagic,pExpiration,pColor);
            if (ticket > 0) break;
            err=GetLastError();
            if(err==0)
            { 
               break;
            }
            else
            {
               if(err==4 || err==137 ||err==146 || err==136) //Busy errors
               {
                  Sleep(5000);
                  continue;
               }
               else //normal error
               {
                  Print("Error Code= ", err);
                  break;
               }  
            }
         } 
         break;
  } 
  
  return(ticket);
}  

double StopLong(double price,int stop)
{
 if(stop==0)
  return(0);
 else
  return(price-(stop*Point));
}

double StopShort(double price,int stop)
{
 if(stop==0)
  return(0);
 else
  return(price+(stop*Point));
}

double TakeLong(double price,int take)
{
 if(take==0)
  return(0);
 else
  return(price+(take*Point));
}

double TakeShort(double price,int take)
{
 if(take==0)
  return(0);
 else
  return(price-(take*Point));
}



Profitability Reports

GBP/USD Jul 2025 - Sep 2025
0.67
Total Trades 215
Won Trades 59
Lost trades 156
Win Rate 27.44 %
Expected payoff -16.83
Gross Profit 7362.07
Gross Loss -10980.66
Total Net Profit -3618.59
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
0.72
Total Trades 248
Won Trades 77
Lost trades 171
Win Rate 31.05 %
Expected payoff -11.40
Gross Profit 7270.66
Gross Loss -10096.66
Total Net Profit -2826.00
-100%
-50%
0%
50%
100%
EUR/USD Jul 2025 - Sep 2025
2.18
Total Trades 3993
Won Trades 1973
Lost trades 2020
Win Rate 49.41 %
Expected payoff 45565.62
Gross Profit 336247972.55
Gross Loss -154304471.24
Total Net Profit 181943501.31
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
0.79
Total Trades 100
Won Trades 40
Lost trades 60
Win Rate 40.00 %
Expected payoff -9.84
Gross Profit 3717.92
Gross Loss -4702.19
Total Net Profit -984.27
-100%
-50%
0%
50%
100%
USD/JPY Jan 2025 - Jul 2025
0.92
Total Trades 1355
Won Trades 421
Lost trades 934
Win Rate 31.07 %
Expected payoff -2.77
Gross Profit 45367.75
Gross Loss -49119.77
Total Net Profit -3752.02
-100%
-50%
0%
50%
100%
USD/CHF Jan 2025 - Jul 2025
0.92
Total Trades 424
Won Trades 152
Lost trades 272
Win Rate 35.85 %
Expected payoff -4.57
Gross Profit 22707.16
Gross Loss -24646.92
Total Net Profit -1939.76
-100%
-50%
0%
50%
100%
USD/CAD Jan 2025 - Jul 2025
0.91
Total Trades 571
Won Trades 186
Lost trades 385
Win Rate 32.57 %
Expected payoff -3.73
Gross Profit 21225.32
Gross Loss -23353.78
Total Net Profit -2128.46
-100%
-50%
0%
50%
100%
GBP/USD Jan 2025 - Jul 2025
0.79
Total Trades 708
Won Trades 231
Lost trades 477
Win Rate 32.63 %
Expected payoff -8.58
Gross Profit 22619.23
Gross Loss -28695.94
Total Net Profit -6076.71
-100%
-50%
0%
50%
100%
GBP/CAD Jan 2025 - Jul 2025
0.77
Total Trades 981
Won Trades 316
Lost trades 665
Win Rate 32.21 %
Expected payoff -6.13
Gross Profit 19807.39
Gross Loss -25824.90
Total Net Profit -6017.51
-100%
-50%
0%
50%
100%
GBP/AUD Jan 2025 - Jul 2025
0.71
Total Trades 1635
Won Trades 491
Lost trades 1144
Win Rate 30.03 %
Expected payoff -5.21
Gross Profit 21267.58
Gross Loss -29779.20
Total Net Profit -8511.62
-100%
-50%
0%
50%
100%

Comments