A Price Specific Expert Advisor

 
This is Russell. You may have seen some of my posts on this forum before. I've been actively playing around with MT and especially MQL4 and have came across a strategy that examins the current price only; absolutely no technical indicators are involved. Basically, I just wrote a routine that would determine consecutive candlestick patterns that would signify a likely continuation of a trend. But what impressed me with the results was that when I tested the expert advisor in the Strategy Tester, significant profits were generated for all of the forex symbols. In my experience, a specific strategy would work well on some symbols, and not others.

I would like to have your thoughts on this. Here's the code...

//+------------------------------------------------------------------+
//|                                            Price Advisor.mq4 |
//|                      Copyright © 2005, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"
#include <stdlib.mqh>

int prev_err = 0;
int state = 0;
double range = 0;

void PrintErrors(string message)
{
   
   int err = GetLastError();
   if (err != 0 && err != prev_err) 
   {
      Print("Error:  " + message + ":  " + err + ":  " + ErrorDescription(err));
   }
   
   prev_err = err;
}

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//---- 

      
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//---- 

   // Monitor Open Positions...
   int total = OrdersTotal();
   for (int i = 0; i < total; i++)
   {  
      OrderSelect(i, SELECT_BY_POS);
      if (OrderSymbol() == Symbol())
      {
         if (OrderProfit() > 2) 
         {
            OrderClose( OrderTicket(), OrderLots(), OrderClosePrice(), 3, Aqua);
            PrintErrors("Close Order:  exeptable profit");      
         }
                
      
      }
      
   }

   
   // Determine if we already placed an order on this symbol...
   bool trading_on_symbol = false;      
   total = OrdersTotal();
   for (i = 0; i < total; i++)
   {
      OrderSelect(i, SELECT_BY_POS);
      if (OrderSymbol() == Symbol())
      {
         trading_on_symbol = true;
         break;
      }
   }
   
   double stop_loss = 1200;
   double lots = 0.10;
            
   if (!trading_on_symbol && TimeDayOfWeek(CurTime()) < 4 && TimeDayOfWeek(CurTime()) > 0)
   {

      if (Symbol() == "USDCHF") range = 4;
      if (Symbol() == "GBPUSD") range = 8;
      if (Symbol() == "EURUSD") range = 4;
      if (Symbol() == "USDJPY") range = 1;
      if (Symbol() == "AUDUSD") range = 1;
      if (Symbol() == "USDCAD") range = 4;
      if (Symbol() == "EURCHF") range = 2;
      if (Symbol() == "EURGBP") range = 3;
      if (Symbol() == "EURJPY") range = 4;
      if (Symbol() == "EURAUD") range = 4;
      if (Symbol() == "GBPCHF") range = 1;
      if (Symbol() == "GBPJPY") range = 4;
      
   
      if ( Close[3] < Open[3] - range * Point && Close[2] < Open[2] - range * Point && Close[1] < Open[1] - range * Point)
      {
         OrderSend( Symbol(), OP_SELL, lots, Bid,1, Ask + stop_loss * Point, Bid - 8 * Point, NULL, 0, 0, Aqua);               
         PrintErrors("OrderSend:  Sell Order");
         trading_on_symbol = true;
      }
      
      
      if ( Close[3] > Open[3] + range * Point && Close[2] > Open[2] + range * Point && Close[1] > Open[1] + range * Point)
      {
         OrderSend( Symbol(), OP_BUY, lots, Ask,1, Ask - stop_loss * Point, Ask + 8 * Point, NULL, 0, 0, Aqua);
         PrintErrors("OrderSend:  Buy Order");
         trading_on_symbol = true;
      }
      
             
      
   }
   
   
   
  
      
//----
   return(0);
  }
//+------------------------------------------------------------------+
 
Russell,

With a 1200 pip stoploss, you wont get stopped out often. However, if you backtest with 12 months data, you will find a few currencies where the loss is significant!

Best regards,

Hugh
Reason: