FXGaugeMAs_lite

Download script
Author: Copyright � 2007, Doji Starr
FXGaugeMAs_lite

The FXGaugeMAs_lite tool is a visual analysis indicator designed to help traders identify and interpret market trends by smoothing out price action. Rather than looking at the erratic "noise" of individual price movements, this script calculates and displays seven different Moving Averages simultaneously on your chart.

How it Works

The core logic of this tool relies on identifying trends across various time horizons. It does this by calculating a Simple Moving Average (SMA) for each of the following periods: 21, 34, 55, 75, 100, 144, and 233.

By using these specific numerical periods, the indicator provides a comprehensive "gauge" of market momentum:

  • Short-term trends: Represented by the smaller periods (e.g., 21 and 34), these lines react more quickly to recent price changes.
  • Medium-term trends: Represented by the middle periods (e.g., 55, 75, and 100), these help identify the prevailing direction of the current market cycle.
  • Long-term trends: Represented by the largest periods (e.g., 144 and 233), these act as the "anchor" for the price, showing the overall macro-trend over an extended duration.

Visual Representation

The script renders seven distinct lines on your chart window. Because each line uses a different period, they will cluster and spread out depending on the strength of the market. When the lines are aligned and moving in the same direction, it typically signifies a strong, established trend. Conversely, when the lines begin to flatten or cross one another, it can signal a potential change in momentum or a transition into a sideways market.

Key Features for the User

  • Customizable Visibility: You can define how many historical bars the indicator should calculate (up to 1,000 by default), allowing you to balance visual clarity with historical data.
  • Automatic Scaling: The tool automatically adjusts to the amount of data available on your chart to ensure that the calculations remain accurate without crashing the platform.
  • Safety Check: The script includes a built-in safety feature that alerts you if the "ShowBars" setting is too low to properly display the longest moving average, ensuring you always have enough data to make informed visual decisions.

In summary, this indicator serves as a multi-layered roadmap. By looking at all seven lines at once, you can see not just where the price is now, but how it relates to the recent past, the current trend, and the long-term market structure.

Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1It issuies visual alerts to the screen
13 Views
0 Downloads
0 Favorites
FXGaugeMAs_lite
//+------------------------------------------------------------------+
//|                                           _i_FXGaugeMAs_lite.mq4 |
//|                                     Copyright © 2007, Doji Starr |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, Doji Starr"

#property indicator_chart_window
#property indicator_buffers 7
#property indicator_color1 Lime
#property indicator_color2 Brown
#property indicator_color3 Magenta
#property indicator_color4 DarkSlateGray
#property indicator_color5 Yellow
#property indicator_color6 LightSlateGray
#property indicator_color7 White



// input params
extern int MA_Period1 = 21;
extern int MA_Period2 = 34;
extern int MA_Period3 = 55;
extern int MA_Period4 = 75;
extern int MA_Period5 = 100;
extern int MA_Period6 = 144;
extern int MA_Period7 = 233;
extern int ShowBars   = 1000;
extern int LineWidth  = 1;

// vars
int counted_bars, startBar, bar, i, goober;

// buffers
double buf_1[], buf_2[], buf_3[], buf_4[], buf_5[], buf_6[], buf_7[];



//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
    
    IndicatorBuffers(7);
    
    SetIndexBuffer(0, buf_1);
    SetIndexEmptyValue(0,EMPTY_VALUE);
    SetIndexDrawBegin(0,MA_Period7);
    SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, LineWidth);
    SetIndexLabel(0, " MA 1 ( "+MA_Period1+" )");
    
    SetIndexBuffer(1, buf_2);
    SetIndexEmptyValue(1,EMPTY_VALUE);
    SetIndexDrawBegin(1,MA_Period7);
    SetIndexStyle(1, DRAW_LINE, STYLE_SOLID, LineWidth);
    SetIndexLabel(1, " MA 2 ( "+MA_Period2+" )");
    
    SetIndexBuffer(2, buf_3);
    SetIndexEmptyValue(2,EMPTY_VALUE);
    SetIndexDrawBegin(2,MA_Period7);
    SetIndexStyle(2, DRAW_LINE, STYLE_SOLID, LineWidth);
    SetIndexLabel(2, " MA 3 ( "+MA_Period3+" )");
    
    SetIndexBuffer(3, buf_4);
    SetIndexEmptyValue(3,EMPTY_VALUE);
    SetIndexDrawBegin(3,MA_Period7);
    SetIndexStyle(3, DRAW_LINE, STYLE_SOLID, LineWidth);
    SetIndexLabel(3, " MA 4 ( "+MA_Period4+" )");
    
    SetIndexBuffer(4, buf_5);
    SetIndexEmptyValue(4,EMPTY_VALUE);
    SetIndexDrawBegin(4,MA_Period7);
    SetIndexStyle(4, DRAW_LINE, STYLE_SOLID, LineWidth);
    SetIndexLabel(4, " MA 5 ( "+MA_Period5+" )");
    
    SetIndexBuffer(5, buf_6);
    SetIndexEmptyValue(5,EMPTY_VALUE);
    SetIndexDrawBegin(5,MA_Period7);
    SetIndexStyle(5, DRAW_LINE, STYLE_SOLID, LineWidth);
    SetIndexLabel(5, " MA 6 ( "+MA_Period6+" )");
    
    SetIndexBuffer(6, buf_7);
    SetIndexEmptyValue(6,EMPTY_VALUE);
    SetIndexDrawBegin(6,MA_Period7);
    SetIndexStyle(6, DRAW_LINE, STYLE_SOLID, LineWidth);
    SetIndexLabel(6, " MA 7 ( "+MA_Period7+" )");
    
    return(0);
}

//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
{
    return(0);
}

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{
    
    startBar = ShowBars;
    
    if (startBar > Bars) { startBar = Bars-1; }
    
    if (startBar < MA_Period7*2 && goober < Time[0]) { Alert(" Increase ShowBars To At Least "+(MA_Period7*2+1)+" "); goober = Time[0]; }
    
    for (bar=0; bar<startBar; bar++)
    {
        buf_1[bar] = iMA(NULL, 0, MA_Period1, 0, MODE_SMA, PRICE_CLOSE, bar);
        buf_2[bar] = iMA(NULL, 0, MA_Period2, 0, MODE_SMA, PRICE_CLOSE, bar);
        buf_3[bar] = iMA(NULL, 0, MA_Period3, 0, MODE_SMA, PRICE_CLOSE, bar);
        buf_4[bar] = iMA(NULL, 0, MA_Period4, 0, MODE_SMA, PRICE_CLOSE, bar);
        buf_5[bar] = iMA(NULL, 0, MA_Period5, 0, MODE_SMA, PRICE_CLOSE, bar);
        buf_6[bar] = iMA(NULL, 0, MA_Period6, 0, MODE_SMA, PRICE_CLOSE, bar);
        buf_7[bar] = iMA(NULL, 0, MA_Period7, 0, MODE_SMA, PRICE_CLOSE, bar);
    }
    
    return(0);
}

Comments