Price Heatmap Indicator For MT5
Table Of Contents:
- Price Heatmap Indicator For MT5
- Installing the Price Heatmap Indicator For MT5
- Parameters of the Price Heatmap Indicator For MT5
- Buffers of the Price Heatmap Indicator For MT5
- Main Parts Of The Code
The Price Heatmap Indicator For MT5 is a technically sound indicator which provides an interesting and insightful perspective into price action as it trades about the markets - the heat map uses a great colorization visual which maps the price action volatility, and buying and selling pressure - this indicator works very well in sideways channels where the oversold and overbought regions become easily noticeable in the end of their respective down and up cycles. Traders will notice that there is a purple dotted line or group of lines going horizontally across the screen - well these lines are peak lines which may be treated as support and resistance levels of which trades may use as suitable guidelines for setting take profit targets. As for the heat-map itself, well the colors are simple to understand - the heat-map varies from one extreme color to another extreme color depending on the price action - the one extreme is colored in a strong red color and the other extreme color is green. The red color marks the contentious parts of the market where the buying pressure overcomes selling pressure or vice versa - it is a zone of high volatility - when price comes into this red zone traders should be on the lookout for sudden price movements.
Installing the Price Heatmap 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 peak_lines.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 Price Heatmap Indicator For MT5
The Price Heatmap Indicator For MT5 has 4 parameters to configure.
input int InpCalcTime=4; // Calculation Time(hour) input int InpDailyPeriod=60; // DailyPeriod(hour) input int InpFastPeriod=180; // FastPeriod(hour) input int InpSlowPeriod=30; // SlowPeriod(day)
Buffers of the Price Heatmap Indicator For MT5
The Price Heatmap Indicator For MT5 provides 40 buffers.
SetIndexBuffer(0,P1Buffer,INDICATOR_DATA); SetIndexBuffer(1,P2Buffer,INDICATOR_DATA); SetIndexBuffer(2,P3Buffer,INDICATOR_DATA); SetIndexBuffer(3,P4Buffer,INDICATOR_DATA); SetIndexBuffer(4,P5Buffer,INDICATOR_DATA); SetIndexBuffer(5,P6Buffer,INDICATOR_DATA); SetIndexBuffer(6,P7Buffer,INDICATOR_DATA); SetIndexBuffer(7,P8Buffer,INDICATOR_DATA); SetIndexBuffer(8,P9Buffer,INDICATOR_DATA); SetIndexBuffer(9,P10Buffer,INDICATOR_DATA); SetIndexBuffer(10,D1Buffer,INDICATOR_CALCULATIONS); SetIndexBuffer(11,D2Buffer,INDICATOR_CALCULATIONS); SetIndexBuffer(12,D3Buffer,INDICATOR_CALCULATIONS); SetIndexBuffer(13,D4Buffer,INDICATOR_CALCULATIONS); SetIndexBuffer(14,D5Buffer,INDICATOR_CALCULATIONS); SetIndexBuffer(15,D6Buffer,INDICATOR_CALCULATIONS); SetIndexBuffer(16,D7Buffer,INDICATOR_CALCULATIONS); SetIndexBuffer(17,D8Buffer,INDICATOR_CALCULATIONS); SetIndexBuffer(18,D9Buffer,INDICATOR_CALCULATIONS); SetIndexBuffer(19,D10Buffer,INDICATOR_CALCULATIONS); SetIndexBuffer(20,F1Buffer,INDICATOR_CALCULATIONS); SetIndexBuffer(21,F2Buffer,INDICATOR_CALCULATIONS); SetIndexBuffer(22,F3Buffer,INDICATOR_CALCULATIONS); SetIndexBuffer(23,F4Buffer,INDICATOR_CALCULATIONS); SetIndexBuffer(24,F5Buffer,INDICATOR_CALCULATIONS); SetIndexBuffer(25,F6Buffer,INDICATOR_CALCULATIONS); SetIndexBuffer(26,F7Buffer,INDICATOR_CALCULATIONS); SetIndexBuffer(27,F8Buffer,INDICATOR_CALCULATIONS); SetIndexBuffer(28,F9Buffer,INDICATOR_CALCULATIONS); SetIndexBuffer(29,F10Buffer,INDICATOR_CALCULATIONS); SetIndexBuffer(30,S1Buffer,INDICATOR_CALCULATIONS); SetIndexBuffer(31,S2Buffer,INDICATOR_CALCULATIONS); SetIndexBuffer(32,S3Buffer,INDICATOR_CALCULATIONS); SetIndexBuffer(33,S4Buffer,INDICATOR_CALCULATIONS); SetIndexBuffer(34,S5Buffer,INDICATOR_CALCULATIONS); SetIndexBuffer(35,S6Buffer,INDICATOR_CALCULATIONS); SetIndexBuffer(36,S7Buffer,INDICATOR_CALCULATIONS); SetIndexBuffer(37,S8Buffer,INDICATOR_CALCULATIONS); SetIndexBuffer(38,S9Buffer,INDICATOR_CALCULATIONS); SetIndexBuffer(39,S10Buffer,INDICATOR_CALCULATIONS);
Main Parts Of The Code
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 i,first; //--- check for bars count if(rates_total lt =min_rates_total) return(0); //--- first=1000; if(first+1 lt prev_calculated) first=prev_calculated-2; //--- for(i=first; i lt rates_total && !IsStopped(); i++) { bool is_update=false; MqlDateTime tm0,tm1; TimeToStruct(time[i],tm0); TimeToStruct(time[i-1],tm1); if(tm1.hour!=tm0.hour && tm0.hour==InpCalcTime) { is_update=true; calc_peaks(1,PERIOD_M5,D1BinRange,DailyPeriod,i,time[i],1); calc_peaks(2,PERIOD_M30,BinRange,FastPeriod,i,time[i],2); calc_peaks(3,PERIOD_M30,BinRange,SlowPeriod,i,time[i],2); } if(!is_update) { D1Buffer[i] = D1Buffer[i-1]; D2Buffer[i] = D2Buffer[i-1]; D3Buffer[i] = D3Buffer[i-1]; D4Buffer[i] = D4Buffer[i-1]; D5Buffer[i] = D5Buffer[i-1]; D6Buffer[i] = D6Buffer[i-1]; D7Buffer[i] = D7Buffer[i-1]; D8Buffer[i] = D8Buffer[i-1]; D9Buffer[i] = D9Buffer[i-1]; D10Buffer[i]= D10Buffer[i-1]; //--- F1Buffer[i] = F1Buffer[i-1]; F2Buffer[i] = F2Buffer[i-1]; F3Buffer[i] = F3Buffer[i-1]; F4Buffer[i] = F4Buffer[i-1]; F5Buffer[i] = F5Buffer[i-1]; F6Buffer[i] = F6Buffer[i-1]; F7Buffer[i] = F7Buffer[i-1]; F8Buffer[i] = F8Buffer[i-1]; F9Buffer[i] = F9Buffer[i-1]; F10Buffer[i]= F10Buffer[i-1]; //--- S1Buffer[i] = S1Buffer[i-1]; S2Buffer[i] = S2Buffer[i-1]; S3Buffer[i] = S3Buffer[i-1]; S4Buffer[i] = S4Buffer[i-1]; S5Buffer[i] = S5Buffer[i-1]; S6Buffer[i] = S6Buffer[i-1]; S7Buffer[i] = S7Buffer[i-1]; S8Buffer[i] = S8Buffer[i-1]; S9Buffer[i] = S9Buffer[i-1]; S10Buffer[i]= S10Buffer[i-1]; } double ma=(high[i]+low[i]+close[i])/3; //--- double res=getPeaks(ma,BinRange*2,i); if(res gt 0.0) { append_peaks(i,res,0); } else { P1Buffer[i] = P1Buffer[i-1]; P2Buffer[i] = P2Buffer[i-1]; P3Buffer[i] = P3Buffer[i-1]; P4Buffer[i] = P4Buffer[i-1]; P5Buffer[i] = P5Buffer[i-1]; P6Buffer[i] = P6Buffer[i-1]; P7Buffer[i] = P7Buffer[i-1]; P8Buffer[i] = P8Buffer[i-1]; P9Buffer[i] = P9Buffer[i-1]; P10Buffer[i]= P10Buffer[i-1]; } } //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ double getPeaks(double v,int binRange,int i) { double min=v-binRange*PIP*1.5; double max=v+binRange*PIP*1.5; //--- if(min lt = P1Buffer[i-1] && P1Buffer[i-1] lt = max) return 0.0; if(min lt = P2Buffer[i-1] && P2Buffer[i-1] lt = max) return 0.0; if(min lt = P3Buffer[i-1] && P3Buffer[i-1] lt = max) return 0.0; if(min lt = P4Buffer[i-1] && P4Buffer[i-1] lt = max) return 0.0; if(min lt = P5Buffer[i-1] && P5Buffer[i-1] lt = max) return 0.0; if(min lt = P6Buffer[i-1] && P6Buffer[i-1] lt = max) return 0.0; if(min lt = P7Buffer[i-1] && P7Buffer[i-1] lt = max) return 0.0; if(min lt = P8Buffer[i-1] && P8Buffer[i-1] lt = max) return 0.0; if(min lt = P9Buffer[i-1] && P9Buffer[i-1] lt = max) return 0.0; if(min lt = P10Buffer[i-1] && P10Buffer[i-1] lt = max) return 0.0; //--- min=v-binRange*PIP; max=v+binRange*PIP; //--- if(min lt = D1Buffer[i] && D1Buffer[i] lt = max) return D1Buffer[i]; if(min lt = D2Buffer[i] && D2Buffer[i] lt = max) return D2Buffer[i]; if(min lt = D3Buffer[i] && D3Buffer[i] lt = max) return D3Buffer[i]; if(min lt = D4Buffer[i] && D4Buffer[i] lt = max) return D4Buffer[i]; if(min lt = D5Buffer[i] && D5Buffer[i] lt = max) return D5Buffer[i]; if(min lt = D6Buffer[i] && D6Buffer[i] lt = max) return D6Buffer[i]; if(min lt = D7Buffer[i] && D7Buffer[i] lt = max) return D7Buffer[i]; if(min lt = D8Buffer[i] && D8Buffer[i] lt = max) return D8Buffer[i]; if(min lt = D9Buffer[i] && D9Buffer[i] lt = max) return D9Buffer[i]; if(min lt = D10Buffer[i] && D10Buffer[i] lt = max) return D10Buffer[i]; //--- if(min lt = S1Buffer[i] && S1Buffer[i] lt = max) return S1Buffer[i]; if(min lt = S2Buffer[i] && S2Buffer[i] lt = max) return S2Buffer[i]; if(min lt = S3Buffer[i] && S3Buffer[i] lt = max) return S3Buffer[i]; if(min lt = S4Buffer[i] && S4Buffer[i] lt = max) return S4Buffer[i]; if(min lt = S5Buffer[i] && S5Buffer[i] lt = max) return S5Buffer[i]; if(min lt = S6Buffer[i] && S6Buffer[i] lt = max) return S6Buffer[i]; if(min lt = S7Buffer[i] && S7Buffer[i] lt = max) return S7Buffer[i]; if(min lt = S8Buffer[i] && S8Buffer[i] lt = max) return S8Buffer[i]; if(min lt = S9Buffer[i] && S9Buffer[i] lt = max) return S9Buffer[i]; if(min lt = S10Buffer[i] && S10Buffer[i] lt = max) return S10Buffer[i]; //--- if(min lt = F1Buffer[i] && F1Buffer[i] lt = max) return F1Buffer[i]; if(min lt = F2Buffer[i] && F2Buffer[i] lt = max) return F2Buffer[i]; if(min lt = F3Buffer[i] && F3Buffer[i] lt = max) return F3Buffer[i]; if(min lt = F4Buffer[i] && F4Buffer[i] lt = max) return F4Buffer[i]; if(min lt = F5Buffer[i] && F5Buffer[i] lt = max) return F5Buffer[i]; if(min lt = F6Buffer[i] && F6Buffer[i] lt = max) return F6Buffer[i]; if(min lt = F7Buffer[i] && F7Buffer[i] lt = max) return F7Buffer[i]; if(min lt = F8Buffer[i] && F8Buffer[i] lt = max) return F8Buffer[i]; if(min lt = F9Buffer[i] && F9Buffer[i] lt = max) return F9Buffer[i]; if(min lt = F10Buffer[i] && F10Buffer[i] lt = max) return F10Buffer[i]; //--- return 0.0; } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void calc_peaks(int opt,ENUM_TIMEFRAMES tf,int binRange,int period,int i,datetime t,int limit) { int peaks[]; int hist[]; int offset; if(generate_histgram(offset,peaks,hist,t,tf,binRange,period)) { int peak_cnt=ArraySize(peaks); if(peak_cnt gt 0) { int line_cnt=0; for(int j=0;j lt MathMin(limit,peak_cnt);j++) { double peak=(offset+peaks[j]*binRange+binRange/2) *PIP; append_peaks(i,peak,opt); } } } } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ bool generate_histgram(int &offset, int &tf_peaks[], int &tf_hist[], datetime t, ENUM_TIMEFRAMES tf, int binRange, int histPeriod) { double tf_high[]; double tf_low[]; long tf_vol[]; ArraySetAsSeries(tf_high,true); ArraySetAsSeries(tf_low,true); ArraySetAsSeries(tf_vol,true); int tf_len1=CopyTickVolume(Symbol(),tf,t,histPeriod,tf_vol); int tf_len2=CopyHigh(Symbol(),tf,t,histPeriod,tf_high); int tf_len3=CopyLow (Symbol(),tf,t,histPeriod,tf_low); //--- check copy count bool tf_ok=(histPeriod==tf_len1 && tf_len1==tf_len2 && tf_len2==tf_len3); if(!tf_ok)return (false); //--- offset=(int)MathRound(tf_low[ArrayMinimum(tf_low)]/PIP); int limit=(int)MathRound(tf_high[ArrayMaximum(tf_high)]/PIP); //--- calc_histgram(tf_peaks,tf_hist,tf_high,tf_low,tf_vol,offset,limit,binRange,histPeriod); //--- return (true); } //+------------------------------------------------------------------+ //| calc histgram | //+------------------------------------------------------------------+ bool calc_histgram(int &peaks[], int &hist[], const double &hi[], const double &lo[], const long &vol[], int offset, int limit, double binRange, int histPeriod) { //--- int j,k; //--- histgram bin steps int steps=(int)MathRound((limit-offset)/binRange)+1; //--- init ArrayResize(hist,steps); ArrayInitialize(hist,0); //--- histgram loop for(j=histPeriod-1;j gt =0;j--) { int l =(int)MathRound(lo[j]/PIP); int h =(int)MathRound(hi[j]/PIP); int v=(int)MathRound(MathSqrt(MathMin(vol[j],1))); int min = (int)MathRound((l-offset)/binRange); int max = (int)MathRound((h-offset)/binRange); //--- for normal for(k=min;k lt =max;k++)hist[k]+=v; } //--- find peaks int work[][2]; //--- find peaks int peak_count=find_peaks(work,hist,steps,binRange); ArrayResize(peaks,0,peak_count); int top=0; int cnt=0; for(j=peak_count-1;j gt =0;j--) { if(j==(peak_count-1))top=work[j][0]; if(work[j][0] gt top*0.1) { cnt++; ArrayResize(peaks,cnt,peak_count); peaks[cnt-1]=work[j][1]; } } return (true); } //+------------------------------------------------------------------+ //| Find peaks | //+------------------------------------------------------------------+ int find_peaks(int &peaks[][2],const int &hist[],int steps,double binrange) { if(steps lt =10) { ArrayResize(peaks,1); peaks[0][1] = ArrayMaximum(hist); peaks[0][0] =hist[peaks[0][1]]; return 1; } int count=0; for(int i=2;i lt steps-2;i++) { int max=MathMax(MathMax(MathMax(MathMax( hist[i-2],hist[i-1]),hist[i]),hist[i+1]),hist[i+2]); if(hist[i]==max) { count++; ArrayResize(peaks,count); int total=hist[i-2]+hist[i-1]+hist[i]+hist[i+1]+hist[i+2]; peaks[count-1][0] = total; peaks[count-1][1] = i; } } if(count gt 1) { ArraySort(peaks); } //--- return(count); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void append_peaks(int i,double v,int opt) { if(opt==0) { P1Buffer[i]=v; P2Buffer[i]=P1Buffer[i-1]; P3Buffer[i]=P2Buffer[i-1]; P4Buffer[i]=P3Buffer[i-1]; P5Buffer[i]=P4Buffer[i-1]; P6Buffer[i]=P5Buffer[i-1]; P7Buffer[i]=P6Buffer[i-1]; P8Buffer[i]=P7Buffer[i-1]; P9Buffer[i]=P8Buffer[i-1];