//+------------------------------------------------------------------+ //| MA Other TimeFrame Correct.mq5 | //| Copyright © 2021, Vladimir Karputov | //| https://www.mql5.com/ru/market/product/43516 | //+------------------------------------------------------------------+ #property copyright "Copyright © 2021, Vladimir Karputov" #property link "https://www.mql5.com/ru/market/product/43516" #property version "1.001" #property indicator_chart_window #property indicator_buffers 1 #property indicator_plots 1 //--- the iMA plot #property indicator_label1 "MA" #property indicator_type1 DRAW_SECTION #property indicator_color1 clrMediumPurple #property indicator_style1 STYLE_SOLID #property indicator_width1 2 //--- indicator buffer double iMABuffer[]; //--- input parameters input group "MA" input ENUM_TIMEFRAMES Inp_MA_period_other = PERIOD_D1; // MA: other timeframe input int Inp_MA_ma_period = 12; // MA: averaging period input int Inp_MA_ma_shift = 0; // MA: horizontal shift input ENUM_MA_METHOD Inp_MA_ma_method = MODE_SMA; // MA: smoothing type input ENUM_APPLIED_PRICE Inp_MA_applied_price = PRICE_CLOSE; // MA: type of price //--- datetime m_prev_bars = 0; // "0" -> D'1970.01.01 00:00'; datetime m_prev_bars_other = 0; // "0" -> D'1970.01.01 00:00'; int handle_iMA = INVALID_HANDLE; // variable for storing the handle of the iMA indicator bool m_init_error = false; // error on InInit //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- assignment of array to indicator buffer SetIndexBuffer(0,iMABuffer,INDICATOR_DATA); //--- set shift PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0.0); //--- if(Inp_MA_period_other==PERIOD_CURRENT || Inp_MA_period_other