//+------------------------------------------------------------------+"); //| Custom indicator initialization function |"); //| Called by Alveo to initialize the EMA Indicator at startup. |"); //+------------------------------------------------------------------+"); protected override int Init() { try { // ENTER YOUR CODE HERE IndicatorBuffers(indicator_buffers); // Allocates memory for buffers used for custom indicator calculations. SetIndexBuffer(0, UpTrend); // binds a specified indicator buffer with one-dimensional dynamic array of the type double. SetIndexArrow(0, 159); // Sets an arrow symbol for indicators line of the DRAW_ARROW type. 159=dot. SetIndexBuffer(1, DownTrend); // repeat for each buffer SetIndexArrow(1, 159); SetIndexBuffer(2, Consolidation); SetIndexArrow(2, 159); SetIndexStyle(0, DRAW_LINE, STYLE_SOLID); // Sets the shape, style, width and color for the indicator line. SetIndexLabel(0, "EMA(" + IndPeriod + ").Bull"); // Sets description for showing in the DataWindow and in the tooltip on Chart. SetIndexStyle(1, DRAW_LINE, STYLE_SOLID); // repeat for all 3 buffers SetIndexLabel(1, "EMA(" + IndPeriod + ").Bear"); SetIndexStyle(2, DRAW_LINE, STYLE_SOLID); SetIndexLabel(2, "EMA(" + IndPeriod + ").Mixed"); // Sets the "short" name of a custom indicator to be shown in the DataWindow and in the chart subwindow. IndicatorShortName("EMA3 v1.0 (" + IndPeriod + "," + SlopeThreshold + ")"); ema = new EMAobj(IndPeriod, SlopeThreshold); Print("EMA: Started. [" + Chart.Symbol + "] period=" + Period()); // Print this message to Alveo Log file on startup } catch (Exception ex) { Print("EMA: Init: Exception: " + ex.Message); Print("EMA: " + ex.StackTrace); } return(0); // done }
internal HEMAobj(int period, int threshold) : this() // do HEMA() first { Period = period; Threshold = (double)threshold * 1e-6; sqrtPeriod = Math.Sqrt(Period); ema1 = new EMAobj(period, threshold); ema2 = new EMAobj(period / 2, threshold); ema3 = new EMAobj(sqrtPeriod, threshold); }
internal DTEMAobj(int period, int threshold) : this() { if (period < 1) { throw new Exception("DTEMAobj: period < 1, invalid !!"); } if (threshold < 1) { throw new Exception("DTEMAobj: Threshold < 1, invalid !!"); } Period = (double)period; Threshold = (double)threshold * 1e-6; EMA1 = new EMAobj(Period, threshold); EMA2 = new EMAobj(Period, threshold); EMA3 = new EMAobj(Period, threshold); }