[ea]goldfish_v06g_Ron_MT4





#property copyright "Ron Thompson"
#property link      "http://www.lightpatch.com/forex"

// This EA is NEVER to be SOLD individually 
// This EA is NEVER to be INCLUDED as part of a collection that is SOLD

//
// goldfish (flopping around like a goldfish out of water)
//

#property copyright "Ron Thompson"
#property link      "http://www.ForexMT4.com/"

// generic user input
extern double Lots=0.1;
extern int TrailStop=30;

// start the flopping at a LONG position
bool FSell=false;  // where to go next
bool FBuy=true;    // for Future Buy/Sell

datetime bartime;
int      bartick=0;
int    Slippage=2;

// File handling
int handle=0;

// naming and numbering
double   MagicNumber  = 200512062015;
string   TradeComment = "goldfish";



//+------------------------------------+
//| Custom init (usually empty on EAs) |
//|------------------------------------|
// Called ONCE when EA is added to chart
// or expert is re-compiled
int init()
  {
   Comment(TradeComment);
  }


//+------------------------------------+
//| Custom deinit(usually empty on EAs)|
//+------------------------------------+
// Called ONCE when EA is removed from chart
int deinit()
  {
   Comment(" ");
  }


//+------------------------------------+
//| EA main code                       |
//+------------------------------------+
// Called EACH TICK

int start()
  {

   double   p=Point;
   double   spread=Ask-Bid;
   int      cnt=0;

   int  OpenOrders=0;   
 
   double gainloss;
   
   double  SL;
   double  TP;
   
   // use bar movement to prevent multiple orders per bar
   if(bartime!=Time[0])
     {
      bartime=Time[0];
      bartick++;
     }

   for(cnt=0; cnt<OrdersTotal(); cnt++)
     {
      OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
      if( OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber)
        {
         OpenOrders++;
        }
     }

   //initial direction and catch any stoploss that we missed
   if (OpenOrders==0)
     {
      if (FBuy==true && FSell==false)
        {
		   SL=Ask-(TrailStop*p);
		   TP=0;
         OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,SL,TP,TradeComment+"BUY",MagicNumber,White);
         FBuy=false;
         FSell=true;
        }

      if (FBuy==false && FSell==true)
        {
		   SL=Bid+(TrailStop*p);
		   TP=0;
         OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,SL,TP,TradeComment+"SELL ",MagicNumber,Red);
         FBuy=true;
         FSell=false;
        }
     }
     
   // Trailing stop
   for(cnt=0; cnt<OrdersTotal(); cnt++)
     {
      OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
      if( OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber)
        {

         if(OrderType()==OP_BUY)
           {
            gainloss=Bid-OrderStopLoss();

            if ( gainloss > (TrailStop*p) )
              {
               SL=Bid-(TrailStop*p);
               TP=OrderTakeProfit();
               OrderModify(OrderTicket(),OrderOpenPrice(),SL,TP, White);
              }
           }//buy

         if(OrderType()==OP_SELL)
           {
            gainloss=OrderStopLoss()-Ask;

            if ( gainloss > (TrailStop*p) )
              {
               SL=Ask+(TrailStop*p);
               TP=OrderTakeProfit();
               OrderModify(OrderTicket(),OrderOpenPrice(),SL,TP, Red);
              }
           }//sell
           
        } // if(OrderSymbol)
        
     } // for

  } // start()








Sample





Analysis



Market Information Used:

Series array that contains open time of each bar


Indicator Curves created:


Indicators Used:



Custom Indicators Used:

Order Management characteristics:
Checks for the total of open orders

It automatically opens orders when conditions are reached
It can change open orders parameters, due to possible stepping strategy

Other Features:

BackTest : EURUSD on H1

From 2009-11-01 to 2009-11-30 Profit Factor:0.00 Total Net Profit:0.00

BackTest : USDJPY on H1

From 2009-11-01 to 2009-11-30 Profit Factor:0.00 Total Net Profit:0.00

BackTest : USDCHF on H1

From 2009-12-01 to 2010-01-01 Profit Factor:0.00 Total Net Profit:0.00

BackTest : EURUSD on H1

From 2009-12-01 to 2010-01-17 Profit Factor:1.72 Total Net Profit:7498.22

BackTest : USDCAD on H1

From 2009-12-01 to 2010-01-01 Profit Factor:0.00 Total Net Profit:0.00

BackTest : EURUSD on H1

From 2009-08-01 to 2009-10-01 Profit Factor:0.00 Total Net Profit:0.00

BackTest : GBPUSD on H1

From 2010-01-01 to 2010-02-27 Profit Factor:0.00 Total Net Profit:0.00

BackTest : USDCAD on H1

From 2009-01-01 to 2010-01-01 Profit Factor:0.00 Total Net Profit:0.00

BackTest : EURUSD on H1

From 2010-03-01 to 2010-03-27 Profit Factor:0.00 Total Net Profit:0.00

BackTest : GBPUSD on H1

From 2010-01-01 to 2010-04-16 Profit Factor:0.00 Total Net Profit:0.00

BackTest : EURUSD on H1

From 2010-04-01 to 2010-04-30 Profit Factor:0.00 Total Net Profit:0.00

BackTest : EURUSD on H1

From 2010-05-01 to 2010-05-31 Profit Factor:2.46 Total Net Profit:13610.45

BackTest : EURUSD on H1

From 2010-06-01 to 2010-06-30 Profit Factor:1.74 Total Net Profit:5876.43

Request Backtest for [ea]goldfish_v06g_Ron_MT4


From : (yyyy/mm/dd) To: (yyyy/mm/dd)

Pair: Period: