Trend_all_period_en

Download script
Author: Copyright � 2009, Vladimir Hlystov
Trend_all_period_en

This script is designed to provide a comprehensive multi-timeframe overview of market trends, allowing traders to see the "big picture" at a single glance. Instead of requiring you to switch between different charts manually, it aggregates and displays trend data from nine different timeframes (ranging from 1-minute intervals to monthly views) directly onto your current screen.

Core Functionality

The logic is built around four distinct analytical methods used to determine market direction. The script calculates the trend for each timeframe based on these specific models:

  • Offset Method: Uses a specific external calculation (labeled "offset") to identify momentum.
  • Offset 2 Method: A modified version of the offset logic that combines multiple data points from the same source for a potentially more nuanced trend reading.
  • Moving Average (MA) Alignment: This monitors three specific Moving Averages (5, 13, and 34). It identifies an "UP" trend if the fastest average is above both slower averages, and a "DN" trend if it falls below them.
  • MACD Momentum: This analyzes the MACD (Moving Average Convergence Divergence) indicator. It compares the current momentum value against the previous one to determine if the price is currently moving higher or lower.

How the Information is Displayed

The script organizes this data into a clean, professional dashboard on your chart:

  1. Timeframe Breakdown: The dashboard lists nine rows, each corresponding to a specific timeframe (M1, M5, M15, M30, H1, H4, D1, W1, and MN1).
  2. Multi-Method Comparison: For every single timeframe, the script displays the results for all four analytical methods simultaneously. This allows you to see if different indicators agree with one another (e.g., if the MACD and the Moving Averages are both showing an upward trend).
  3. Visual Coding:
    • UP: Shown in OrangeRed, indicating bullish momentum.
    • DN: Shown in MediumBlue, indicating bearish momentum.
    • Neutral: Displayed in DimGray if the data is inconclusive or flat.
  4. The "All Period" Summary: At the bottom of the dashboard, the script provides a global conclusion. It aggregates all the data points across every timeframe and every method to give you a final "Total Trend" status, helping you identify if the overall market sentiment is bullish, bearish, or neutral.

User Experience

The logic ensures that as the market moves, the dashboard updates automatically. By consolidating nine timeframes and four different technical strategies into one visual list, it serves as a high-level "command center," making it easier to spot convergences where multiple timeframes and methods all point in the same direction.

Indicators Used
Moving average indicatorMACD Histogram
5 Views
0 Downloads
0 Favorites
Trend_all_period_en
//+------------------------------------------------------------------+
//|                                             Trend_all_period.mq4 |
//|                               Copyright © 2009, Vladimir Hlystov |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, Vladimir Hlystov"
#property link      "cmillion@narod.ru"

