MTF_SnakeForce(2)

Download script
Author:
MTF_SnakeForce(2)

This indicator is designed to provide traders with a visual representation of market momentum and structural boundaries by analyzing data across different timeframes. It essentially "translates" high-level market trends into a format that can be viewed on smaller, more immediate charts.

Multi-Timeframe Analysis Logic

The core functionality of this script relies on its ability to look at a larger timeframe than the one currently displayed on your screen. By pulling data from a higher period (for example, looking at Daily trends while viewing a 15-minute chart), it helps the trader identify the broader "big picture" without having to constantly switch windows.

The script uses four distinct data layers to categorize market behavior:

  • Force Up / Force Down: These represent the active momentum of the market. They visualize the strength with which price is moving in a specific direction, helping to distinguish between a weak trend and a powerful, sustained move.
  • Resistance Up / Resistance Down: These identify structural boundaries or "walls" where the price may encounter difficulty continuing its current path.

Visual Representation and Smoothing

To make this data easy for a human to interpret, the script employs several processing techniques:

  1. Dynamic Mapping: The tool automatically synchronizes the timing between the higher timeframe and your current chart. It ensures that the data points align correctly with the candles you are currently watching.
  2. Buffer Refreshing: When looking at high timeframes on a low timeframe, there is often a "gap" in data where the higher timeframe hasn't finished its cycle yet. The script includes a smoothing logic that carries over the most recent available value to the current bars. This ensures that the visual indicators remain continuous and fluid rather than appearing as broken lines or empty gaps.
  3. Automatic Labeling: The tool is designed to be user-friendly by automatically generating a descriptive label in the corner of your chart. It calculates the specific time duration being analyzed (e.g., Minutes, Hours, or Days) and updates the title so you always know exactly which timeframe's data you are observing.

Summary for the Trader

In practical terms, this script acts as a "Force and Resistance" map. It tells you how hard the market is pushing in a certain direction (Force) and where it might be hitting a ceiling or floor (Resistance), all while allowing you to stay focused on your immediate trading execution timeframe.

