Force Index_v1M2LA_mtf

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

The Force Index is a technical analysis tool designed to help traders visualize the underlying strength behind a price movement. Rather than just looking at whether a price is going up or down, this script measures the momentum of that move by combining price trends with trading volume (or "tick" activity).

Here is a professional breakdown of how the logic functions:

Core Calculation Logic

The script calculates two distinct versions of the Force Index simultaneously, allowing you to see both short-term and long-term momentum at a glance. It works by identifying the change in a Moving Average over a specific period and multiplying that change by the current volume.

  • Fast Momentum: One line tracks shorter, quicker price changes. This is highly sensitive and helps identify immediate shifts in market energy.
  • Slow Momentum: The second line tracks longer, broader price trends. This provides a "smoothed" view of the market, helping to filter out minor noise and reveal the primary trend.

Multi-Timeframe Functionality

A unique feature of this specific script is its ability to operate across different timeframes. You can set the indicator to analyze data from higher timeframes (such as Hourly or Daily charts) while you are currently looking at a smaller timeframe (like a 1-minute or 5-minute chart). This allows for "top-down" analysis, where you can see if the larger market trend supports your current trade setup.

Alert System and Thresholds

The script includes a built-in notification system designed to alert you when market momentum reaches specific intensities:

  • Trigger Levels: You can define specific numerical boundaries (thresholds). When the Force Index line crosses above or below these levels, it indicates that momentum is accelerating significantly.
  • Smart Notifications: To prevent your screen from being flooded with constant alerts, the script includes a "cooldown" logic. It will only notify you once when a level is crossed and won't alert you again until the price moves back into a neutral zone, ensuring you only receive meaningful information.

Summary for the User

Essentially, this tool acts as a "momentum gauge." By watching how these lines behave relative to each other and your set threshold levels, you can determine if a trend is gaining strength, losing steam, or if a significant breakout is occurring based on the actual volume of activity in the market.

Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1It issuies visual alerts to the screen
6 Views
1 Downloads
0 Favorites
Force Index_v1M2LA_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,ExtForcePeriod2);
   SetIndexDrawBegin(1,ExtForcePeriod2);
   SetIndexDrawBegin(2,ExtForcePeriod2);
 
  
   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 = "CurrTF(0)";
   }
//---- name for DataWindow and indicator subwindow label

   sShortName="Force ("+ExtForcePeriod+","+ExtForcePeriod2+") |"+TimeFrameStr;
   IndicatorShortName(sShortName);

   SetIndexLabel(0,""+ExtForcePeriod+"");
   SetIndexLabel(1,""+ExtForcePeriod2+"");
   SetIndexLabel(2,NULL);
   
//  SetIndexLabel(0,sShortName); 
//        if (TimeFrame < Period()) TimeFrame = Period(); // in kerris f-la



   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... (TF",TimeFrame," on Cart M",GetCurrentTF(Period())," ",Symbol(),")"); // alert by omelette //mod.4mtf 
           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