I am trying to create a simple strategy for mt4 to check if the sequence of candlesticks are: buy, sell, sell, buy, sell and the last sell candlestick breaksout the previously buy candle but it is not working.
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Aqua
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int init() {
SetIndexStyle(0,DRAW_ARROW,STYLE_SOLID,1);
SetIndexStyle(1,DRAW_ARROW,STYLE_SOLID,1);
SetIndexArrow(1,233);
SetIndexArrow(0,234);
///
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start() {
int counted_bars=IndicatorCounted();
int k,i,j,limit,hhb,llb;
if (counted_bars<0) return(-1);
if (counted_bars>0) counted_bars--;
limit=Bars-1;
if(counted_bars>=1) limit=Bars-counted_bars-1;
if (limit<0) limit=0;
for(i=limit;i>=0;i--) {
// Verificar se a sequência é "compra, venda, venda, compra, venda"
if(Close[1]<Open[2] && Close[2] > Open[2] && Close[3] < Close[4] && Close[4] < Open[4] && Close[5] > Open[5] )
{
return(-1);
}
}
return(0);
}
//+------------------------------------------------------------------+
but does not show the signal for sell in the next candle bearish.