4hVegasMetaTrader4hCTD_v1
Download scriptThis tool is designed to provide traders with a visual representation of the overall market sentiment or "direction" for specific trading sessions. Instead of focusing on momentary price fluctuations, it aims to identify whether the prevailing trend for a given week is moving upward or downward.
How the Logic Works
1. Trend Identification via External Data The script does not rely solely on immediate price action (like moving averages or RSI). Instead, it looks at "Global Variables"—which are essentially persistent data points stored by the trading platform. It specifically seeks out a value assigned to the current week for the specific currency pair you are viewing.
2. Determining Market Direction The logic follows a straightforward classification system based on these stored values:
- Bullish Sentiment (UP): If the stored value for the current week is greater than zero, the script recognizes this as an upward trend.
- Bearish Sentiment (DOWN): If the stored value for the current week is less than zero, the script recognizes this as a downward trend.
- Neutral/No Data: If no specific value is found or it doesn't meet the criteria above, the direction remains undefined.
3. Visual Representation on the Chart The script translates these "Up" and "Down" directions into a numerical format that appears in a separate window below your main chart:
- It marks the trend as 1 when the direction is UP.
- It marks the trend as -1 when the direction is DOWN.
Summary for the Trader
Essentially, this script acts as a "sentiment filter." Rather than telling you exactly when to enter a trade at a specific minute, it informs you of the broader context. It allows you to see at a glance whether the prevailing bias for the week (based on the Vegas Model logic) is positive or negative, helping you align your trades with the dominant market direction.
/*-----------------------------+
| |
| Shared by www.Aptrafx.com |
| |
+------------------------------*/
//+------------------------------------------------------------------+
//| 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