//+------------------------------------------------------------------+ //| Oracle Move.mq4 | //| Copyright 2016, MetaQuotes Software Corp. | //| https://www.mql5.com | //| Modification by http://www.daytradingsite.com| //+------------------------------------------------------------------+ #property copyright "Copyright 2016, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.00" #property strict #property indicator_chart_window #property indicator_buffers 2 #property indicator_color1 clrRed #property indicator_color2 clrBlue input int MA_Period = 30; input ENUM_APPLIED_PRICE Applied_price = PRICE_CLOSE; //--- double Buffer1[]; double Buffer2[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 2); SetIndexStyle(1, DRAW_LINE, STYLE_SOLID, 2); SetIndexBuffer(0, Buffer1); SetIndexBuffer(1, Buffer2); IndicatorDigits(Digits + 1); IndicatorShortName("Oracle Move"); return (0); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { //--- int limit = 1; if(prev_calculated==0) { limit = rates_total -1; for (int i = limit; i >1; i--) { Buffer1[i] = 0; Buffer2[i] = 0; } } for (int i = limit; i >=0; i--) { Buffer2[i] = 2.0 * iMA(NULL, 0, (int)MathFloor(MA_Period / 2), 0, MODE_LWMA, Applied_price, i) - iMA(NULL, 0, MA_Period, 0, MODE_LWMA, Applied_price, i); Buffer1[i] = iMAOnArray(Buffer2, 0, (int)MathFloor(MathSqrt(MA_Period)), 0, MODE_LWMA, i); } //--- return value of prev_calculated for next call return(rates_total); }