//+------------------------------------------------------------------+ //| Rj_Slice.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 DepthCalcDay = 5; extern double UpdateTime = 1; extern bool BackgroundLevelOn = true; double lBuy[]; double lSell[]; static datetime LastTime=0; static datetime StartTime=1; int init() { return(0); } int deinit() { for (int i=0; i<3000; i++) {ObjectDelete("vhb "+i); ObjectDelete("V "+i);} return(0); } int start() { if(LastTime < StartTime) { int i, j, MaxVolume, EndTime, VolSlice; color ColLine; int TimeVisiblBar = WindowBarsPerChart()-WindowFirstVisibleBar(); double MaxPrice = iHigh(NULL, PERIOD_D1, 0); double MinPrice = iLow(NULL, PERIOD_D1, 0); for(j=DepthCalcDay; j>=0; j--) { MaxPrice = MathMax(MaxPrice, iHigh(NULL, PERIOD_D1, j)); MinPrice = MathMin(MinPrice, iLow(NULL, PERIOD_D1, j)); } int Range = MathRound((MaxPrice-MinPrice)/Point); ArrayResize(lBuy, Range+1); ArrayInitialize(lBuy, 0.0); ArrayResize(lSell, Range+1); ArrayInitialize(lSell, 0.0); for(i=0; i<=Range; i++) { lBuy[i] = iCustom(NULL, PERIOD_M1, "Rj_Volume", DepthCalcDay, 0, i); lSell[i] = iCustom(NULL, PERIOD_M1, "Rj_Volume", DepthCalcDay, 1, i); } if(MathRound(lBuy[ArrayMaximum(lBuy)])>=MathRound(lSell[ArrayMaximum(lSell)])) MaxVolume=MathRound(lBuy[ArrayMaximum(lBuy)]); else MaxVolume=MathRound(lSell[ArrayMaximum(lSell)]); if(TimeVisiblBar<=2) TimeVisiblBar=50; for (i=0; i<=Range; i++) {ObjectDelete("vhb "+i); ObjectDelete("V "+i);} for(i=0; i<=Range; i++) { if(BackgroundLevelOn) { if(lBuy[i]>lSell[i]) { ColLine=C'64,136,50'; } if(lBuy[i]lSell[i]) { EndTime = TimeStart()-(TimeVisiblBar-1)*Period()*60; ColLine=C'64,136,50'; } if(lBuy[i]ArrSell[shift]) DifBuy[shift]=MathRound((ArrBuy[shift]-ArrSell[shift])*100); if(ArrBuy[shift]