iBearsBullsfuncs

Download script
Author: paladin80
iBearsBullsfuncs

This script is designed as a technical toolkit for MetaTrader users to measure market momentum by calculating the "power" or distance of price action relative to a moving average. It provides two specific calculation methods: one for identifying bearish (downward) pressure and one for bullish (upward) pressure.

Core Logic Overview

The script operates by comparing the current price extremes—specifically the highest and lowest points of a candle—against a smoothed average of the market's history. By subtracting the average from these extremes, the script produces a numerical value that represents how far the price has stretched beyond its "normal" trend.

Key Components

1. Bearish Power Calculation This function measures downward momentum. It looks at the lowest price reached during a specific time period and compares it to a Moving Average.

  • The Logic: It takes the lowest price point and subtracts the Moving Average value from it.
  • The Result: This provides a figure that illustrates how significantly the price is dropping below the expected average. A larger negative result indicates stronger downward pressure.

2. Bullish Power Calculation This function measures upward momentum using the opposite logic. It focuses on the highest price reached during a specific time period.

  • The Logic: It takes the highest price point and subtracts the Moving Average value from it.
  • The Result: This shows how far the price has surged above the expected average. A larger positive result indicates stronger upward momentum.

Customization Options

Both functions are highly flexible, allowing users to tailor the calculations based on their specific trading style through several variables:

  • Asset Selection: Users can choose to run the calculation on the current chart or any other financial symbol.
  • Timeframe: The logic can be applied to different intervals (e.g., 1-minute, hourly, or daily charts).
  • Period & Smoothing: Users can define how many previous bars are used to calculate the average and which specific smoothing method (the "mode") should be applied.
  • Price Point: It allows the user to decide which price type (such as open, close, high, or low) the moving average should be based on.
  • Historical Shift: The script can look at current live data or "look back" at previous candles to analyze historical power levels.
Price Data Components
Series array that contains the lowest prices of each barSeries array that contains the highest prices of each bar
Indicators Used
Moving average indicator
7 Views
0 Downloads
0 Favorites
iBearsBullsfuncs
//+------------------------------------------------------------------+
//|                                             iBearsBullsfuncs.mq4 |
//|                                         Author:  paladin80       |
//|                                         E-mail:  forevex@mail.ru |
//+------------------------------------------------------------------+
#property copyright "paladin80"
#property link      "forevex@mail.ru"
#property library
//--------------------------------------------- iBearsPowerfunc() - start ----------------------------------------------------------
//+----------------------------------------------------------------------------+
//| Input parameters:                                                          |
//|   Sy - Symbol.                                                             |
//|   Tf - Timeframe.                                                          |
//|   BearsPeriod - Period for calculation                                     |
//|   Applied_price - Applied price.                                           |
//|   Bears_MA_mode - Applied MA method.                                       |
//|   Shift - Index of the value taken from the indicator buffer.              |
//+----------------------------------------------------------------------------+
double iBearsPowerfunc(string Sy,int Tf,int BearsPeriod,int Applied_price,int Bears_MA_mode,int Shift)
{
   double Temp, Bears;
   if (Sy=="" || Sy=="0") Sy=Symbol();   
      Temp=iMA(Sy,Tf,BearsPeriod,0,Bears_MA_mode,Applied_price,Shift);
      Bears=iLow(Sy,Tf,Shift)-Temp;
   return(Bears);
}
//--------------------------------------------- iBearsPowerfunc() - end ------------------------------------------------------------

//--------------------------------------------- iBullsPowerfunc() - start ----------------------------------------------------------
//+----------------------------------------------------------------------------+
//| Input parameters:                                                          |
//|   Sy - Symbol.                                                             |
//|   Tf - Timeframe.                                                          |
//|   BullsPeriod - Period for calculation                                     |
//|   Applied_price - Applied price.                                           |
//|   Bulls_MA_mode - Applied MA method.                                       |
//|   Shift - Index of the value taken from the indicator buffer.              |
//+----------------------------------------------------------------------------+
double iBullsPowerfunc(string Sy,int Tf,int BullsPeriod,int Applied_price,int Bulls_MA_mode,int Shift)
{
   double Temp, Bulls;
   if (Sy=="" || Sy=="0") Sy=Symbol();   
      Temp=iMA(Sy,Tf,BullsPeriod,0,Bulls_MA_mode,Applied_price,Shift);
      Bulls=iHigh(Sy,Tf,Shift)-Temp;
   return(Bulls);
}
//--------------------------------------------- iBullsPowerfunc() - end ------------------------------------------------------------


















Comments