Скачать MetaTrader 5

индикатор работает только на истории, в реал рисует только 2 последних значения... помогите...

Авторизуйтесь или зарегистрируйтесь, чтобы добавить комментарий
Михаил
1025
Михаил  

код индкикатора

#property copyright "Copyright © 2007"
#property link      "http://www.metaquotes.net"

#property indicator_separate_window
#property indicator_minimum -0.05
#property indicator_maximum 1.05
#property indicator_buffers 7
#property indicator_color1 Aqua
#property indicator_color2 LawnGreen
#property indicator_color3 LimeGreen
#property indicator_color4 Yellow
#property indicator_color5 SaddleBrown
#property indicator_color6 OrangeRed
#property indicator_color7 Orange

extern int ma_period = 34;
int CountedBars = 0;
double buf_0[];
double buf_1[];
double buf_2[];
double buf_3[];
double buf_4[];
double buf_5[];
double buf_6[];

int init() {
   SetIndexStyle(0, DRAW_HISTOGRAM, STYLE_SOLID, 3, Aqua);
   SetIndexStyle(1, DRAW_HISTOGRAM, STYLE_SOLID, 3, LawnGreen);
   SetIndexStyle(2, DRAW_HISTOGRAM, STYLE_SOLID, 3, LimeGreen);
   SetIndexStyle(3, DRAW_HISTOGRAM, STYLE_SOLID, 3, Yellow);
   SetIndexStyle(4, DRAW_HISTOGRAM, STYLE_SOLID, 3, SaddleBrown);
   SetIndexStyle(5, DRAW_HISTOGRAM, STYLE_SOLID, 3, OrangeRed);
   SetIndexStyle(6, DRAW_HISTOGRAM, STYLE_SOLID, 3, Orange);
   SetIndexBuffer(0, buf_0);
   SetIndexBuffer(1, buf_1);
   SetIndexBuffer(2, buf_2);
   SetIndexBuffer(3, buf_3);
   SetIndexBuffer(4, buf_4);
   SetIndexBuffer(5, buf_5);
   SetIndexBuffer(6, buf_6);
   IndicatorShortName("CZI_Heart_v1");
   SetIndexLabel(0, "Strong UpTrend / ZLR long OK");
   SetIndexLabel(1, "Retrace UpTrend");
   SetIndexLabel(2, "Choppy UpTrend");
   SetIndexLabel(3, "Flat Trend");
   SetIndexLabel(4, "Strong DownTrend / ZLR short OK");
   SetIndexLabel(5, "Retrace DownTrend");
   SetIndexLabel(6, "Choppy DownTrend");
   return (0);
}

int start() {
   double MA;
   double close;
   for (int n = Bars; n >= 0; n--) {
      buf_0[n] = 0.0;
      buf_1[n] = 0.0;
      buf_2[n] = 0.0;
      buf_3[n] = 0.0;
      buf_4[n] = 0.0;
      buf_5[n] = 0.0;
      buf_6[n] = 0.0;
   }
   if (Bars <= 10) return (0);
   CountedBars = IndicatorCounted();
   if (CountedBars < 0) return (-1);
   if (CountedBars > 0) CountedBars--;
   for (int i = Bars - CountedBars - 1; i >= 0; i--) {
      MA = iMA(Symbol(), Period(), ma_period, 0, MODE_EMA, PRICE_CLOSE, i);
      close = iClose(Symbol(), Period(), i);
      if (close / MA > 1.00015) {
         buf_0[i] = 1.0;
         buf_1[i] = 0.0;
         buf_2[i] = 0.0;
         buf_3[i] = 0.0;
         buf_4[i] = 0.0;
         buf_5[i] = 0.0;
         buf_6[i] = 0.0;
      }
      if (close / MA > 1.0001 && close / MA <= 1.00015) {
         buf_0[i] = 0.0;
         buf_1[i] = 1.0;
         buf_2[i] = 0.0;
         buf_3[i] = 0.0;
         buf_4[i] = 0.0;
         buf_5[i] = 0.0;
         buf_6[i] = 0.0;
      }
      if (close / MA > 1.0 && close / MA <= 1.0001) {
         buf_0[i] = 0.0;
         buf_1[i] = 0.0;
         buf_2[i] = 1.0;
         buf_3[i] = 0.0;
         buf_4[i] = 0.0;
         buf_5[i] = 0.0;
         buf_6[i] = 0.0;
      }
      if (close / MA > 0.99992 && close / MA <= 1.0) {
         buf_0[i] = 0.0;
         buf_1[i] = 0.0;
         buf_2[i] = 0.0;
         buf_3[i] = 1.0;
         buf_4[i] = 0.0;
         buf_5[i] = 0.0;
         buf_6[i] = 0.0;
      }
      if (close / MA < 0.9997) {
         buf_0[i] = 0.0;
         buf_1[i] = 0.0;
         buf_2[i] = 0.0;
         buf_3[i] = 0.0;
         buf_4[i] = 1.0;
         buf_5[i] = 0.0;
         buf_6[i] = 0.0;
      }
      if (close / MA < 0.99985 && close / MA >= 0.9997) {
         buf_0[i] = 0.0;
         buf_1[i] = 0.0;
         buf_2[i] = 0.0;
         buf_3[i] = 0.0;
         buf_4[i] = 0.0;
         buf_5[i] = 1.0;
         buf_6[i] = 0.0;
      }
      if (close / MA < 0.99992 && close / MA >= 0.99985) {
         buf_0[i] = 0.0;
         buf_1[i] = 0.0;
         buf_2[i] = 0.0;
         buf_3[i] = 0.0;
         buf_4[i] = 0.0;
         buf_5[i] = 0.0;
         buf_6[i] = 1.0;
      }
   }
   return (0);
}

где ошибка, помогите исправить...

Nikolaj
305
Nikolaj  
dmmikl86:

код индкикатора

где ошибка, помогите исправить...


..................
int start() {
   double MA;
   double close;
    int i,counted_bars=IndicatorCounted();
   i=Bars-counted_bars -1;
   int limit =Bars-counted_bars;
   if (limit>1) {
      limit = Bars-ma_period-1;
   }
  for (i=limit;i>=0;i--) {
      buf_0[i] = 0.0;
      buf_1[i] = 0.0;
      buf_2[i] = 0.0;
      buf_3[i] = 0.0;
      buf_4[i] = 0.0;
      buf_5[i] = 0.0;
      buf_6[i] = 0.0;
   }
  for (i=limit;i>=0;i--)  .........
Михаил
1025
Михаил  
nikost:


огромное спасибо
Авторизуйтесь или зарегистрируйтесь, чтобы добавить комментарий