#property indicator_separate_window #property indicator_buffers 2 #property indicator_color1 Blue #property indicator_color2 Red //---- input parameters extern int period=30; //---- buffers double buf1[]; double buf2[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexStyle(0,DRAW_HISTOGRAM); SetIndexBuffer(0,buf1); SetIndexStyle(1,DRAW_HISTOGRAM); SetIndexBuffer(1,buf2); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int limit; int counted_bars=IndicatorCounted(); //---- last counted bar will be recounted if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; double up_count,down_count; //---- //расчет среднего количества баров за период======================= for (int i = limit; i>=0; i--) { if(i<period){period =i;} up_count=0; down_count=0; for(int y=i; y<i+period; y++) { if (Close[y+1]<Close[y]){up_count++;}// бычья свеча if (Close[y+1]>Close[y]){down_count++;}//медвежья свеча } buf1[i] = up_count; buf2[i] = down_count*(-1); } //---- return(0); } //+------------------------------------------------------------------+Вот так.
сравните со своим кодом и увидите ошибки.
Вы упускаете торговые возможности:
- Бесплатные приложения для трейдинга
- 8 000+ сигналов для копирования
- Экономические новости для анализа финансовых рынков
Регистрация
Вход
Вы принимаете политику сайта и условия использования
Если у вас нет учетной записи, зарегистрируйтесь
почему не прорисовываеться индикатор. суть идеи, показывать за определенный период сколько бычьих сечей, а сколько медвежьих