#property copyright "© 2003-2006 AINUR, RickD" #property indicator_separate_window #property indicator_buffers 2 #property indicator_color1 DodgerBlue #property indicator_color2 Red //extern int MaxBars = 1000; extern int ATRPeriod = 14; double buf1[]; double buf2[]; double hi, lo, kr, no, kk, kn; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ void init() { SetIndexBuffer(0, buf1); SetIndexBuffer(1, buf2); SetIndexStyle(0, DRAW_HISTOGRAM); SetIndexStyle(1, DRAW_HISTOGRAM); //SetIndexDrawBegin(0, Bars-MaxBars); //SetIndexDrawBegin(1, Bars-MaxBars); hi = 0; lo = 0; kr = 0; no = 0; kk = 0; kn = 0; } void start() { int counted = IndicatorCounted(); if (counted < 0) return (-1); if (counted > 0) counted--; int limit = Bars-counted; limit = MathMin(limit, Bars-ATRPeriod); //limit = MathMin(limit, MaxBars); double ATR, cur; for (int i=limit; i >= 0; i--) { ATR = iATR(NULL, 0, ATRPeriod, i); cur = Open[i]; if (hi == 0) hi = Open[i]; if (lo == 0) lo = Open[i]; if (cur > (hi+ATR)) { kk = MathCeil((cur-(hi+ATR))/ATR); //if (kk <= 1) kk = 1; hi = cur; lo = cur-ATR; kr = kr+kk; no = 0; } if (cur < (lo-ATR)) { kn = MathCeil(((lo-ATR)-cur)/ATR); //if (kn <= 1) kn = 1; lo = cur; hi = cur+ATR; no = no+kn; kr = 0; } buf1[i] = kr; buf2[i] = -no; } }
Sample
Analysis
Market Information Used:
Series array that contains open prices of each bar
Indicator Curves created:
Implements a curve of type DRAW_HISTOGRAM
Indicators Used:
Indicator of the average true range
Custom Indicators Used:
Order Management characteristics:
Other Features: