# iBearsPower

Do you want to know about the MQL5.community development? Have a look at the Wall!
147
2015.12.09 03:55

Does anyone know what is the code to calculate the median number between the highest value and lowest value of iBearsPower ?

For example:

iBearsPower highest value is: 50

iBearsPower lowest value is: 10

Median value is: (50+10) / 2 = 30

I want to know what the mql4 code for that.

46469
2015.12.09 06:32
mql4student:

Does anyone know what is the code to calculate the median number between the highest value and lowest value of iBearsPower ?

For example:

iBearsPower highest value is: 50

iBearsPower lowest value is: 10

Median value is: (50+10) / 2 = 30

I want to know what the mql4 code for that.

```//+------------------------------------------------------------------+
//|                                               HiLoBearsPower.mq4 |
//|                        Copyright 2015, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "https://www.mql5.com/en/users/3rjfx ~ By 3rjfx ~ Created: 2015/12/09"
#property version   "1.00"
#property strict
//---
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
{
//---
//---
double LastHiBears=0.0;
double LastLoBears=0.0;
//--
for(int i=99; i>=0; i--)
{
if(iCustom(_Symbol,0,"Bears.ex4",0,i)>LastHiBears)
{LastHiBears=NormalizeDouble(iCustom(_Symbol,0,"Bears.ex4",0,i),_Digits);}
if(iCustom(_Symbol,0,"Bears.ex4",0,i)<LastLoBears)
{LastLoBears=NormalizeDouble(iCustom(_Symbol,0,"Bears.ex4",0,i),_Digits);}
}
//--
double Median=NormalizeDouble((LastHiBears+LastLoBears)/2,_Digits);
Print("----- BearsPower Highest value in Last 100 Bars Symbol",_Symbol,": ",LastHiBears);
Print("----- BearsPower Lowest value in Last 100 Bars Symbol ",_Symbol,": ",LastLoBears);
Print("----- BearsPower Median value in Last 100 Bars Symbol ",_Symbol,": ",Median);
//---
}
//+------------------------------------------------------------------+

//-- Copy and paste this scripts into the MT4 folder Scripts
//-- double-click the file name these scripts "HiLoBearsPower"
//-- You can see the results on the Experts tab

```