MTF_AMA_SLOPE

Download script
Author: Kalenzo
MTF_AMA_SLOPE

This technical tool is designed to help traders analyze market trends by visualizing a specific type of smoothed moving average across different timeframes simultaneously. Instead of just looking at the current price action, this script allows you to "peek" into higher time periods to identify the broader market direction.

Core Functionality

Multi-Timeframe Integration The primary purpose of this script is its ability to bridge different time horizons. It can pull data from a larger timeframe (such as Daily or Hourly charts) and project it onto your current smaller chart (such as 15-minute or 1-hour charts). This helps traders understand whether the "big picture" trend supports their immediate trading decisions.

Dynamic Smoothing Logic The script utilizes an advanced calculation method based on smoothed moving averages. Unlike standard moving averages that can be jittery or lag significantly, this logic uses a combination of "fast" and "slow" parameters to balance responsiveness with stability. It aims to filter out market "noise"—the minor, insignificant price fluctuations—to reveal the underlying momentum of the asset.

Visual Smoothing and Continuity Because shifting data from a high timeframe to a low timeframe can often result in "staircase" effects (where the line jumps suddenly), this script includes a specific logic to smooth out those transitions. It ensures that the visual line remains continuous and fluid, providing a more natural representation of price flow across the chart.

Key Components for the User

  • Timeframe Selection: You can choose which higher timeframe you want to monitor (e.g., watching a Weekly trend while trading on a 15-minute scale).
  • Sensitivity Controls: The script allows for adjustments regarding how quickly the indicator reacts to price changes (the "fast" and "slow" settings) and the overall period of the average.
  • Slope Visualization: By focusing on the "slope" or the path of the average, traders can identify whether the market is currently trending upward, downward, or moving sideways, making it easier to determine potential entry and exit points based on dominant momentum.
Miscellaneous
Implements a curve of type %1
14 Views
0 Downloads
0 Favorites
MTF_AMA_SLOPE
//+------------------------------------------------------------------+
//|                   MTF_AMA_SLOPE                    AMA SLOPE.mq4 |
//|                   2007   forexTSD.com             2006   Kalenzo |
//|                                     bartlomiej.gorski@gmail.com  |
//| I used the idea of P.Kauffman and code from KAMA             idk |
//| made by © 2004, by konKop,wellx                                  |
//+------------------------------------------------------------------+
#property copyright "Kalenzo"
#property link      "bartlomiej.gorski@gmail.com"

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Brown
#property indicator_width1 2

//---- input parameters
extern int TimeFrame = 0;
extern int       periodAMA=9;
extern int       nfast=2;
extern int       nslow=30;
extern double    G=2.0;

//---- buffers
//double kAMAbuffer[];
double ExtMapBuffer1[];
 
//+------------------------------------------------------------------+

//int    cbars=0, prevbars=0, prevtime=0;

//double slowSC,fastSC;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexLabel(0,"["+TimeFrame+"]("+periodAMA+")("+nfast+","+nslow+","+G+")");

   IndicatorDigits(4);
//   IndicatorShortName("MTF_AMA_Slope");
  // return(0);
 // }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
//int deinit()
 // {
 //  return(0);
 // }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
//---- 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("MTF_AMA_SLOPE["+TimeFrameStr+"]("+periodAMA+")("+nfast+","+nslow+","+G+")");   

//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//| Calculations                                    |
//+------------------------------------------------------------------+
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
    ExtMapBuffer1[i]=iCustom(NULL,TimeFrame,"AMA_SLOPE",periodAMA,nfast,nslow,G, 0,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];
 ********************************************************/  

   ExtMapBuffer1[i]=ExtMapBuffer1[0]; 
//----
   } } }
//+++++++++++++++++++++++++++++++++++++++++++++++   Raff

//-----

return(0);
  }
//+------------------------------------------------------------------+


Comments