//+------------------------------------------------------------------+
//| This MQL is generated by Expert Advisor Builder                  |
//|                http://sufx.core.t3-ism.net/ExpertAdvisorBuilder/ |
//|                                                                  |
//|  In no event will author be liable for any damages whatsoever.   |
//|                      Use at your own risk.                       |
//|                                                                  |
//+------------------- DO NOT REMOVE THIS HEADER --------------------+

#define SIGNAL_NONE 0
#define SIGNAL_BUY   1
#define SIGNAL_SELL  2
#define SIGNAL_CLOSEBUY 3
#define SIGNAL_CLOSESELL 4

#property copyright "Expert Advisor Builder"
#property link      "http://sufx.core.t3-ism.net/ExpertAdvisorBuilder/"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 DodgerBlue
#property indicator_color2 Red

double upArrow[], dnArrow[];

int init() {
	SetIndexBuffer(0,upArrow);
	SetIndexBuffer(1,dnArrow);
	SetIndexStyle(0,DRAW_ARROW);
	SetIndexStyle(1,DRAW_ARROW);
	SetIndexArrow(0,233);	
	SetIndexArrow(1,234);
	IndicatorDigits(Digits+1);
	return(0);
}

int start() {
   int    limit;
   int    counted_bars=IndicatorCounted();
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars-1;
//---- macd
   for(int i=limit; i>=0; i--) {
   		int Current = i;
   		int Order = 0;
		double Buy1_1 = iClose(NULL, 0, Current + 1);
		double Buy1_2 = iHigh(NULL, 0, Current + 2);
		double Buy2_1 = iClose(NULL, 0, Current + 0);
		double Buy2_2 = iHigh(NULL, 0, Current + 1);
		double Buy3_1 = iClose(NULL, 0, Current + 0);
		double Buy3_2 = iHigh(NULL, 0, Current + 2);

		double Sell1_1 = iClose(NULL, 0, Current + 1);
		double Sell1_2 = iLow(NULL, 0, Current + 2);
		double Sell2_1 = iClose(NULL, 0, Current + 0);
		double Sell2_2 = iLow(NULL, 0, Current + 1);
		double Sell3_1 = iClose(NULL, 0, Current + 0);
		double Sell3_2 = iLow(NULL, 0, Current + 2);
   		if (Buy1_1 <= Buy1_2 && Buy2_1 > Buy2_2 && Buy3_1 > Buy3_2) Order = 1;
   		if (Sell1_1 >= Sell1_2 && Sell2_1 < Sell2_2 && Sell3_1 < Sell3_2) Order = -1;
   		if(Order==1) upArrow[i] = Low[i];
   		if(Order==-1) dnArrow[i] = High[i]+0.5*iATR(NULL,0,10,i+1);
   	}
   return(0);
}
//+------------------------------------------------------------------+