#property indicator_chart_window
//-------------------------------------------------------------
extern int size_font=10;
extern int corner=3;//corner of the conclusion data
extern color color_UP = OrangeRed;
extern color color_DN = MediumBlue;
extern color color_0  = DimGray;
extern int period_TR=8;//period (only for "offset")
extern int offset_TR=5;//offset (only for "offset")
//-------------------------------------------------------------
string typetrend[4] = {"offset","offset2","5 13 34","MACD 5 34 5"};
string string_per[9] = {"M1","M5","M15","M30","H1","H4","D1","W1","MN1"};
int per[9] = {1,5,15,30,60,240,1440,10080,43200};
int trend[9],
    trendALL=0,
    sim,i,d;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   if (corner==1 || corner==2) {d = size_font*1.5;} else d = 0;
   int Õ = size_font*9;
   double Y = 10*(size_font+2);
   ObjectCreate ("All Period", OBJ_LABEL, 0, 0, 0);
   ObjectSet    ("All Period", OBJPROP_CORNER, corner);
   ObjectSet    ("All Period", OBJPROP_XDISTANCE, 10 );
   ObjectSet    ("All Period", OBJPROP_YDISTANCE, 5);
   for (i=0; i<9; i++) 
   {
      ObjectCreate (string_per[i]+" Period", OBJ_LABEL, 0, 0, 0);
      ObjectSetText(string_per[i]+" Period",string_per[i]+" ",size_font,"Arial",color_0);
      ObjectSet    (string_per[i]+" Period", OBJPROP_CORNER, corner);
      ObjectSet    (string_per[i]+" Period", OBJPROP_XDISTANCE, Õ );
      ObjectSet    (string_per[i]+" Period",  OBJPROP_YDISTANCE, Y-i*(size_font+2));

      ObjectCreate (string_per[i]+" MACD", OBJ_LABEL, 0, 0, 0);
      ObjectSet    (string_per[i]+" MACD", OBJPROP_CORNER, corner);
      ObjectSet    (string_per[i]+" MACD", OBJPROP_XDISTANCE, Õ-size_font*2 );
      ObjectSet    (string_per[i]+" MACD",  OBJPROP_YDISTANCE, Y-i*(size_font+2));

      ObjectCreate (string_per[i]+" MA5/13/34", OBJ_LABEL, 0, 0, 0);
      ObjectSet    (string_per[i]+" MA5/13/34", OBJPROP_CORNER, corner);
      ObjectSet    (string_per[i]+" MA5/13/34", OBJPROP_XDISTANCE, Õ-size_font*4 );
      ObjectSet    (string_per[i]+" MA5/13/34",  OBJPROP_YDISTANCE, Y-i*(size_font+2));

      ObjectCreate (string_per[i]+" offset2", OBJ_LABEL, 0, 0, 0);
      ObjectSet    (string_per[i]+" offset2", OBJPROP_CORNER, corner);
      ObjectSet    (string_per[i]+" offset2", OBJPROP_XDISTANCE, Õ-size_font*6 );
      ObjectSet    (string_per[i]+" offset2",  OBJPROP_YDISTANCE, Y-i*(size_font+2));

      ObjectCreate (string_per[i]+" offset", OBJ_LABEL, 0, 0, 0);
      ObjectSet    (string_per[i]+" offset", OBJPROP_CORNER, corner);
      ObjectSet    (string_per[i]+" offset", OBJPROP_XDISTANCE, Õ-size_font*8 );
      ObjectSet    (string_per[i]+" offset",  OBJPROP_YDISTANCE, Y-i*(size_font+2));
   }
   ObjectCreate (" MACD", OBJ_LABEL, 0, 0, 0);
   ObjectSet    (" MACD", OBJPROP_CORNER, corner);
   ObjectSet    (" MACD", OBJPROP_XDISTANCE, Õ-size_font*2+d );
   ObjectSet    (" MACD", OBJPROP_YDISTANCE, Y+size_font*6-d*2);
   ObjectSet    (" MACD", OBJPROP_ANGLE, 90);
   ObjectSetText(" MACD", "MACD ",size_font,"Arial",color_0);

   ObjectCreate (" MA5/13/34", OBJ_LABEL, 0, 0, 0);
   ObjectSet    (" MA5/13/34", OBJPROP_CORNER, corner);
   ObjectSet    (" MA5/13/34", OBJPROP_XDISTANCE, Õ-size_font*4+d );
   ObjectSet    (" MA5/13/34", OBJPROP_YDISTANCE, Y+size_font*6-d*2);
   ObjectSet    (" MA5/13/34", OBJPROP_ANGLE, 90);
   ObjectSetText(" MA5/13/34", "5/13/34",size_font,"Arial",color_0);

   ObjectCreate (" offset2", OBJ_LABEL, 0, 0, 0);
   ObjectSet    (" offset2", OBJPROP_CORNER, corner);
   ObjectSet    (" offset2", OBJPROP_XDISTANCE, Õ-size_font*6+d );
   ObjectSet    (" offset2", OBJPROP_YDISTANCE, Y+size_font*6-d*2);
   ObjectSet    (" offset2", OBJPROP_ANGLE, 90);
   ObjectSetText(" offset2", "offset2 ",size_font,"Arial",color_0);

   ObjectCreate (" offset", OBJ_LABEL, 0, 0, 0);
   ObjectSet    (" offset", OBJPROP_CORNER, corner);
   ObjectSet    (" offset", OBJPROP_XDISTANCE, Õ-size_font*8+d );
   ObjectSet    (" offset", OBJPROP_YDISTANCE, Y+size_font*6-d*2);
   ObjectSet    (" offset", OBJPROP_ANGLE, 90);
   ObjectSetText(" offset", "offset   ",size_font,"Arial",color_0);
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
   ObjectDelete("All Period");
   ObjectDelete(" MACD");
   ObjectDelete(" MA5/13/34");
   ObjectDelete(" offset");
   ObjectDelete(" offset2");
   for (i=0; i<9; i++) 
   {
      ObjectDelete(string_per[i]+" Period");
      ObjectDelete(string_per[i]+" MACD");
      ObjectDelete(string_per[i]+" MA5/13/34");
      ObjectDelete(string_per[i]+" offset");
      ObjectDelete(string_per[i]+" offset2");
   }
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   if (ObjectFind("All Period")!=0) 
   {
      init();
      //âûáîð òèïà
   }
   string str;
   color colortrend;
   //----------------------------------
   TR_R(0);//offset
   for (i=0; i<9; i++)
   {
      trendALL = trendALL + trend[i];
      if (trend[i]==0){colortrend=color_0;str="";} 
      if (trend[i]>0) {colortrend=color_UP;str="UP";}    
      if (trend[i]<0) {colortrend=color_DN;str="DN";}
      ObjectSetText(string_per[i]+" offset",str,size_font,"Arial",colortrend);
   }
   TR_R(1);//offset2
   for (i=0; i<9; i++)
   {
      trendALL = trendALL + trend[i];
      if (trend[i]==0){colortrend=color_0;str="";} 
      if (trend[i]>0) {colortrend=color_UP;str="UP";}    
      if (trend[i]<0) {colortrend=color_DN;str="DN";}
      ObjectSetText(string_per[i]+" offset2",str,size_font,"Arial",colortrend);
   }
   TR_R(2);//MA5/13/34
   for (i=0; i<9; i++)
   {
      trendALL = trendALL + trend[i];
      if (trend[i]==0){colortrend=color_0;str="";} 
      if (trend[i]>0) {colortrend=color_UP;str="UP";}    
      if (trend[i]<0) {colortrend=color_DN;str="DN";}
      ObjectSetText(string_per[i]+" MA5/13/34",str,size_font,"Arial",colortrend);
   }
   TR_R(3);//macd
   for (i=0; i<9; i++)
   {
      trendALL = trendALL + trend[i];
      if (trend[i]==0){colortrend=color_0;str="";} 
      if (trend[i]>0) {colortrend=color_UP;str="UP";}    
      if (trend[i]<0) {colortrend=color_DN;str="DN";}
      ObjectSetText(string_per[i]+" MACD",str,size_font,"Arial",colortrend);
   }
   if (trendALL==0){colortrend=color_0;str="";}     
   if (trendALL>0) {colortrend=Red;  str="UP ";}     
   if (trendALL<0) {colortrend=Green;str="DN ";}
   ObjectSetText("All Period","All "+str,size_font,"Arial",colortrend);
