//+------------------------------------------------------------------+ //| Spread Record.mq4 | //| Copyright 2015, MetaQuotes Software Corp. | //| http://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2015, Vasiliy Sokolov." #property link "https://www.mql5.com/ru/users/c-4" #property version "1.00" #property description "Recording spread and show it." #property indicator_separate_window #property indicator_buffers 5 #property indicator_plots 5 #property indicator_type1 DRAW_BARS #property indicator_type2 DRAW_ARROW #property indicator_color1 clrBlack #property indicator_color2 clrBlack double spread_open[]; double spread_high[]; double spread_low[]; double spread_close[]; double spread_avrg[]; int elements; double avrg_current; int count; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping SetIndexBuffer(0,spread_open,INDICATOR_DATA); SetIndexBuffer(1,spread_high,INDICATOR_DATA); SetIndexBuffer(2,spread_low,INDICATOR_DATA); SetIndexBuffer(3,spread_close,INDICATOR_DATA); SetIndexBuffer(4,spread_avrg,INDICATOR_DATA); IndicatorSetInteger(INDICATOR_DIGITS,1); PlotIndexSetInteger(1,PLOT_ARROW,0x9f); PlotIndexSetInteger(0,PLOT_LINE_COLOR,clrRed); PlotIndexSetInteger(1,PLOT_LINE_COLOR,clrGreen); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { printf("DEINIT"); } //+------------------------------------------------------------------+ //| 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(prev_calculated==0) { printf("INITIALIZE INDICATORS "+TimeToString(TimeCurrent())); double init_value=EMPTY_VALUE; ArrayInitialize(spread_high,init_value); ArrayInitialize(spread_low,init_value); ArrayInitialize(spread_open,init_value); ArrayInitialize(spread_close,init_value); ArrayInitialize(spread_avrg,init_value); elements=ArraySize(spread_high); InitNewBar(elements-1); } //--- new bar initialization for(; elementsspread_high[i]) spread_high[i]=d; if(d