//------------------------------------------------------------------ #property copyright "mladen" #property link "mladen" //------------------------------------------------------------------ #property indicator_chart_window #property indicator_buffers 2 #property indicator_plots 1 #property indicator_label1 "hull" #property indicator_type1 DRAW_COLOR_LINE #property indicator_color1 clrLimeGreen,clrOrange #property indicator_style1 STYLE_SOLID #property indicator_width1 2 // // // // // enum enPrices { pr_close, // Close pr_open, // Open pr_high, // High pr_low, // Low pr_median, // Median pr_typical, // Typical pr_weighted, // Weighted pr_average // Average (high+low+oprn+close)/4 }; input double HmaLength = 14; // Hull period input double HmaPower = 1; // Hull power input enPrices Price = pr_close; // Price double hull[]; double colorInd[]; //------------------------------------------------------------------ // //------------------------------------------------------------------ // // // // // int OnInit() { SetIndexBuffer(0,hull ,INDICATOR_DATA); SetIndexBuffer(1,colorInd,INDICATOR_COLOR_INDEX); return(0); } //------------------------------------------------------------------ // //------------------------------------------------------------------ // // // // // int OnCalculate(const int rates_total, const int prev_calculated, const datetime& time[], const double& open[], const double& high[], const double& low[], const double& close[], const long& tick_volume[], const long& volume[], const int& spread[]) { // // // // // int HalfPeriod = (int)MathFloor(HmaLength/2); int HullPeriod = (int)MathFloor(MathSqrt(HmaLength)); for (int i=(int)MathMax(prev_calculated-1,1); ihull[i-1]) colorInd[i] = 0; if (hull[i]=0; k++) { double weight = period-k; sumw += MathPow(weight,power); sum += MathPow(weight,power)*workLwmp[r-k][instanceNo]; } return(sum/sumw); }