//+------------------------------------------------------------------+ //| iPeriodPhasing.mq5 | //| Arthur Albano | //| https://www.mql5.com/en/users/arthuralbano | //+------------------------------------------------------------------+ #property copyright "Arthur Albano" #property link "https://www.mql5.com/en/users/arthuralbano" #property version "1.00" #property indicator_buffers 2 #property indicator_plots 2 #property indicator_separate_window #property indicator_label1 "iOHLC4" #property indicator_type1 DRAW_LINE #property indicator_color1 clrFuchsia #property indicator_style1 STYLE_SOLID #property indicator_width1 2 //--- signum macro #define sgn(a) (a!=0) ? int(a/fabs(a)) : 0; //--- indicator buffers double iOHLC4[], d, iPeriodPhase[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { SetIndexBuffer(0,iOHLC4,INDICATOR_DATA); SetIndexBuffer(1,iPeriodPhase,INDICATOR_CALCULATIONS); IndicatorSetString(INDICATOR_SHORTNAME,"iOHLC4"); IndicatorSetInteger(INDICATOR_DIGITS,_Digits); 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[]) { if(Bars(_Symbol,_Period)