EL_FODEURO-alt

Profit factor:
0.44
Price Data Components
Series array that contains close prices for each bar
Orders Execution
It Closes Orders by itself It automatically opens orders when conditions are reachedChecks for the total of open orders
2 Views
0 Downloads
0 Favorites
EL_FODEURO-alt
//+------------------------------------------------------------------+
//|                                                     simplefx.mq4 |
//|                             Copyright © 2007, GLENNBACON.COM LLC |
//|                                  http://www.GetForexSoftware.com |
//+------------------------------------------------------------------+

// Shift of moving average
#define Shift 1

// Trend Detection function
#define TREND_BUY 11
#define TREND_SELL 22
#define TREND_CLOSE 33

// Input variables
extern double  Lots              = 0.30;
extern int     Slippage          = 3;
extern string  Order_Comment     = "EL FODEURO";
extern color   Order_Arrow_Color = Green;
extern double PercentMargin = 0.005;

extern int NOGOVolatility = 200;
extern int SMALLGOVolatility = 100;

extern int SSP = 34; // bars - calculating period
extern int SSK = 29; // tolerance of second line

// Global variables
int Total_Open_Orders = 1; // we only want to open one order at a time and only manage the one order
int cnt = 0;               // counter variable, used in for() loops
bool init_variables;       // init variable when program starts
datetime PreviousBar;      // record the candle/bar time
int NowTrend = TREND_CLOSE;
int Magic = 1;

//Indicators
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double Wal1[];
double Wal2[];
double ExtMapBuffer4[];
int i, i1,  i2, shift;
double SsMax, SsMin, SsMax05, SsMin05, Rsmin, Rsmax, Tsmin, Tsmax;
int val1, val2, AvgRange;
bool uptrend, old;

double iClose0,iClose1,iIchi,iLine1,iLine2;

int init()
  {
   init_variables = true;  // Allows us to init variables in the start function because 
                           // we cannot do this in the init function because the variables 
                           // use values from the chart 
   return(0);
  }
int deinit()
  {
   // clear chart when EA is removed
   ObjectsDeleteAll();
   return(0);
  }

int start()
  {          
   // make sure trader has set Lots to at least the minimum lot size of the broker and 
   // we will normalize the Lots variable so we can properly open an order
   
   
   Print ( Year() ) ;
   
   Print ( Day() ) ;
   
   Print ( Month() ) ;
   if(MarketInfo(Symbol(),MODE_MINLOT) == 0.01)
   {
      Lots = NormalizeDouble(Lots,2);
      if(Lots < 0.01)
      {
         Comment("The variable Lots must be 0.01 or greater to open an order. ");
         return(0);
      }
   }
   if(MarketInfo(Symbol(),MODE_MINLOT) == 0.1)
   {
      Lots = NormalizeDouble(Lots,1);
      if(Lots < 0.1)
      {
         Comment("The variable Lots must be 0.1 or greater to open an order. ");
         return(0);
      }
   }
   if(MarketInfo(Symbol(),MODE_MINLOT) == 1)
   {
      Lots = NormalizeDouble(Lots,0);
      if(Lots < 1)
      {
         Comment("The variable Lots must be 1 or greater to open an order. ");
         return(0);
      }
   }
         
   // init variables when the expert advisor first starts running
   if(init_variables == true)
   {
      PreviousBar = Time[0];     // record the current canle/bar open time
      
      // place code here that you only wnat to run one time
      MathSrand(TimeLocal());
      //Magic = MathRand();  
           
      init_variables = false;    // change to false so we only init variable once
   }
   
   // perform analysis and open orders on new candle/bar 
   if(NewBar() == true)

 //  Sleep (30000);
   {
      NowTrend = TrendDetection();
   
      // only perform analysis and close order if we only have one order open
      if(TotalOpenOrders() == Total_Open_Orders && SelectTheOrder() == true)
      {
         if((OrderType()) == OP_BUY && ((NowTrend == TREND_SELL) || (NowTrend == TREND_CLOSE)))
         {
            OrderClose(OrderTicket(),OrderLots(),Bid,Slippage,Order_Arrow_Color);
         }
         if((OrderType() == OP_SELL) && ((NowTrend == TREND_BUY) || (NowTrend == TREND_CLOSE)))
         {
            OrderClose(OrderTicket(),OrderLots(),Ask,Slippage,Order_Arrow_Color);
         }
      }
      
      // only perform analysis and open new order if we have not reached our Total_Open_Orders max
      if(TotalOpenOrders() < Total_Open_Orders)
      {
         // open buy
         if(NowTrend == TREND_BUY)
         {
            // open order
            OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,0,0,Order_Comment,Magic,0,Order_Arrow_Color);
         }
         
         // open sell
         else if(NowTrend == TREND_SELL)
         {
            // open order 
            OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,0,0,Order_Comment,Magic,0,Order_Arrow_Color);
         }
      }
/*   
          Print("Date: ",Month(),"-",Day(),"-",Year()," Server Time: ",Hour(),":",Minute(),":",Seconds(),
            " volatility:", AvgRange,
            " iClose0: ",iClose0,     
            " iClose1: ",iClose1,
            " iIchi: ",iIchi,
            " iLine1: ",iLine1,
            " iLine2: ",iLine2,
            " Trend: ",NowTrend);  
*/
         Display_Info();
   
   }
   return(0);
  }

/////////////////////////////////////////////////////////////////////////
// Common functions                                                   //
///////////////////////////////////////////////////////////////////////