Miscellaneous
Implements a curve of type %1
13 Views
1 Downloads
0 Favorites
MTF_SnakeForce(2)
//+------------------------------------------------------------------+
//|MTF_SnakeForce                                 SnakeInBorders.mq4 |
//|                                      "ÈÍÄÈÊÀÒÎÐÛ ÄËß ÑÀÌÎÎÁÌÀÍÀ" |
//|(MTF - ForexTSD.com 2007)  Bookkeeper, 2006, yuzefovich@gmail.com |
//+------------------------------------------------------------------+
#property copyright ""
#property link      ""
//+------------------------------------------------------------------+
#property  indicator_separate_window
#property indicator_buffers 4
#property indicator_color1  Lime
#property indicator_color2  Red
#property indicator_color3  Lime
#property indicator_color4  Red
//----
extern int TimeFrame = 0;
extern int  cPeriod=24; 
//----
double    ForceUp[];
double    ForceDown[];
double    ResistanceUp[];
double    ResistanceDown[];
//----
int init()
{
int    draw_begin;
double indperiod,val1,val2;
string CommentStr;
   draw_begin=3*cPeriod;
   IndicatorBuffers(5);
   SetIndexBuffer(0,ForceUp);
   SetIndexBuffer(1,ForceDown);
   SetIndexBuffer(2,ResistanceUp);
   SetIndexBuffer(3,ResistanceDown);
   SetIndexStyle(0,DRAW_HISTOGRAM,EMPTY,2);
   SetIndexStyle(1,DRAW_HISTOGRAM,EMPTY,2);
   SetIndexStyle(2,DRAW_HISTOGRAM);
   SetIndexStyle(3,DRAW_HISTOGRAM);
   SetIndexLabel(2,NULL);
   SetIndexLabel(3,NULL);
   SetIndexDrawBegin(0,draw_begin);
   SetIndexDrawBegin(1,draw_begin);
   SetIndexDrawBegin(2,draw_begin);
   SetIndexDrawBegin(3,draw_begin);
   indperiod=1.0*cPeriod*Period();
   if(indperiod<60)
   {
      CommentStr=DoubleToStr(indperiod,0);
      CommentStr=" M"+CommentStr+", FORCE UP -DOWN ";
   }
   else
   {
      indperiod=indperiod/60;
      if(indperiod>=24)
      {
         val1=MathAbs(MathRound(indperiod/24)-indperiod/24);
         if(val1<0.01)
         {
            CommentStr=DoubleToStr(indperiod/24,0);
            CommentStr=" D"+CommentStr+", FORCE UP -DOWN ";
         }
          else
         {
            CommentStr=DoubleToStr(indperiod/24,1);
            CommentStr=" D"+CommentStr+", FORCE UP -DOWN ";
         }
      }
      else
      {
         val1=MathAbs(MathRound(indperiod)-indperiod);
         if(val1<0.01)
         {
            CommentStr=DoubleToStr(indperiod,0);
            CommentStr=" H"+CommentStr+", FORCE UP -DOWN ";
         }
          else
         {
            CommentStr=DoubleToStr(indperiod,1);
            CommentStr=" H"+CommentStr+", FORCE UP -DOWN ";
         }
      }
   }
   
   //---- name for DataWindow and indicator subwindow label
   switch(TimeFrame)
   {
      case 1 : string TimeFrameStr="Period_M1"; break;
      case 5 : TimeFrameStr="Period_M5"; break;
      case 15 : TimeFrameStr="Period_M15"; break;
      case 30 : TimeFrameStr="Period_M30"; break;
      case 60 : TimeFrameStr="Period_H1"; break;
      case 240 : TimeFrameStr="Period_H4"; break;
      case 1440 : TimeFrameStr="Period_D1"; break;
      case 10080 : TimeFrameStr="Period_W1"; break;
      case 43200 : TimeFrameStr="Period_MN1"; break;
      default : TimeFrameStr="Current Timeframe";
   } 
   
    
   IndicatorShortName("SnakeForce["+TimeFrame+"]("+cPeriod+")"+CommentStr);
    return(0);
}
//----
//+------------------------------------------------------------------+
int start()
  {
   datetime TimeArray[];
   int    i,shift,limit,y=0,counted_bars=IndicatorCounted();
    
// Plot defined timeframe on to current timeframe   
   ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),TimeFrame); 
   
   limit=Bars-counted_bars+TimeFrame/Period();
   for(i=0,y=0;i<limit;i++)
   {
   if (Time[i]<TimeArray[y]) y++;  
//---- main loop
    ForceUp[i]=iCustom(NULL,TimeFrame,"SnakeForce",cPeriod,0,y);
    ForceDown[i]=iCustom(NULL,TimeFrame,"SnakeForce",cPeriod,1,y);
    ResistanceUp[i]=iCustom(NULL,TimeFrame,"SnakeForce",cPeriod,2,y);
    ResistanceDown[i]=iCustom(NULL,TimeFrame,"SnakeForce",cPeriod,3,y);

}

  // Refresh buffers
//++++++++++++++++++++++++++++++++++++++   upgrade by Raff 
   if (TimeFrame>Period()) {
     int PerINT=TimeFrame/Period()+1;
     datetime TimeArr[]; ArrayResize(TimeArr,PerINT);
     ArrayCopySeries(TimeArr,MODE_TIME,Symbol(),Period()); 
     for(i=0;i<PerINT+1;i++) {if (TimeArr[i]>=TimeArray[0]) {
//----
 /******************************************************** 
    Refresh buffers:         buffer[i] = buffer[0];
 ********************************************************/  
    ForceUp[i]=ForceUp[0];
    ForceDown[i]=ForceDown[0];
    ResistanceUp[i]= ResistanceUp[0];
    ResistanceDown[i]=ResistanceDown[0];

//----
   } } }
//+++++++++++++++++++++++++++++++++++++++++++++++   Raff

//-----

return(0);
  }



Comments