MA_monika_SAR

Download script
Author: Copyright � 2010, basisforex@gmail.com
MA_monika_SAR

This indicator is designed to provide a comprehensive multi-timeframe analysis by layering different market perspectives directly onto your current chart. Instead of forcing you to constantly switch between different timeframes (like looking from a 1-minute chart to a daily chart), this tool calculates and displays critical trend data from multiple periods simultaneously.

Core Functionality

The script tracks two primary types of technical indicators—Moving Averages and Parabolic SAR—across four distinct layers of time. By calculating these automatically, it allows you to see how "big picture" trends are interacting with "short-term" price action in real-time.

How the Logic Works:

  • Multi-Timeframe Synchronization: The script identifies your current chart's timeframe and automatically selects three higher timeframes to monitor alongside it. For example, if you are viewing a lower timeframe, it will pull data from larger intervals (such as 5-minute, 1-hour, and Daily) to give you a sense of the overall market momentum.
  • Dual Indicator Tracking:
    • Moving Averages: It calculates four different Moving Averages. These are displayed as lines on your chart, representing the average price over specific periods. This helps in identifying the general direction of the trend.
    • Parabolic SAR: It also tracks four Parabolic Stop and Reverse (SAR) values. On the chart, these appear as distinct arrows or dots. These are primarily used to identify potential reversal points and set trailing stop-loss levels.
  • Visual Organization: To keep the data from becoming cluttered, the script uses a specific color-coding system:
    • Yellow: Represents the first higher timeframe.
    • Blue: Represents the second higher timeframe.
    • Black: Represents the third (highest) timeframe.
  • Dynamic Calculation: The logic is built to scale automatically. It performs complex math to ensure that the data from a Daily chart, for instance, aligns correctly with the price candles on a much smaller timeframe, providing a seamless "birds-eye view" of the market.

Summary for the User

In short, this tool removes the need to manually flip through various charts to see where the market is headed. It gathers "big picture" trend data from higher timeframes and overlays it onto your active screen, allowing you to make more informed decisions by seeing how current price movements fit into the broader market context.

Indicators Used
Moving average indicatorParabolic Stop and Reverse system
Miscellaneous
Implements a curve of type %1
10 Views
0 Downloads
0 Favorites
MA_monika_SAR
/*------------------------------------------------------------------+
 |                                            MA_monika_SAR.mq4.mq4 |
 |                                                 Copyright © 2010 |
 |                                             basisforex@gmail.com |
 +------------------------------------------------------------------*/
#property copyright "Copyright © 2010, basisforex@gmail.com"
#property link      "basisforex@gmail.com"
//-----
#property indicator_chart_window
#property indicator_buffers 8
#property indicator_color1 White
#property indicator_color2 Yellow
#property indicator_color3 Blue
#property indicator_color4 Black
#property indicator_color5 White
#property indicator_color6 Yellow
#property indicator_color7 Blue
#property indicator_color8 Black
//-----
extern int        n0Period    = 13;
extern int        n1Period    = 13;
extern int        n2Period    = 13;
extern int        n3Period    = 13;
//-----
extern int        MaShift     = 0;
extern int        MODE_Ma     = 3;
extern int        PRICE_Ma    = 6;
//-----
extern double     Step        = 0.02;
extern double     Maximum     = 0.2;
//-----
double M1ma[];
double M5ma[];
double H1ma[];
double D1ma[];
double M1sar[];
double M5sar[];
double H1sar[];
double D1sar[];
//+------------------------------------------------------------------+
int init()
 {
   SetIndexShift(0, MaShift);
   SetIndexShift(1, MaShift);
   SetIndexShift(2, MaShift);
   SetIndexShift(3, MaShift);
   SetIndexShift(4, MaShift);
   SetIndexShift(5, MaShift);
   SetIndexShift(6, MaShift);
   SetIndexShift(7, MaShift);
   //-----
   SetIndexBuffer(0, M1ma);
   SetIndexBuffer(1, M5ma);
   SetIndexBuffer(2, H1ma);
   SetIndexBuffer(3, D1ma);
   SetIndexBuffer(4, M1sar);
   SetIndexBuffer(5, M5sar);
   SetIndexBuffer(6, H1sar);
   SetIndexBuffer(7, D1sar);
   //-----
   SetIndexStyle(0, DRAW_LINE);
   SetIndexStyle(1, DRAW_LINE);
   SetIndexStyle(2, DRAW_LINE);
   SetIndexStyle(3, DRAW_LINE);
   SetIndexStyle(4, DRAW_ARROW);
   SetIndexArrow(4, 159);
   SetIndexStyle(5, DRAW_ARROW);
   SetIndexArrow(5, 159);
   SetIndexStyle(6, DRAW_ARROW);
   SetIndexArrow(6, 159);
   SetIndexStyle(7, DRAW_ARROW);
   SetIndexArrow(7, 159);
   //-----
   return(0);
 }
//+------------------------------------------------------------------+
string GetNextTF(int curTF)
 {
   switch(curTF)
    {
      case 1:
        return("5=15#30");
        break;
      case 5:
        return("15=30#60");
        break; 
      case 15:
        return("30=60#240");
        break;
      case 30:
        return("60=240#1440");
        break;
      case 60:
        return("240=1440#10080");
        break;
      case 240:
        return("1440=10080#43200");
        break;        
    }
 }
//+------------------------------------------------------------------+
int start()
 {
   int limit;
   int counted_bars = IndicatorCounted();
   if(counted_bars < 0) return(-1);
   if(counted_bars > 0) counted_bars--;
   limit = Bars - counted_bars;
   //-----
   string T = GetNextTF(Period());
   int tf1 = StrToDouble(StringSubstr(T, 0, StringFind(T, "=", 0)));
   int tf2 = StrToDouble(StringSubstr(T, StringFind(T, "=", 0) + 1, StringFind(T, "#", 0)));
   int tf3 = StrToDouble(StringSubstr(T, StringFind(T, "#", 0) + 1, StringLen(T)));
   Comment(tf1, " Yellow  ", "\n", tf2, " Blue ", "\n", tf3, " Black");
   //-----
   for(int i = 0; i < limit; i++)
    {
      M1ma[i]   = iMA(NULL, Period(), n0Period, 0, MODE_Ma, PRICE_Ma, i);
      M5ma[i]   = iMA(NULL, tf1, n1Period, 0, MODE_Ma, PRICE_Ma, i / (tf1 / Period()));
      H1ma[i]   = iMA(NULL, tf2, n2Period, 0, MODE_Ma, PRICE_Ma, i / (tf2 / Period()));
      D1ma[i]   = iMA(NULL, tf3, n3Period, 0, MODE_Ma, PRICE_Ma, i / (tf3 / Period()));
      //-----
      M1sar[i]  = iSAR(NULL, Period(), Step, Maximum, i);
      M5sar[i]  = iSAR(NULL, tf1, Step, Maximum, i / (tf1 / Period()));
      H1sar[i]  = iSAR(NULL, tf2, Step, Maximum, i / (tf2 / Period()));
      D1sar[i]  = iSAR(NULL, tf3, Step, Maximum, i / (tf3 / Period()));
    }  
   //-----
   return(0);
 }
//+------------------------------------------------------------------+

Comments