Candle_Direction
Download scriptThis tool is designed to provide traders with a real-time visual summary of market momentum across multiple timeframes simultaneously. Instead of requiring you to switch between different charts to see how the price is moving on various intervals, this script consolidates that information into a single, easy-to-read dashboard directly on your main trading screen.
How the Logic Works
The core functionality of the script revolves around analyzing the "direction" of the current price candle for nine specific timeframes: ranging from the 1-minute chart all the way up to the monthly chart (M1, M5, M15, M30, H1, H4, D1, W1, and MN).
For each of these timeframes, the script performs a simple but effective comparison:
- Price Movement: It looks at the current price at which a candle opened versus the price at which it is currently trading (the closing price).
- Trend Identification:
- If the current price is higher than the opening price, it identifies an Upward move.
- If the current price is lower than the opening price, it identifies a Downward move.
- If the price has not moved from the opening point, it remains Neutral.
Visual Presentation
To make this data useful for fast decision-making, the script translates these mathematical comparisons into a visual dashboard:
- Timeframe Labels: It creates a clean list of all the monitored timeframes on your screen so you know exactly what data you are viewing.
- Directional Indicators: Next to each timeframe label, the script places an arrow that changes color dynamically based on the market's behavior:
- Green Arrows: Indicate bullish momentum (price is currently higher than the open).
- Red Arrows: Indicate bearish momentum (price is currently lower than the open).
- White Arrows: Indicate a neutral state where the price is sitting at its opening mark.
Key Benefits for the User
By using this logic, you can instantly see the "big picture" of the market. It allows you to detect if multiple timeframes are aligning in the same direction—which often suggests a stronger, more reliable trend—or if there is a conflict between short-term and long-term movements. It effectively eliminates the need for manual chart hopping, providing a streamlined "pulse check" of the market at a single glance.
//+------------------------------------------------------------------+
//| Candle Direction.mq4 |
//| Copyright 2014, Luis Andrianto |
//| https://login.mql5.com/en/users/lou15 |
//+------------------------------------------------------------------+
#property copyright "Copyright 2014, Luis Andrianto"
#property link "https://login.mql5.com/en/users/lou15"
#property indicator_chart_window
#property indicator_buffers 1
extern color LabelColor=DodgerBlue;
extern int Corner=0;
extern color UpColor=LimeGreen;
extern color DownColor=Red;
extern color NetralColor=White;
int TF[]={1,5,15,30,60,240,1440,10080,43200};
string Label[]={"M1","M5","M15","M30","H1","H4","D1","W1","MN"};
double ExtBuff[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexBuffer(0,ExtBuff,INDICATOR_DATA);
for(int i=0;i<=8;i++)
{
ObjectCreate(Label[i],OBJ_LABEL,0,0,0);
ObjectCreate(Label[i]+" ARROW",OBJ_LABEL,0,0,0);
}
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
for(int i=0;i<=8;i++)
{
ObjectDelete(Label[i]);
ObjectDelete(Label[i]+" ARROW");
}
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
double OCandle(int tf){double OC=iOpen(Symbol(),tf,0);return(OC);}
double CCandle(int tf){double CC=iClose(Symbol(),tf,0);return(CC);}
void ObSetLabel(string name,string text,int x,int y)
{
ObjectSetText(name,text,10,"Impact",LabelColor);
ObjectSet(name,OBJPROP_CORNER,Corner);
ObjectSet(name,OBJPROP_XDISTANCE,x);
ObjectSet(name,OBJPROP_YDISTANCE,y);
ObjectSet(name,OBJPROP_BACK,0);
}
void ObSetArrow(string name,int code,int x,int y,color clr)
{
ObjectSetText(name,CharToStr(code),14,"Wingdings",clr);
ObjectSet(name,OBJPROP_CORNER,Corner);
ObjectSet(name,OBJPROP_XDISTANCE,x);
ObjectSet(name,OBJPROP_YDISTANCE,y);
ObjectSet(name,OBJPROP_BACK,0);
}
int start()
{
//----
int X_Start=0;
int Y_Start=20;
color clr;
for(int i=0;i<=8;i++)
{
X_Start=X_Start+30;
ObSetLabel(Label[i],Label[i],X_Start,Y_Start);
if(CCandle(TF[i])>OCandle(TF[i])){clr=UpColor;ExtBuff[i]=1;}
else if(CCandle(TF[i])<OCandle(TF[i])){clr=DownColor;ExtBuff[i]=2;}
else {clr=NetralColor;ExtBuff[i]=0;}
ObSetArrow(Label[i]+" ARROW",110,X_Start,Y_Start+20,clr);
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments