//+------------------------------------------------------------------+ //| Rj_ActivMarket.mq4 | //| Copyright © 2011, RJ Rjabkov Aleksandr | //| rj-a@mail.ru | //+------------------------------------------------------------------+ #property copyright "Copyright © 2011, RJ Rjabkov Aleksandr" #property link "rj-a@mail.ru" #property indicator_chart_window extern int smooth=12; double VSlice[]; double Buff[]; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int init() { IndicatorBuffers(2); SetIndexBuffer(0,VSlice); SetIndexBuffer(1,Buff); return(0); } //*************** int deinit() {for(int i=0; i<=200; i++) {ObjectDelete("m "+i);} ObjectDelete("marks"); return(0);} //*************** int start() { int i,cb; int counted_bars = IndicatorCounted(); if(counted_bars < 0) return(-1); if(counted_bars > 0) counted_bars--; int limit = Bars - counted_bars; if(counted_bars==0) limit-=1+smooth; cb=limit; for(i=cb; i>=0; i--) Buff[i]=Volume[i]/(Period()*60); for(i=cb; i>=0; i--) VSlice[i]=smooth(Buff,smooth,i); int PercentActive=MathRound(VSlice[0]*100); double Marks=NormalizeDouble(VSlice[0]*100,2); color r=255,g=255,b=0; int CoordTime1=Time[0]+(WindowBarsPerChart()-WindowFirstVisibleBar()-3)*Period()*60; int CoordTime2=Time[0]+(WindowBarsPerChart()-WindowFirstVisibleBar()-6)*Period()*60; double CoordPrice=WindowPriceMin()+5*Point; color ColLine; for(i=0; i<=200; i++) {ObjectDelete("m "+i);} ObjectDelete("marks"); for(i=0; i<=PercentActive; i++) { if(g<0) g=0; ColLine=r+g*256+b*65536; ObjectCreate("m "+i,OBJ_TREND,0,0,0,0,0); ObjectSet("m "+i,OBJPROP_TIME1,CoordTime1); ObjectSet("m "+i,OBJPROP_TIME2,CoordTime2); ObjectSet("m "+i,OBJPROP_PRICE1,CoordPrice); ObjectSet("m "+i,OBJPROP_PRICE2,CoordPrice); ObjectSet("m "+i,OBJPROP_STYLE,DRAW_LINE); ObjectSet("m "+i,OBJPROP_WIDTH,3); ObjectSet("m "+i,OBJPROP_COLOR,ColLine); ObjectSet("m "+i,OBJPROP_BACK,false); ObjectSet("m "+i,OBJPROP_RAY,false); g-=2; CoordPrice+=0.00005; } ObjectCreate("marks",OBJ_TEXT,0,((CoordTime2-CoordTime1)/2)+CoordTime1,CoordPrice+4*Point); ObjectSetText("marks",DoubleToStr(Marks,2)+"%",8,"Arial",ColLine); return(0); } //+------------------------------------------------------------------+ double smooth(double smooth_name[],int smooth,int count) { double result; int smoothed=smooth+count; while(smoothed>count) { result+=smooth_name[smoothed-1]; smoothed--; } result=result/smooth; return(result); } //+------------------------------------------------------------------+