//+------------------------------------------------------------------+ //| EWO.mq4 | //| Copyright © 2005-2006, David W. Thomas | //| http://www.davidwt.com | //+------------------------------------------------------------------+ // Elliott Wave Oscillator #property copyright "Copyright © 2005-2006, David W. Thomas" #property link "http://www.davidwt.com" #property indicator_separate_window #property indicator_buffers 1 #property indicator_color1 Sienna //---- buffers double EWOBuffer[]; //---- variables int indexbegin = 0; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexStyle(0, DRAW_LINE); SetIndexBuffer(0, EWOBuffer); SetIndexLabel(0, "EWO"); //---- IndicatorShortName("EWO"); indexbegin = Bars - 35; if (indexbegin < 0) indexbegin = 0; return(0); } //+------------------------------------------------------------------+ //| Custor indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int i; int counted_bars = IndicatorCounted(); //---- check for possible errors if (counted_bars < 0) counted_bars = 0; //---- last counted bar will be recounted if (counted_bars > 0) counted_bars--; if (counted_bars > indexbegin) counted_bars = indexbegin; for (i = 0; i < indexbegin-counted_bars; i++) { //! compute EWO for the current bar. If EWO is > 0, then the 5SMA is above //! the 35SMA. If EWO < 0, then the 5SMA is below the 35SMA. EWOBuffer[i] = iMA(NULL, 0, 5, 0, MODE_SMA, PRICE_MEDIAN, i) - iMA(NULL, 0, 35, 0, MODE_SMA, PRICE_MEDIAN, i); } return(0); } //+------------------------------------------------------------------+