Status
Open
Budget
15.00 EUR
Payment Method
Direct Payment
Job Description
Need convert MT5 indi (open code) to CTrader.
Thanks.
#property indicator_separate_window #property indicator_buffers 11 #property indicator_plots 1 #property indicator_label1 "Trend" #property indicator_type1 DRAW_COLOR_HISTOGRAM #property indicator_color1 clrLightGray,clrPaleGreen,clrGreen,clrBlue,clrLightCoral,clrRed,clrMagenta #property indicator_width1 2 #property indicator_minimum -3 #property indicator_maximum 3 #property indicator_label2 "vq zone" #property indicator_type2 DRAW_NONE #property indicator_color2 C'209,243,209',C'255,230,183' #property indicator_label3 "fast average" #property indicator_type3 DRAW_NONE #property indicator_color3 clrDarkGray #property indicator_style3 STYLE_DOT #property indicator_label4 "slow average" #property indicator_type4 DRAW_NONE #property indicator_color4 clrDarkGray #property indicator_style4 STYLE_DOT #property indicator_label5 "Volatility quality" #property indicator_type5 DRAW_NONE #property indicator_color5 clrLightGray #property indicator_width5 2 #include <MovingAverages.mqh> input int PriceSmoothing = 5; // Price smoothing period input ENUM_MA_METHOD PriceSmoothingMethod = MODE_LWMA; // Price smoothing method input int Ma1Period = 9; // Fast moving average input ENUM_MA_METHOD Ma1Method = MODE_SMA; // Fast moving average method input int Ma2Period = 200; // Slow moving average input ENUM_MA_METHOD Ma2Method = MODE_SMA; // Slow moving average method input double FilterInPips = 1.0; // Filter (in pips) double val[],valc[],fill1[],fill2[],avg1[],avg2[],trend[]; int trend_up_dw; //------------------------------------------------------------------ // //------------------------------------------------------------------ int hh,hl,ho,hc; double mh[],ml[],mo[],mc[]; int OnInit() { hh=iMA(Symbol(),Period(),PriceSmoothing,0,PriceSmoothingMethod,PRICE_HIGH); hl=iMA(Symbol(),Period(),PriceSmoothing,0,PriceSmoothingMethod,PRICE_LOW); ho=iMA(Symbol(),Period(),PriceSmoothing,0,PriceSmoothingMethod,PRICE_OPEN); hc=iMA(Symbol(),Period(),PriceSmoothing,0,PriceSmoothingMethod,PRICE_CLOSE); if(hh==INVALID_HANDLE || hl==INVALID_HANDLE || ho==INVALID_HANDLE || hc==INVALID_HANDLE){ Alert("Cant load ma"); return(INIT_FAILED); } SetIndexBuffer(0,trend ,INDICATOR_DATA); SetIndexBuffer(1,valc ,INDICATOR_COLOR_INDEX); SetIndexBuffer(2,fill1 ,INDICATOR_DATA); SetIndexBuffer(3,fill2 ,INDICATOR_DATA); SetIndexBuffer(4,avg1 ,INDICATOR_DATA); SetIndexBuffer(5,avg2 ,INDICATOR_DATA); SetIndexBuffer(6,val ,INDICATOR_DATA); //SetIndexBuffer(6,valc ,INDICATOR_COLOR_INDEX); SetIndexBuffer(7,mh,INDICATOR_CALCULATIONS); SetIndexBuffer(8,ml,INDICATOR_CALCULATIONS); SetIndexBuffer(9,mo,INDICATOR_CALCULATIONS); SetIndexBuffer(10,mc,INDICATOR_CALCULATIONS); PlotIndexSetInteger(1,PLOT_SHOW_DATA,false); IndicatorSetString(INDICATOR_SHORTNAME,"Volatility quality Stridsman ("+(string)PriceSmoothing+","+(string)Ma1Period+")"); return(0); } void OnDeinit(const int reason) { } 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[]){ if (Bars(_Symbol,_Period)<rates_total) return(-1); double pipMultiplier = MathPow(10,_Digits%2); int start; if(prev_calculated==0) { start=1; val[0]=0; } else { start=prev_calculated-1; } if(CopyBuffer(hh,0,0,rates_total-start,mh)==-1){ return(0); } if(CopyBuffer(ho,0,0,rates_total-start,mo)==-1){ return(0); } if(CopyBuffer(hl,0,0,rates_total-start,ml)==-1){ return(0); } if(CopyBuffer(hc,0,0,rates_total-start,mc)==-1){ return(0); } for(int i=start;i<rates_total;i++) { double cHigh =mh[i]; double cLow =ml[i]; double cOpen =mo[i]; double cClose =mc[i]; double pClose; if(i>0){ pClose = mc[i-1]; } else{ pClose = cClose; } if(i<PriceSmoothing){ cHigh =high[i]; cLow =low[i]; cOpen =open[i]; cClose =close[i]; pClose=close[i-1]; } double trueRange = MathMax(cHigh,pClose)-MathMin(cLow,pClose); double range = cHigh-cLow; double vqi=0; if(range!= 0 && trueRange!=0) { vqi=((cClose-pClose)/trueRange + (cClose-cOpen)/range)*0.5; } else if(i>0) { vqi=val[i-1]; } val[i]=0; if(i>0) { val[i]=val[i-1]+MathAbs(vqi)*(cClose-pClose+cClose-cOpen)*0.5; } if(FilterInPips > 0 && i>0) { if (MathAbs(val[i]-val[i-1]) < FilterInPips*pipMultiplier*_Point) { val[i] = val[i-1]; } } } SimpleMAOnBuffer(rates_total,prev_calculated,0,Ma1Period,val,avg1); SimpleMAOnBuffer(rates_total,prev_calculated,0,Ma2Period,val,avg2); for(int i=start;i<rates_total;i++) { // Color UP/DOWN //valc[i] = (i>0) ? (val[i]>val[i-1]) ? 1 : (val[i]<val[i-1]) ? 5 : valc[i-1] : 0; // trend_up_dw[i] = (i>0) ? (val[i]>val[i-1]) ? 1 : (val[i]<val[i-1]) ? -1 : trend_up_dw[i-1] : 0; //if (i>0) { if (val[i]>val[i-1]) trend_up_dw=1; else if (val[i]<val[i-1]) trend_up_dw=-1; } // Trend Buffer UP if (trend_up_dw==1) { if (val[i]>val[i-1]) { trend[i]=3; //STRONG UP TREND "1" valc[i]=3; } else if (val[i] == val[i-1] && (val[i]> avg1[i]+0.00001)) { trend[i] = 2; // STRONG UP PICK (fast retracement) valc[i]=2; } //else trend[i] = 3; else if (val[i] == val[i-1] && (val[i]<= (avg1[i]+ 0.000001))) { trend[i] = 1; // RANGE ZONE (FAST MA = VOLATILITY) valc[i]=1; } else// if (trend[i]=0) { trend[i] = trend[i-1]; valc[i]=valc[i-1]; } } else if (trend_up_dw==-1) { if (val[i]<val[i-1] ) { trend[i]= -3; valc[i]=6; } else if (val[i] == val[i-1] && val[i]< (avg1[i]-0.00001)) { trend[i] = -2; // STRONG UP PICK (fast retracement) valc[i]=5; } else if (val[i] == val[i-1] && (val[i]>= (avg1[i]- 0.00001))) { trend[i] = -1; // RANGE ZONE (FAST MA = VOLATILITY) valc[i]=4; } else //if (trend[i]=0) { trend[i] = trend[i-1]; valc[i]=valc[i-1]; } } } /**/ return(rates_total); }
Comments
Log in to add a comment.
No comments found.