//+------------------------------------------------------------------+ //| BOS.mq5 | //| Copyright 2012, MetaQuotes Software Corp. | //| http://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2012, MetaQuotes Software Corp." #property link "http://www.mql5.com" #property version "1.00" #property indicator_separate_window #property indicator_buffers 9 #property indicator_plots 1 //--- plot Label1 #property indicator_label1 "BuyOrSellColor" #property indicator_type1 DRAW_COLOR_CANDLES #property indicator_color1 clrRed, clrBlue, clrWhite //--- входные параметры input double Delta=0.0010; double ExtBuyOrSell[]; double ExtOpenBuffer[]; double ExtHighBuffer[]; double ExtLowBuffer[]; double ExtCloseBuffer[]; double ExtColorsBuffer[]; //+------------------------------------------------------------------+ //| Пользовательские функции, инициализация индикаторов | //+------------------------------------------------------------------+ int OnInit() { //--- Отображение буферов индикатора SetIndexBuffer(5,ExtBuyOrSell,INDICATOR_DATA); SetIndexBuffer(0,ExtOpenBuffer,INDICATOR_DATA); SetIndexBuffer(1,ExtHighBuffer,INDICATOR_DATA); SetIndexBuffer(2,ExtLowBuffer,INDICATOR_DATA); SetIndexBuffer(3,ExtCloseBuffer,INDICATOR_DATA); SetIndexBuffer(4,ExtColorsBuffer,INDICATOR_COLOR_INDEX); //--- Устанавливает 1-ый бар от того, что будет индекс обращен PlotIndexSetInteger(0,PLOT_COLOR_INDEXES,2); //--- Количество цифр значения индикатора IndicatorSetInteger(INDICATOR_DIGITS,_Digits); printf("We have %u colors of days",PlotIndexGetInteger(0,PLOT_COLOR_INDEXES)); return(0); } static int buy,sell,ost,pos; double pecentb,pecents; //+------------------------------------------------------------------+ //| Настройка индекса цвета | //+------------------------------------------------------------------+ int getIndexOfColor(int i) { if (ExtBuyOrSell[i]<=-Delta) return(0);// first index if (ExtBuyOrSell[i]>=Delta) return(1);// second index return(2); // third index } //+------------------------------------------------------------------+ //| Пользовательские функции, итерации индикатора | //+------------------------------------------------------------------+ 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) pos=0; else pos=prev_calculated-1; //--- Главный цикл for(int i=pos;i=Delta && pos>prev_calculated-1) buy++; ExtColorsBuffer[i]=getIndexOfColor(i); if ((open[i]-close[i])<=-Delta && pos>prev_calculated-1) sell++; ExtColorsBuffer[i]=getIndexOfColor(i); if ((open[i]-close[i])>-Delta && (open[i]-close[i])prev_calculated-1) ost++; ExtColorsBuffer[i]=getIndexOfColor(i); } pecentb=(double)buy/ArraySize(ExtBuyOrSell)*100; pecents=(double)sell/ArraySize(ExtBuyOrSell)*100; Print("ОБЩЕЕ КРОЛИЧЕСТВО СВЕЧЕЙ ",ArraySize(ExtBuyOrSell)); Print("Процент свечей для покупки ",pecentb); Print("Количество свечей для покупки ",buy); Print("Процент свечей для покупки ",pecents); Print("Количество свечей для продажи ",sell); Print("Количество остальных свечей ",ost); //--- Вернуть значение prev_calculated для следующего вызова return(rates_total); }