Support-Resistance Indicator For MT5
Table Of Contents:
- Support-Resistance Indicator For MT5
- Installing the Support-Resistance Indicator For MT5
- Parameters of the Support-Resistance Indicator For MT5
- Buffers of the Support-Resistance Indicator For MT5
- Main Parts Of The Code
The Support-Resistance Indicator For MT5 draws dynamic support and resistance lines on the chart. The indicator use the Gaussian Transform algorithm to calculate the lines. You can define the distance of the support and resistance line by changing the parameter WindowSize.
Installing the Support-Resistance Indicator For MT5
After you downloaded the indicator via the form above you need to unzip the zip-file. Then you need to copy the file support-resistanceindicator.mq5 into the folder MQL5\Indicators of your MT5 installation. After that please restart MT5 and then you will be able to see the indicator in the list of indicators.
Parameters of the Support-Resistance Indicator For MT5
The Support-Resistance Indicator For MT5 has 2 parameters to configure.
input uint WindowSize=20; //window width input int Shift=0; // horizontal shift of the indicator in bars
Buffers of the Support-Resistance Indicator For MT5
The Support-Resistance Indicator For MT5 provides 3 buffers.
SetIndexBuffer(0,ExtLineBuffer0,INDICATOR_DATA); SetIndexBuffer(1,ExtLineBuffer1,INDICATOR_DATA); SetIndexBuffer(2,ExtLineBuffer2,INDICATOR_DATA);
Main Parts Of The Code
int OnCalculate( const int rates_total, // amount of history in bars at the current tick const int prev_calculated,// amount of history in bars at the previous tick 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[] ) { //---- Checking if the number of bars is sufficient for the calculation if(rates_total lt min_rates_total) return(0); //---- declaration of local variables int limit,bar; double Max,Min,slow,shigh; //--- calculations of the necessary amount of data to be copied and //the limit starting index for loop of bars recalculation if(prev_calculated gt rates_total || prev_calculated lt =0)// checking for the first start of the indicator calculation { limit=rates_total-min_rates_total-1; // starting index for calculation of all bars } else limit=rates_total-prev_calculated; // starting index for calculation of new bars //---- indexing elements in arrays as time series ArraySetAsSeries(high,true); ArraySetAsSeries(low,true); ArraySetAsSeries(open,true); ArraySetAsSeries(close,true); //---- main loop of the indicator calculation for(bar=limit; bar gt =0 && !IsStopped(); bar--) { Max=0; Min=999999999; for(int kkk=bar; kkk lt int(bar+WindowSize); kkk++) { slow=Smooth_5(rates_total,PRICE_LOW,kkk,open,low,high,close); if(slow lt Min) Min=slow; shigh=Smooth_5(rates_total,PRICE_HIGH,kkk,open,low,high,close); if(shigh gt Max) Max=shigh; } ExtLineBuffer1[bar]=Max; ExtLineBuffer0[bar]=(Max+Min)/2; ExtLineBuffer2[bar]=Min; } //---- return(rates_total); } //+------------------------------------------------------------------+