SlopeDirection_MTF

Download script
Author: Copyright � 2007, Asystem2000
SlopeDirection_MTF

This tool is designed to help traders visualize the prevailing direction of market momentum by analyzing price trends across different timeframes. Instead of simply showing a single data point, it identifies and plots directional trends, making it easier to see whether the market is currently leaning toward an upward or downward movement.

How It Works

The logic operates by pulling information from a secondary trend calculation and projecting it onto your current chart. Here is a breakdown of its core functions:

  • Multi-Timeframe Analysis: The primary strength of this script is its ability to look "higher up" at the market. You can choose to view trends from larger timeframes (like daily or hourly charts) while staying on a smaller, more active trading chart. This helps you ensure that your short-term trades align with the bigger picture.
  • Trend Detection: The script monitors specific price movements based on user-defined settings (such as how many previous candles to look at and which price type—like opening or closing prices—to follow). It looks for a "slope," determining if the trend is gaining strength in an upward direction or losing it in a downward direction.
  • Visual Representation: The script translates these complex calculations into two distinct visual lines:
    • One line represents the Upward Trend, typically highlighted in Lime Green.
    • The other line represents the Downward Trend, typically highlighted in Red.

Key Features for the User

  • Customizable Sensitivity: Users can adjust the "period" (how much historical data is considered) and the "method" to fine-tune how quickly or slowly the indicator reacts to new price changes.
  • Smart Synchronization: The script automatically calculates the correct time alignment between your current chart and the higher timeframe you have selected. This means it handles the heavy mathematical lifting of matching different time scales so you don't have to.
  • Validation Safety: To prevent errors, the script includes a built-in check. If you try to select an unsupported or incompatible timeframe, the tool will alert you rather than displaying incorrect data.

Summary

In short, this script acts as a "trend compass." By looking at the behavior of larger timeframes and plotting that information clearly on your current screen, it helps traders identify whether they should be looking for buying opportunities (green) or selling opportunities (red), providing a clearer sense of market flow.

Miscellaneous
It issuies visual alerts to the screenImplements a curve of type %1
16 Views
0 Downloads
0 Favorites
SlopeDirection_MTF
//+------------------------------------------------------------------+
//|                                           SlopeDirection_MTF.mq4 |
//|                      Copyright © 2007, ASystem 2000              |
//|                                        asystem2000@rambler.ru    |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, Asystem2000"
#property link      "asystem2000@rambler.ru"

#property indicator_chart_window 
#property indicator_buffers 2
#property indicator_color1 LimeGreen
#property indicator_color2 Red
//---- input parameters
extern int       TimeFrame=0;
extern int       period=80; 
extern int       method=3;                         // MODE_SMA 
extern int       price=0;                          // PRICE_CLOSE 
extern string    Note="You can adjust indicator name";
extern string    Indicator="Slope Direction Line";

//---- buffers
double B_Up[];
double B_Dn[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
  if (TimeFrame!=0)
  { 
  if (TimeFrame<Period())
     {
       Alert("Íàñòðàèâàåìûé òàéìôðåéì äîëæåí áûòü áîëüøå òåêóùåãî èëè ðàâåí 0");
       deinit();
       return(0);
     }
  }
  bool OK_Period=false;   
  switch (TimeFrame)
  {
    case 0:OK_Period=true;break;
    case 1:OK_Period=true;break;
    case 5:OK_Period=true;break;
    case 15:OK_Period=true;break;
    case 30:OK_Period=true;break;
    case 60:OK_Period=true;break;
    case 240:OK_Period=true;break;
    case 1440:OK_Period=true;break;
    case 10080:OK_Period=true;break;
    case 43200:OK_Period=true;break;
  }
  if (OK_Period==false)
     {
       Alert("Âû ââåëè íåêîððåêòíóþ öèôðó òàéìôðåéìà");
       deinit();
       return(0);
     }
  
//---- indicators
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2);
   SetIndexBuffer(0,B_Up);
   SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,2);
   SetIndexBuffer(1,B_Dn);
   
   IndicatorShortName("Slope Direction Line - MTF ("+period+")");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
   int limit;
   if (TimeFrame>0) limit=Bars-counted_bars+(3*TimeFrame/Period());
   else limit=Bars-counted_bars-1;
   if (limit>Bars) limit=Bars;
   int    C_time;
   int    Bar_Shift;
   if (limit==0) return(0);
//----
   int i=0;
   while(i<=limit)
   {
     C_time=Time[i];
     Bar_Shift=iBarShift(NULL,TimeFrame,C_time,false);
     B_Up[i]=iCustom(NULL,TimeFrame,Indicator,period,method,price,0,Bar_Shift);
     B_Dn[i]=iCustom(NULL,TimeFrame,Indicator,period,method,price,1,Bar_Shift); 
     i++;
   }
   
   
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments