Linear Regression Channel Indicator For MT5
Table Of Contents:
- Linear Regression Channel Indicator For MT5
- Linear Regression Channel Indicator For MT5インストール
- Linear Regression Channel Indicator For MT5パラメーター
- Linear Regression Channel Indicator For MT5
- コードの主要部分
Linear Regression Channel Indicator For MT5のLinear Regression Channel Indicator For MT5
Linear Regression Channel Indicator For MT5インストール
上記のフォームからインジケーターをダウンロードした後、zipファイルを解凍する必要があります。次に、ファイルlrchannel.mq5をMT5インストールのMQL5Indicatorsフォルダーにコピーする必要があります。その後、MT5を再起動してください。そうすると、インジケーターのリストにインジケーターが表示されます。
Linear Regression Channel Indicator For MT5パラメーター
Linear Regression Channel Indicator For MT5は、構成する1 パラメーターがあります。
input int InChPeriod = 150; //Channel Period
Linear Regression Channel Indicator For MT5
Linear Regression Channel Indicator For MT5は、 5 バッファーを提供します。
SetIndexBuffer(0,rlBuffer,INDICATOR_DATA); SetIndexBuffer(1,upBuffer,INDICATOR_DATA); SetIndexBuffer(2,downBuffer,INDICATOR_DATA); SetIndexBuffer(3,highBuffer,INDICATOR_DATA); SetIndexBuffer(4,lowBuffer,INDICATOR_DATA);
コードの主要部分
int OnCalculate(const int rates_total, const int prev_calculated, const int begin, const double &price[]) { double sumX,sumY,sumXY,sumX2,a,b,F,S; int X; //--- check for bars count if(rates_total lt ExChPeriod+1)return(0); //--- if new bar set, calculate if(rCount!=rates_total) { PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,rates_total-ExChPeriod-1); PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,rates_total-ExChPeriod-1); PlotIndexSetInteger(2,PLOT_DRAW_BEGIN,rates_total-ExChPeriod-1); PlotIndexSetInteger(3,PLOT_DRAW_BEGIN,rates_total-ExChPeriod-1); PlotIndexSetInteger(4,PLOT_DRAW_BEGIN,rates_total-ExChPeriod-1); //--- calculate coefficient a and b of equation linear regression F=0.0; S=0.0; sumX=0.0; sumY=0.0; sumXY=0.0; sumX2=0.0; X=0; for(int i=rates_total-1-ExChPeriod;i lt rates_total-1;i++) { sumX+=X; sumY+=price[i]; sumXY+=X*price[i]; sumX2+=MathPow(X,2); X++; } a=(sumX*sumY-ExChPeriod*sumXY)/(MathPow(sumX,2)-ExChPeriod*sumX2); b=(sumY-a*sumX)/ExChPeriod; //--- calculate values of main line and error F X=0; for(int i=rates_total-1-ExChPeriod;i lt rates_total;i++) { rlBuffer[i]=b+a*X; F+=MathPow(price[i]-rlBuffer[i],2); X++; } //--- calculate deviation S S=NormalizeDouble(MathSqrt(F/(ExChPeriod+1))/MathCos(MathArctan(a*M_PI/180)*M_PI/180),_Digits); //--- calculate values of last buffers for(int i=rates_total-1-ExChPeriod;i lt rates_total;i++) { upBuffer[i]=rlBuffer[i]+S; downBuffer[i]=rlBuffer[i]-S; highBuffer[i]=rlBuffer[i]+2*S; lowBuffer[i]=rlBuffer[i]-2*S; } rCount=rates_total; } return(rates_total); } //+------------------------------------------------------------------+