//+------------------------------------------------------------------+ //| | //| TrailCD.mq4 | //|Индикатор | //|Схождение/расхождение быстрого и медленного тралов | //+------------------------------------------------------------------+ #property copyright "mandorr@gmail.com" #property indicator_separate_window #property indicator_buffers 1 #property indicator_color1 SkyBlue #property indicator_maximum 0.0050 #property indicator_minimum -0.0050 //---- extern int TrailFast=25; // Быстрый трал extern int TrailSlow=65; // Медленный трал extern int CountBars=1000; // Количество отображаемых баров //---- double buffer[]; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void init() { SetIndexStyle(0,DRAW_HISTOGRAM,0,2); SetIndexBuffer(0,buffer); SetIndexLabel(0,"Value"); SetIndexDrawBegin(0,0); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void start() { ArrayInitialize(buffer,0); int price=MathRound(Close[CountBars-1]/Point); int value_fast=price; int value_slow=price; for(int i=CountBars-1;i>=0;i--) { price=MathRound(Close[i]/Point); if (value_fastprice+TrailFast) value_fast=price+TrailFast; if (value_slowprice+TrailSlow) value_slow=price+TrailSlow; buffer[i]=(value_fast-value_slow)*Point; } } //+------------------------------------------------------------------+