Force Index_v1M2L_mtf

Download script
Author: Copyright � 2005, MetaQuotes Software Corp.
Force Index_v1M2L_mtf

This script is a sophisticated technical analysis tool designed to measure market momentum and volatility by calculating the "Force" behind price movements. Unlike standard indicators that only look at price, this tool incorporates trading volume to provide a more comprehensive view of market activity.

Core Functionality

The logic operates by identifying the speed and strength of price changes over two different time horizons simultaneously. It calculates a momentum value based on the difference between current moving averages and their previous values, then multiplies that result by the trading volume.

By using two different periods (configurable by the user), the tool allows you to visualize:

  • Short-term momentum: Rapid changes in price driven by immediate volume.
  • Long-term momentum: Broader trends and sustained buying or selling pressure.

Multi-Timeframe Analysis

One of the primary features of this script is its "Multi-Timeframe" (MTF) capability. It can fetch data from different time periods (such as 1-minute, hourly, daily, or weekly charts) and project that information onto your current screen. This allows you to stay aware of what is happening on a larger scale without having to switch back and forth between different windows.

Automated Alerts and Thresholds

To help traders react quickly to market shifts, the script includes an integrated alert system. You can set specific "Trigger Levels"—numerical boundaries that represent significant momentum thresholds.

The logic follows these rules for notifications:

  • Threshold Monitoring: The script constantly checks if the calculated Force exceeds your predefined limits.
  • Smart Filtering: To prevent constant, repetitive notifications, the tool is programmed with a "one-time" alert logic. It will notify you when a threshold is breached but will remain silent until the momentum settles back below that level and then breaks out again.
  • End of Bar Timing: The system can be configured to only check for these conditions at the completion of a candle, ensuring that alerts are based on confirmed data rather than "ghost" movements during a live price flicker.

Summary for the User

Essentially, this tool acts as a momentum speedometer. It tells you not just which way the market is moving, but how much "power" is behind that move. By combining volume, dual-period trends, and multi-timeframe data into a single view with smart alerts, it helps identify high-activity zones where significant price action is likely to occur.

Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1It issuies visual alerts to the screen
5 Views
0 Downloads
0 Favorites
Force Index_v1M2L_mtf
//+------------------------------------------------------------------+
//| Force Index_v1m2L_mtf                            Force Index.mq4 |
//|                      Copyright © 2005, MetaQuotes Software Corp. |
//| MTF www.forex-tsd.com keris  ki        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 DodgerBlue
#property indicator_color2 DarkSlateBlue
#property indicator_color3 Purple
#property indicator_style3 2


#property indicator_level1 0.03
#property indicator_level2 -0.03
#property indicator_level3 0.05
#property indicator_level4 -0.05
//#property indicator_level5 0.00
#property indicator_levelcolor DarkSlateGray
//---- input parameters

extern int ExtForcePeriod=13;
extern int ExtForcePeriod2=24;
extern int ExtForceMAMethod=0;
extern int ExtForceAppliedPrice=0;
extern int TimeFrame = 0;

extern bool Alerts_On = false;
extern bool Alerts_EOB = true; // End of bar alerts
extern double Alert_Trigger_Level_1 = 0.03;
extern double Alert_Trigger_Level_2 = 0.05;
extern int    MaxBarsToCount  =1500;
extern string  TimeFrames = "M1;5,15,30,60H1;240H4;1440D1;10080W1;43200MN|0-CurrentTF";

//---- buffers
double ExtForceBuffer[],ExtForceBuffer2[],ATL[3], ExtBuffer0[];
bool EntryAllowed[3];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   string sShortName;
   SetIndexBuffer(0,ExtForceBuffer);
//---- indicator line
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(1,ExtForceBuffer2);
//---- indicator line
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(2,ExtBuffer0);
//---- indicator line
   SetIndexStyle(2,DRAW_LINE);

//---- first values aren't drawn
   SetIndexDrawBegin(0,ExtForcePeriod);
   SetIndexDrawBegin(1,ExtForcePeriod);
   SetIndexDrawBegin(2,ExtForcePeriod);
  
   ATL[1] = Alert_Trigger_Level_1;
   ATL[2] = Alert_Trigger_Level_2;
  
//----
   switch(TimeFrame)
   {
      case 1 :   string  TimeFrameStr = "M1";  break;
      case 5 :           TimeFrameStr = "M5";  break;
      case 15 :          TimeFrameStr = "M15"; break;
      case 30 :          TimeFrameStr = "M30"; break;
      case 60 :          TimeFrameStr = "H1";  break;
      case 240 :         TimeFrameStr = "H4";  break;
      case 1440 :        TimeFrameStr = "D1";  break;
      case 10080 :       TimeFrameStr = "W1";  break;
      case 43200 :       TimeFrameStr = "MN1"; break;
      default :          TimeFrameStr = "CurrentTF(0)";
   }
//---- name for DataWindow and indicator subwindow label
   sShortName="Force ("+ExtForcePeriod+","+ExtForcePeriod2+") |"+TimeFrameStr;
   IndicatorShortName(sShortName);
   SetIndexLabel(0,sShortName);


   return(0);
  }
//+------------------------------------------------------------------+
//| Force Index indicator                                            |
//+------------------------------------------------------------------+
int start()
  {
   int limit;
   datetime TimeArray[];

   int i,y=0, counted_bars=IndicatorCounted();
//---- insufficient data
     ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),TimeFrame); 

   if(Bars<=ExtForcePeriod) return(0);
   else counted_bars++;
   
   limit=Bars-counted_bars;
   limit=MathMax(limit,TimeFrame/Period());
   limit=MathMin(limit,MaxBarsToCount);  
//---- Force Index counted
   for(i=0,y=0;i<limit;i++)
   {
   if (TimeFrame<Period()) TimeFrame=Period();
   if (Time[i]<TimeArray[y]) y++;

   
    ExtForceBuffer[i]=Volume[y]*(iMA(NULL,TimeFrame,ExtForcePeriod,0,ExtForceMAMethod,ExtForceAppliedPrice,y)
                               -iMA(NULL,TimeFrame,ExtForcePeriod,0,ExtForceMAMethod,ExtForceAppliedPrice,y+1));
    ExtForceBuffer2[i]=Volume[y]*(iMA(NULL,TimeFrame,ExtForcePeriod2,0,ExtForceMAMethod,ExtForceAppliedPrice,y)
                               -iMA(NULL,TimeFrame,ExtForcePeriod2,0,ExtForceMAMethod,ExtForceAppliedPrice,y+1));
    ExtBuffer0[i]=0;
   
    if (Alerts_On && i == Alerts_EOB) {
     for (int f=1; f<3; f++) {
      double TriggerLevel = ATL[f];
     if (MathAbs(ExtForceBuffer[i]) > TriggerLevel) {
      if (EntryAllowed[f]) {
       Alert("ForceIndex threshold ",f," exceeded... (",GetCurrentTF(Period())," ",Symbol(),")"); // alert by omelette
       EntryAllowed[f] = false; } }
     else EntryAllowed[f] = true; } }
   }
//---- done
   return(0);
  }
  
  string GetCurrentTF(int Prd)
  {
   string temp;
   
   switch(Prd) {
    case 1: temp = "M1"; break;
    case 5: temp = "M5"; break;
    case 15: temp = "M15"; break;
    case 30: temp = "M30"; break;
    case 60: temp = "H1"; break;
    case 240: temp = "H4"; break;
    case 1440: temp = "D1"; break;
    case 10080: temp = "W1"; break;
    case 43200: temp = "M1"; break; }
    
   return(temp);
   
   }
//+------------------------------------------------------------------+

Comments