//+------------------------------------------------------------------+ //| Breakout bars | //| (C) 2008 mikkom, contact: mikko.mattila@kirkas.com | //| | //+------------------------------------------------------------------+ #property copyright "mikkom" //#property indicator_separate_window #property indicator_chart_window #property indicator_buffers 4 #property indicator_color1 Red #property indicator_color2 Green #property indicator_color3 Red #property indicator_color4 Green double red[]; double redBody[]; double greenBody[]; double green[]; extern int count = 20; extern int period = 0; int init() { IndicatorBuffers(4); SetIndexBuffer(0, red); SetIndexStyle(0, DRAW_HISTOGRAM, EMPTY, 1); SetIndexBuffer(1, green); SetIndexStyle(1, DRAW_HISTOGRAM, EMPTY, 1); SetIndexBuffer(2, redBody); SetIndexStyle(2, DRAW_HISTOGRAM, EMPTY, 4); SetIndexBuffer(3, greenBody); SetIndexStyle(3, DRAW_HISTOGRAM, EMPTY, 4); IndicatorShortName("Mikko breakout bars "+count+"/"+period); if(period == 0) period = Period(); return(0); } int deinit() { return(0); } int start() { int counted_bars=IndicatorCounted(); if(counted_bars < 0) return(-1); if(counted_bars > 0) counted_bars--; int limit = Bars - counted_bars; for(int i = limit; i >= 0; i--) { int s = iBarShift(Symbol(), period, Time[i], true); double mmLow = iLow(Symbol(),period,iLowest(Symbol(),period,MODE_LOW,count,s+1)); double mmHigh = iHigh(Symbol(),period,iHighest(Symbol(),period,MODE_HIGH,count,s+1)); if(High[i] > mmHigh) { green[i] = High[i]; red[i] = Low[i]; greenBody[i] = MathMax(Open[i], Close[i]); redBody[i] = MathMin(Open[i], Close[i]); } if(Low[i] < mmLow) { red[i] = High[i]; green[i] = Low[i]; redBody[i] = MathMax(Open[i], Close[i]); greenBody[i] = MathMin(Open[i], Close[i]); } } return(0); }