help for modify indicator, please convert line to histogram. New comment Rajesh Kumar 2012.10.11 12:01 //------------------------------------------------------------------ #property copyright "www.raptor__.cm" #property link "www.raptor__.cm" //------------------------------------------------------------------ #property indicator_separate_window #property indicator_buffers 1 #property indicator_color1 PaleVioletRed #property indicator_width1 2 #property indicator_level1 0 // // // // // extern int Length = 14; extern int Price = 0; double vel[]; //------------------------------------------------------------------ // //------------------------------------------------------------------ // // // // // int init() { SetIndexBuffer(0,vel); IndicatorShortName("velocity ("+Length+")"); return(0); } int start() { int counted_bars=IndicatorCounted(); if(counted_bars<0) return(-1); if(counted_bars>0) counted_bars--; int limit = MathMin(Bars-counted_bars,Bars-1); // // // // // for(int i=limit; i>=0; i--) vel[i] = iVelocity(iMA(NULL,0,1,0,MODE_SMA,Price,i),Length,i); return(0); } //------------------------------------------------------------------ // //------------------------------------------------------------------ // // // // // double prices[]; double iVelocity(double price, double length, int i) { if (ArraySize(prices)!=Bars) ArrayResize(prices,Bars); i=Bars-i-1; prices[i] = price; double suma = 0.0, sumwa=0; double sumb = 0.0, sumwb=0; for(int k=0; k<length; k++) { double weight = length-k; suma += prices[i-k] * weight; sumb += prices[i-k] * weight * weight; sumwa += weight; sumwb += weight*weight; } return(sumb/sumwb-suma/sumwa); } William Roeder 2012.10.11 17:48 #1 SetIndexStyle(0,DRAW_HISTOGRAM); New comment