4hVegasMetaTrader4hCTD
Download scriptThis indicator is designed to provide a clear visual representation of the prevailing market direction based on a specific weekly trend. Instead of looking at complex, real-time price fluctuations, it focuses on identifying whether the current week's sentiment is bullish (moving upward) or bearish (moving downward).
How the Logic Works
The script operates by analyzing historical and current data to determine a "Direction" value for every day within the week. Here is the step-by-step breakdown of how it processes this information:
- Weekly Tracking: The tool looks at the specific date of each price bar to identify which week it belongs to. It uses a unique identifier for the current week to ensure that the data remains consistent across different days.
- External Trend Memory: Rather than calculating a new trend from scratch every second, the script references "Global Variables." These act as a persistent memory bank where the overall direction for the current week is stored.
- Direction Identification:
- If the memory bank indicates a positive value, the script identifies the market direction as "UP."
- If the memory bank indicates a negative value, it identifies the direction as "DOWN."
- If no specific value is stored, it remains neutral.
- Visual Output: The indicator translates these "UP" and "DOWN" directions into a numerical scale on your chart:
- An Upward trend is represented by the number 1.
- A Downward trend is represented by the number -1.
- No established trend results in a value of 0.
Summary for the User
In simple terms, this tool acts as a trend filter. By looking at the indicator window, you can instantly see whether the current market environment is categorized as positive or negative for the week. It removes the "noise" of small price movements and allows you to focus on the broader weekly direction.
//+------------------------------------------------------------------+
//| 4Hour Vegas Model - 4 Hour Chart Direction Indicator |
//| Spiggy |
//| |
//+------------------------------------------------------------------+
#property copyright "Spiggy"
#property link ""
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Blue
//---- input parameters
//---- buffers
double ExtMapBuffer1[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtMapBuffer1);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int limit;
int counted_bars=IndicatorCounted();
double SMA55;
double SMA8;
string ValueIndex;
string Direction;
limit=Bars;
//---- main loop
for(int i=0; i<limit; i++)
{
Direction = "----";
ValueIndex = TimeToStr(Time[i]-(TimeDayOfWeek(Time[i])*86400),TIME_DATE);
if ( GlobalVariableGet(Symbol() + "-ThisWeekDirection-" + ValueIndex) > 0.0 )
{
Direction = "UP";
}
if ( GlobalVariableGet(Symbol() + "-ThisWeekDirection-" + ValueIndex) < 0.0 )
{
Direction = "DOWN";
}
ExtMapBuffer1[i] = 0;
if ( Direction == "UP" )
{
ExtMapBuffer1[i] = 1;
}
if ( Direction == "DOWN" )
{
ExtMapBuffer1[i] = -1;
}
}
return(0);
}
//+------------------------------------------------------------------+
Comments