return(0);
}
//+------------------------------------------------------------------+
void TR_R(int t)
{
   switch(t)
   {  
      case 0 ://offset leading method
         for (i=0; i<9; i++) trend[i] = iCustom(NULL,0,"offset",period_TR,offset_TR,per[i],2,0);
      break; 
      case 1 ://offset óñòîÿâøèéñÿ trend
         for (i=0; i<9; i++)  trend[i] = iCustom(NULL,0,"offset",period_TR,offset_TR,per[i],2,0) + iCustom(NULL,0,"offset",period_TR,offset_TR,per[i],5,0);
      break; 
      case 2 : //way of the determination trend on method Ticket Williams on base MA 5 13 34
         double MA5,MA13,MA34;
         for (i=0; i<9; i++)
         {
            MA5  = iMA(NULL,per[i],5 ,0,MODE_SMA,PRICE_CLOSE,0);
            MA13 = iMA(NULL,per[i],13,0,MODE_SMA,PRICE_CLOSE,0);
            MA34 = iMA(NULL,per[i],34,0,MODE_SMA,PRICE_CLOSE,0);
            trend[i] = 0; if (MA5 > MA13 && MA5 > MA34) trend[i] = 1; if (MA5 < MA13 && MA5 < MA34) trend[i] = -1;
         }
      break; 
      case 3 ://way of the determination trend on MACD 5 34 5
         for (i=0; i<9; i++)
         {
            trend[i] = 0;
            if (iMACD(NULL,per[i],5,34,5,PRICE_CLOSE,MODE_MAIN,0) > iMACD(NULL,per[i],5,34,5,PRICE_CLOSE,MODE_MAIN,1)) trend[i] =  1;
            if (iMACD(NULL,per[i],5,34,5,PRICE_CLOSE,MODE_MAIN,0) < iMACD(NULL,per[i],5,34,5,PRICE_CLOSE,MODE_MAIN,1)) trend[i] = -1;
         }
      break; 
   }
}
//+------------------------------------------------------------------+

Comments