Indicator doesn't plot - TickVolume/Abs(High-Low)

 

Hi,

tried this today, it compiles without problems but it doesn't show any graph... I just took the Volumes indicator from Examples and chaged the calculation method and the names of the functions and variables that I saw fit. Properties are still the same except colors, I figured it would work the same and look similar to the original Volumes with the colored bars. Or maybe I am missing something? I have no clue why it doesn't work.

It is to show a ratio of the tick volume per wick length (volue per movement)

//Looking at a chart one notices the difference in height of the candle bars in times of high vs. low volatility.
//What we can't see is what happens below the surface: How much volume is contained in a movement. Often times it shows that
//the Volumes of Buyers and Sellers eliminate each other at least partially. Perhaps this value shows something about the
//market's activity and the decisiveness of the participants. It is similar to the inversion of the AMA's efficiency ratio
//where the noise is corrected by subtraction of the error.
//But in this case the noise might be a value that gives us information about the heat of the market.

//---INDICATOR TickPerWick (Heat)


//--- indicator settings
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_plots   1
#property indicator_type1   DRAW_COLOR_HISTOGRAM
#property indicator_color1  clrGold,clrRoyalBlue
#property indicator_style1  0
#property indicator_width1  1
#property indicator_minimum 0.0
//--- input data
input ENUM_APPLIED_VOLUME InpVolumeType=VOLUME_TICK;    
//--- indicator buffers
double ExtHeatBuffer[];
double ExtColorsBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
void OnInit()
  {
//--- buffers
   SetIndexBuffer(0,ExtHeatBuffer,INDICATOR_DATA);
   SetIndexBuffer(1,ExtColorsBuffer,INDICATOR_COLOR_INDEX);
//--- name for DataWindow and indicator subwindow label
   IndicatorSetString(INDICATOR_SHORTNAME,"TickPerWick");
//--- indicator digits
   IndicatorSetInteger(INDICATOR_DIGITS,0);
  }
//+------------------------------------------------------------------+
//|  Heat                                                         |
//+------------------------------------------------------------------+
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(rates_total<2)
      return(0);
//--- starting work
   int pos=prev_calculated-1;
//--- correct position
   if(pos<1)
     {
      ExtHeatBuffer[0]=0;
      pos=1;
     }
//--- main cycle
   if(InpVolumeType==VOLUME_TICK)
      CalculateHeat(pos,rates_total,tick_volume,high,low);
   else
      CalculateHeat(pos,rates_total,volume,high,low);
//--- OnCalculate done. Return new prev_calculated.
   return(rates_total);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void CalculateHeat(const int pos,const int rates_total,const long& volume[], const double& high[], const double& low[])
  {
   ExtHeatBuffer[0]=(double)volume[0]/MathAbs((double) high[0]-(double) low[0]);
   ExtColorsBuffer[0]=0.0;
//---
   for(int i=pos; i<rates_total && !IsStopped(); i++)
     {
      double curr_heat=(double)volume[i]/MathAbs((double) high[i]-(double) low[i]);
      double prev_heat=((double)volume[i-1]/MathAbs((double) high[i-1]-(double) low[i-1]));
      //--- calculate indicator
      ExtHeatBuffer[i]=curr_heat;

      if(curr_heat>prev_heat)
         ExtColorsBuffer[i]=0.0;
      else
         ExtColorsBuffer[i]=1.0;
     }
//---
  }
//+------------------------------------------------------------------

Here is the Result:

Not available

Volumes - Volume Indicators - MetaTrader 5 Help
Volumes - Volume Indicators - MetaTrader 5 Help
  • www.metatrader5.com
For the Forex market, Volumes is the indicator of the number of price changes within each period of a selected timeframe. For stock symbols this is...
 
pennyhunter:

Hi,

tried this today, it compiles without problems but it doesn't show any graph... I just took the Volumes indicator from Examples and chaged the calculation method and the names of the functions and variables that I saw fit. Properties are still the same except colors, I figured it would work the same and look similar to the original Volumes with the colored bars. Or maybe I am missing something? I have no clue why it doesn't work.

It is to show a ratio of the tick volume per wick length (volue per movement)

Here is the Result:


Look at the log. What will happen if the high equals the low for a candle ?
 
pennyhunter:

Hi,

It is to show a ratio of the tick volume per wick length (volue per movement)

Here is the Result:

Here you have a division by zero error.

double curr_heat=(double)volume[i]/MathAbs((double) high[i]-(double) low[i]);
double prev_heat=((double)volume[i-1]/MathAbs((double) high[i-1]-(double) low[i-1]));
 
Alain Verleyen:
Look at the log. What will happen if the high equals the low for a candle ?
Nagisa Unada:

Here you have a division by zero error.

Oh okay thanks.

You might have noticed that I don't come from programming.

Will this article help me with the production of said indicator as much as I think it will: https://www.mql5.com/en/articles/10

MQL5: Create Your Own Indicator
MQL5: Create Your Own Indicator
  • www.mql5.com
What is an indicator? It is a set of calculated values that we want to be displayed on the screen in a convenient way. Sets of values are represented in programs as arrays. Thus, creation of an indicator means writing an algorithm that handles some arrays (price arrays) and records results of handling to other arrays (indicator values). By describing creation of True Strength Index, the author shows how to write indicators in MQL5.
Reason: