4hVegasMetaTraderWeeklyIndicator-V11_v2

Download script
Author: Spiggy
4hVegasMetaTraderWeeklyIndicator-V11_v2

This script serves as a technical analysis tool designed to identify and visualize the weekly market direction based on the "Vegas Model." Instead of looking at short-term price fluctuations, it focuses on high-level trends to help traders understand whether the current momentum is heading upwards or downwards.

Core Logic and Methodology

The tool functions by analyzing two different types of Moving Averages (MAs) specifically on a weekly timeframe. By focusing on weekly data, the script filters out "market noise"—the small, erratic price movements that happen in minutes or hours—to reveal the broader path the market is taking.

  1. The Calculation Engines: The script tracks two specific averages:

    • A 5-period Simple Moving Average (SMA): This reacts more quickly to recent price changes.
    • A 21-period Exponential Moving Average (EMA): This is a smoother average that gives more importance to recent data but remains more stable over time.
  2. Determining the Trend: The script doesn't just look at where these averages are; it looks at how the gap between them is changing from one week to the next.

    • Upward Momentum: If the distance between the fast average (SMA5) and the slow average (EMA21) is widening in a positive direction compared to the previous week, the script identifies this as an "UP" trend.
    • Downward Momentum: If that distance is shrinking or moving negatively compared to the previous week, it identifies a "DOWN" trend.

Visual and Data Output

The tool provides three distinct ways to view this information:

  • Visual Indicators: It plots the results in a separate window on your chart using lines and histograms. This allows you to see the strength of the movement visually. Green elements typically represent upward pressure, while Red represents downward pressure.
  • On-Screen Commentary: The script automatically generates a text comment on your chart. This comment clearly states the current direction (UP or DOWN), shows the specific numerical value of the trend's strength, and identifies the specific week it is referencing.
  • Global Data Storage: For advanced users, the script saves this weekly direction data into "Global Variables." This means the information can be accessed by other programs or tools on your trading platform simultaneously.

Summary for the Trader

Essentially, this tool acts as a compass. It looks at the heavy machinery of the market (the weekly trends) and tells you whether the tide is coming in or going out. By comparing the "speed" of the price (SMA5) against the "weight" of the price (EMA21), it helps you stay aligned with the dominant weekly direction.

Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
5 Views
0 Downloads
0 Favorites
4hVegasMetaTraderWeeklyIndicator-V11_v2
//+--------------------------------------------------------------------+
//| 4Hour Vegas Model - Weekly Chart Direction Calculator              |
//|                                                           Spiggy   |
//|                                                                    |
//|Mod by F DCG (20050924):                                            |
//|  - Added PERIOD_W1 to the calc of the MA to get to the proper      |
//|    week figures instead of using the 4h avg.                       |
//|  - Changed some of the variables names to more incurr more meaning |
//+--------------------------------------------------------------------+
#property copyright "Spiggy"
#property link      ""
//----
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Blue
#property indicator_color2 Green
#property indicator_color3 Red
//---- input parameters
//---- buffers
double _maDiff[];
double _upTrend[];
double _downTrend[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,_maDiff);
   SetIndexStyle(1,DRAW_HISTOGRAM);
   SetIndexBuffer(1,_upTrend);
   SetIndexStyle(2,DRAW_HISTOGRAM);
   SetIndexBuffer(2,_downTrend);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{
  int    limit, weekIndex;
  double EMA21;
  double SMA5;
  double EMA21Prev;
  double SMA5Prev;
  string ValueIndex;
  string Direction;  
  // Always prepare all of the information for the other indicators
  limit=Bars;
  //---- main loop
  for(int i=limit; i>=0; i--) 
  {
  	weekIndex=i/30;	
    //---- Calculate the current weekly trend
    EMA21=iMA(Symbol(), PERIOD_W1, 21, 0, MODE_EMA, PRICE_MEDIAN, weekIndex);
    SMA5 =iMA(Symbol(), PERIOD_W1, 5, 0, MODE_SMA, PRICE_MEDIAN, weekIndex);
    //---- Calculate the previous weekly trend
    EMA21Prev=iMA(Symbol(), PERIOD_W1, 21, 0, MODE_EMA, PRICE_MEDIAN, weekIndex+1);
    SMA5Prev =iMA(Symbol(), PERIOD_W1, 5, 0, MODE_SMA, PRICE_MEDIAN, weekIndex+1);
    // Calculate the difference of the MAs
    _maDiff[i] = SMA5-EMA21;
    // Calculate the difference of the MAs
    if (((SMA5-EMA21) - (SMA5Prev-EMA21Prev)) > 0.0 ) 
    {
      _upTrend[i] = (SMA5-EMA21)- (SMA5Prev-EMA21Prev);
      _downTrend[i] = 0.0;
      Direction = "UP";
     }
      else if (((SMA5-EMA21) - (SMA5Prev-EMA21Prev)) < 0.0 ) 
     {
      _upTrend[i] = 0.0;
      _downTrend[i] = (SMA5-EMA21) - (SMA5Prev-EMA21Prev);
      Direction = "DOWN";
    }
    // Calculate the start of the week and publish the value in a global variable
    // Publish this with the previous Sunday as the index
    ValueIndex = TimeToStr(Time[i]-TimeDayOfWeek(Time[i]),TIME_DATE);
    Comment(Symbol() + "-ThisWeekDirection-" + ValueIndex + "\n" + Direction + ":(" + ((SMA5-EMA21) - (SMA5Prev-EMA21Prev)) + ")");
    GlobalVariableSet(Symbol() + "-ThisWeekDirection-" + ValueIndex, ((SMA5-EMA21) - (SMA5Prev-EMA21Prev)));
  }      
   return(0);
  }
//+------------------------------------------------------------------+

Comments