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);
   
   }
//+------------------------------------------------------------------+



Sample





Analysis



Market Information Used:

Series array that contains open time of each bar
Series array that contains tick volumes of each bar


Indicator Curves created:


Implements a curve of type DRAW_LINE

Indicators Used:

Moving average indicator


Custom Indicators Used:

Order Management characteristics:

Other Features:

It issuies visual alerts to the screen