// This function returns the total amount of orders the expert advisor has open  
int TotalOpenOrders()
{
   cnt=OrdersTotal();
   int TotalOpenOrders = 0;
   
   if(cnt==0)
   {
      return(0);
   }
   else
   {
      for(;cnt>=0;cnt--)
      {
         RefreshRates();
         OrderSelect(cnt,SELECT_BY_POS);
         if(OrderMagicNumber()==Magic)
         {
            TotalOpenOrders++;
         }
      }
   }
   return(TotalOpenOrders);
}

// This function finds the open order and selects it 
int SelectTheOrder()
{
   cnt=OrdersTotal();
      
   if(cnt==0)
   {
      return(false);
   }
   else
   {
      for(;cnt>=0;cnt--)
      {
         RefreshRates();
         OrderSelect(cnt,SELECT_BY_POS);
         if(OrderMagicNumber()==Magic)
         {
            return(true);
         }
      }
   }
   return(false);
}

// This function return the value true if the current bar/candle was just formed
bool NewBar()
{
   if(PreviousBar<Time[0])
   {
      PreviousBar = Time[0];
      return(true);
   }
   else
   {
      return(false);
   }
   return(false);    // in case if - else statement is not executed
}

// is trend up/bullish or is it down/bearish
int TrendDetection()
{
   double topLine,bottomLine;
   
   if (iClose1 == 0)
      iClose1 = iClose(NULL,0,10);
   else
      iClose1 = iClose0;
      
   iClose0 = iClose(NULL,0,0);
   AIchimoku();

   if (iLine1 > iLine2)
   {
      topLine = iLine1;
      bottomLine = iLine2;
   }
   else
   {
      topLine = iLine2;
      bottomLine = iLine1;   
   }

   if ((iClose0 > iIchi) && (iClose1 < iIchi))
      return(TREND_BUY);

   if ((iClose0 < iIchi) && (iClose1 > iIchi))
      return(TREND_SELL);

   if ((iClose0 < topLine ) && (iClose0 > bottomLine))
      return(TREND_CLOSE);         

   if (AvgRange < NOGOVolatility )
   {
      if ((iClose0 > topLine) && (iClose0 > iClose1))
            if (((iClose0-topLine)/iClose0)<PercentMargin)
               return(TREND_BUY);
   
      if ((iClose0 < bottomLine) && (iClose0 < iClose1))
            if (((bottomLine-iClose0)/bottomLine)<PercentMargin)
               return(TREND_SELL);
   }
   
   // flat no trend return 0
   return(0);
}

void Display_Info()
{
   Comment("Price:  ",NormalizeDouble(Bid,4),"\n",
            "Date: ",Month(),"-",Day(),"-",Year()," Server Time: ",Hour(),":",Minute(),":",Seconds(),"\n",
            "volatility: ", AvgRange,"\n",
            "iClose0: ",DoubleToStr(iClose0,4),"\n",     
            "iClose1: ",DoubleToStr(iClose1,4),"\n",
            "iIchi: ",DoubleToStr(iIchi,4),"\n",
            "iLine1: ",DoubleToStr(iLine1,4),"\n",
            "iLine2: ",DoubleToStr(iLine2,4),"\n");          
   return(0);
}

void AIchimoku()
{
       // maximum of previous SSP bars period
       SsMax = High[iHighest(NULL, 0, MODE_HIGH, SSP, 0)];      
       // minimum of previous SSP bars period
       SsMin = Low[iLowest(NULL, 0, MODE_LOW, SSP, 0)];         
       // maximum of SSP bars period for SSK bars from begin
       SsMax05 = High[iHighest(NULL, 0, MODE_HIGH, SSP, 0 + SSK)];
       // maximum of SSP bars period for SSK bars from begin
       SsMin05 = Low[iLowest(NULL, 0, MODE_LOW, SSP, 0 + SSK)];   
       iLine1 = (SsMax + SsMin) / 2;
       iLine2 = (SsMax05+SsMin05) / 2;
       val1 = ExtMapBuffer1[1] / Point;
       val2 = ExtMapBuffer2[1] / Point;
       //----
       Rsmax = High[iHighest(NULL, 0, MODE_HIGH, SSP*2, 0)]; 
       Rsmin = Low[iLowest(NULL, 0, MODE_LOW, SSP*2, 0)];  
       AvgRange = (Rsmax / Point) - (Rsmin / Point);
       //----
       Tsmax = High[iHighest(NULL, 0, MODE_HIGH, SSP*1.62, 0)];     
       Tsmin = Low[iLowest(NULL, 0, MODE_LOW, SSP*1.62, 0)];    
       iIchi = (Tsmax + Tsmin) / 2;
}

Profitability Reports

USD/CAD Oct 2024 - Jan 2025
0.58
Total Trades 93
Won Trades 21
Lost trades 72
Win Rate 22.58 %
Expected payoff -7.33
Gross Profit 934.52
Gross Loss -1616.54
Total Net Profit -682.02
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
0.29
Total Trades 131
Won Trades 16
Lost trades 115
Win Rate 12.21 %
Expected payoff -16.18
Gross Profit 854.10
Gross Loss -2973.30
Total Net Profit -2119.20
-100%
-50%
0%
50%
100%
GBP/USD Oct 2024 - Jan 2025
0.56
Total Trades 124
Won Trades 30
Lost trades 94
Win Rate 24.19 %
Expected payoff -14.20
Gross Profit 2208.90
Gross Loss -3970.20
Total Net Profit -1761.30
-100%
-50%
0%
50%
100%
AUD/USD Oct 2024 - Jan 2025
0.33
Total Trades 149
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -17.19
Gross Profit 1234.50
Gross Loss -3795.90
Total Net Profit -2561.40
-100%
-50%
0%
50%
100%

Comments