//+------------------------------------------------------------------+ //| Trend OBJ_REGRESSION.mq5 | //| Copyright © 2019, Vladimir Karputov | //| http://wmua.ru/slesar/ | //+------------------------------------------------------------------+ #property copyright "Copyright © 2019, Vladimir Karputov" #property link "http://wmua.ru/slesar/" #property version "1.000" #property indicator_separate_window #property indicator_buffers 1 #property indicator_plots 1 //--- plot Channel #property indicator_label1 "Trend" #property indicator_type1 DRAW_LINE #property indicator_color1 clrOrchid #property indicator_style1 STYLE_SOLID #property indicator_width1 1 //--- input parameters input uchar InpChannelBars = 30; // Channel Bars input string InpName = "Regression"; // Channel name input color InpColor = clrDeepPink; // Channel color input ENUM_LINE_STYLE InpStyle = STYLE_DASH; // Style of channel lines input int InpWidth = 2; // Width of channel lines input bool InpFill = false; // Filling the channel with color input bool InpBack = false; // Background channel input bool InpSelection = false; // Highlight to move input bool InpHidden = true; // Hidden in the object list input long InpZOrder = 0; // Priority for mouse click //--- indicator buffers double ChannelBuffer[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping SetIndexBuffer(0,ChannelBuffer,INDICATOR_DATA); //--- set accuracy IndicatorSetInteger(INDICATOR_DIGITS,0); //--- name for DataWindow IndicatorSetString(INDICATOR_SHORTNAME,"Trend("+string(InpChannelBars)+")"); //---- sets drawing line empty value PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0.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[]) { /* time[0] -> D'2018.01.02 00:00:00' time[rates_total-1] -> D'2018.12.31 22:00:00' */ //--- if(rates_total