HL_MA_v04





//+------------------------------------------------------------------+ 
//|                                                     High&Low.mq4 | 
//|                                  Copyright © 2007, Shadow Trader | 
//|                                   e-mail: ShadowTrader@fxmail.ru | 
//+------------------------------------------------------------------+ 
// Ýêñïåðò ïðåäíàçíà÷åí äëÿ ðàáîòû íà äíåâêàõ.
// Ïàðàìåòðû óñòàíîâëåíû äëÿ ïàðû EURUSD
extern int ma_period = 20;
extern double SL_percent_of_channel = 2.1;
double lots   = 0.1;
double sl;
double tp;


int init ()
{ 
   return(0);
} 

int deinit()
{
   return(0);
}

int day=1;

int start()
{
   if (AccountFreeMargin() < 120)
      return (0);

   double mah = iMA(Symbol(), 0, ma_period, 0, MODE_LWMA, PRICE_HIGH, 1);
   double mal = iMA(Symbol(), 0, ma_period, 0, MODE_LWMA, PRICE_LOW,  1);
      
   if (OrdersTotal() > 0)
   {
      if (Volume[0]>day)
         return (0);
      else
      {
         for (int i = 0; i < OrdersTotal(); i++)
         {
            if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES) == TRUE)
            {
               if (OrderType() == OP_BUY)
               {
                  if (OrderStopLoss() < mal)
                      OrderModify(OrderTicket(), Ask, mal, OrderTakeProfit(), 0, Gold);
               }

               if (OrderType() == OP_SELL)
               {
                  if (OrderStopLoss() > mah)
                      OrderModify(OrderTicket(), Bid, mah, OrderTakeProfit(), 0, Green);
               }
            }
         }
         return (0);
      }
   }

   // Ïîêóïêà
   if ( Close[1] > mah && Low [0] > mah )
   {
      sl = Ask-SL_percent_of_channel*(mah-mal);
      tp = Ask + (mah - mal);
      OrderSend(Symbol(), OP_BUY, lots, Ask, 3, sl, tp, "", 0, 0, Blue);
   }

   // Ïðîäàæà
   if ( Close[1] < mal && High[0] < mal )
   {
      sl = Bid+SL_percent_of_channel*(mah-mal);
      tp = Bid - (mah - mal);
      OrderSend(Symbol(), OP_SELL, lots, Bid, 3, sl, tp, "", 0, 0, Red);
   }

   return(0);
}



Sample





Analysis



Market Information Used:

Series array that contains tick volumes of each bar
Series array that contains close prices for each bar
Series array that contains the highest prices of each bar


Indicator Curves created:


Indicators Used:

Moving average indicator


Custom Indicators Used:

Order Management characteristics:
Checks for the total of open orders
It can change open orders parameters, due to possible stepping strategy
It automatically opens orders when conditions are reached

Other Features:


BackTest : EURUSD on H1

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

BackTest : EURUSD on H1

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

BackTest : EURUSD on H1

From 2009-12-01 to 2010-01-17 Profit Factor:0.79 Total Net Profit:-574.46

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:0.00 Total Net Profit:0.00

BackTest : EURUSD on H1

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

BackTest : GBPUSD on H1

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

BackTest : USDCAD on H1

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

BackTest : USDCHF on H1

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

BackTest : USDJPY on H1

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

Request Backtest for HL_MA_v04


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

Pair: Period: