Williams_Inds

Author: Denis Orlov
Williams_Inds

Overview

This script is a specialized visual tool designed for MetaTrader users who employ the "Trading Chaos" strategy. Instead of cluttering your main chart with multiple separate windows or complex graphs, this tool consolidates three specific technical indicators into a single, movable on-screen panel. It provides a quick, at-a-glance summary of market direction by tracking the behavior of three popular tools: Awesome Oscillator (AO), Awesomed Oscillator (AC), and MACD.

Core Functionality

The script performs three primary tasks to help a trader monitor market momentum:

1. Directional Tracking The tool continuously monitors the current values of the AO, AC, and MACD indicators. It compares the current data point against the previous one to determine direction:

  • Upward Movement: If the current value is higher than the previous one, the tool identifies an "Up" trend and displays a corresponding upward arrow/icon in Lime or Green.
  • Downward Movement: If the current value is lower than the previous one, the tool identifies a "Down" trend and displays a downward arrow/icon in Red.

2. Interactive Dashboard Rather than being fixed to a specific spot on your screen, the dashboard features an interactive design:

  • Manual Positioning: Users can click and drag the panel to relocate it anywhere on the chart to suit their visual preference.
  • Dynamic Scaling: The height of the panel automatically adjusts based on the timeframe you are viewing (e.g., it scales differently for 1-minute charts versus Daily charts) to ensure readability across all timeframes.
  • Visual Themes: The script includes a toggle for different visual themes, allowing users to switch between color schemes (such as a "White Chart" theme) to match their specific UI setup.

3. Intelligent Alerts The script includes a logic-based notification system designed to highlight high-probability moments. It monitors for "Unidirectional" signals—specifically, instances where all three indicators (AO, AC, and MACD) agree on the same direction simultaneously.

  • When all three point UP, an alert is triggered.
  • When all three point DOWN, an alert is triggered. The tool manages these alerts automatically to ensure you are notified of significant consensus in market momentum without being overwhelmed by repetitive signals.

Summary for the User

Essentially, this script acts as a "Command Center." It simplifies your trading workspace by distilling complex mathematical data into simple colored icons. If the panel shows all arrows pointing in one direction, it signifies a strong trend agreement across three different technical perspectives, allowing for faster decision-making during active trading.

Indicators Used
Bill Williams Awesome oscillatorBill Williams Accelerator/Decelerator oscillatorMACD Histogram
Miscellaneous
It issuies visual alerts to the screen
14 Views
0 Downloads
0 Favorites
Williams_Inds
//+------------------------------------------------------------------+
//|                                                 Williams_Inds.mq4 |
//|                                                      Denis Orlov |
//|                                    http://denis-or-love.narod.ru |
/*
Ïåðåìåùàåìàÿ ïàíåëü ñ èíäèêàòîðàìè Á.Âèëüÿìñà, äëÿ ñòðàòåãèè Òîðãîâûé õàîñ. 
Ïîêàçûâàåò íàïðàâëåíèå èíäèêàòîðîâ AO, AC, è MACD.
http://codebase.mql4.com/ru/6318

The moved panel with the indicators of B.Williams, for strategy Trading chaos. 
It shows a direction of indicators AO, AC, and MACD.
http://codebase.mql4.com/6319

Äåíèñ Îðëîâ
http://denis-or-love.narod.ru

***
Âñå ìîè èíäèêàòîðû:
http://codebase.mql4.com/ru/author/denis_orlov
***
ÏÎËÜÇÓÉÒÅÑÜ È ÏÐÎÖÂÅÒÀÉÒÅ!

*/
//+------------------------------------------------------------------+
#property copyright "Denis Orlov"
#property link      "http://denis-or-love.narod.ru"

#property indicator_chart_window
#define Pref "B.Williams Panel: "


extern string note1="Parameters of MACD:";
extern int FastEMA=12;
extern int SlowEMA=26;
extern int SignalSMA=9;
extern string note2="Coordinates:";
extern int X=30;
extern int Y=0; 
extern int H=0;
extern string note3="Colors, two themes:";
extern color RectClr=Gray;
extern color TxtClr=White;
extern color UpClr=Lime;
extern color DnClr=Red;
extern bool White_Chart_Theme=True;
extern color RectClr1=Gray;
extern color TxtClr1=Maroon;
extern color UpClr1=Green;
extern color DnClr1=Red;

//extern
   int W=9;

   
int nS=3;// êîëè÷åñòâî ñòðîê 
int StepS;//øàã ñòðîêè

int TimeX;
double PriceY;
int TimeW;
double PriceH;
int codeAO, codeAC, codeMACD;
color ClrAO , ClrAC, ClrMACD ;
bool Allow_Hand_Moving=True;
color HandClr=Green;
bool Alert_=False;
color Alert_Clr=Red;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
      //TimeX=Time[0]-X*Period()*60; 
     // PriceY=WindowPriceMax()-Y*Point;
     if(H==0)H=CalculeH();
     
      TimeW=W*Period()*60;
      PriceH=H*Point;
      
      StepS=MathRound(H/nS);
      
      if(White_Chart_Theme)
            {
                RectClr=RectClr1;
                TxtClr=TxtClr1;
                UpClr=UpClr1;
                DnClr=DnClr1;
            }
       
       DrawPanel();
      
      
//----

   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   Delete_My_Obj(Pref);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
//----

      if ( iAO( NULL , Period(), 1)< iAO( NULL , Period(), 0) ) 
         {codeAO=217; ClrAO=UpClr; } else
         {codeAO=218; ClrAO=DnClr;}
         
      if (iAC( NULL , Period(), 1)<iAC( NULL , Period(), 0)) 
         {codeAC=217; ClrAC=UpClr;} else
         {codeAC=218; ClrAC=DnClr;} /* */
       
      if( iMACD( NULL , Period(),  
            FastEMA, SlowEMA, SignalSMA, PRICE_CLOSE, MODE_MAIN, 1)< iMACD( NULL , Period(),  
            FastEMA, SlowEMA, SignalSMA, PRICE_CLOSE, MODE_MAIN, 0) ) 
          {codeMACD=217; ClrMACD=UpClr;} else
         {codeMACD=218; ClrMACD=DnClr;} 
         
          
      if(Alert_)
            {
               
               if(codeAO==217 && codeAC==217 && codeMACD==217)
                  {Alert(Symbol()+" "+PeriodToStr(Period())
                  +" : AO, AC and MACD are UP at "+TimeToStr(TimeCurrent(),TIME_MINUTES)); 
                  ObjectDelete(Pref+"Unidirection Alert"); }
               
               if(codeAO==218 && codeAC==218 && codeMACD==218)
                  {Alert(Symbol()+" "+PeriodToStr(Period())
                  +" : AO, AC and MACD are DOWN at "+TimeToStr(TimeCurrent(),TIME_MINUTES) ); 
                  ObjectDelete(Pref+"Unidirection Alert"); }
               
            }
          
      if(ObjectFind(Pref+"Unidirection Alert")<0)
            Alert_=!Alert_;
      if(Alert_)Alert_Clr=UpClr; else Alert_Clr=DnClr;
      
      if(ObjectFind(Pref+"Allow Hand Moving")<0)
            Allow_Hand_Moving=!Allow_Hand_Moving;
            
      if(Allow_Hand_Moving)
            {
               
               HandClr=UpClr; 
               int TimeX_=ObjectGet(Pref+"Rect",OBJPROP_TIME1);
                    if(TimeX_>Time[WindowFirstVisibleBar()]+X*Period()*60) 
                    X=(TimeX_-Time[WindowFirstVisibleBar()])/Period()/60;
            
              double PriceY_=ObjectGet(Pref+"Rect",OBJPROP_PRICE1);
                    if(PriceY_<WindowPriceMax()-Y*Point) 
                    Y=(WindowPriceMax()-PriceY_)/Point; /**/
                    
             if(ObjectFind(Pref+"Rect")<0)
                  {X=0;Y=0;}            
            }
            else HandClr=DnClr;  
            
      DrawPanel();
//----
   return(0);
  }
//+------------------------------------------------------------------+
int DrawText( string name, datetime T, double P, string Text, int code=0, color Clr=Green,  int Fsize=10, int Win=0)
   { 
      if (name=="") name="Text_"+T;
      
      int Error=ObjectFind(name);// Çàïðîñ 
   if (Error!=Win)// Åñëè îáúåêòà â óê. îêíå íåò :(
    { 
      ObjectCreate(name, OBJ_TEXT, Win, T, P);
      }
      
      ObjectSet(name, OBJPROP_TIME1, T);
      ObjectSet(name, OBJPROP_PRICE1, P);
      if(code==0)
      ObjectSetText(name, Text ,Fsize,"Arial",Clr);
      else
      ObjectSetText(name, CharToStr(code), Fsize,"Wingdings",Clr);
   }
   
//--------------------------------------
void DrawPanel()
{     if(Y<0) Y=0;
      if(Y>(WindowPriceMax()-WindowPriceMin())/Point-H)
       Y=(WindowPriceMax()-WindowPriceMin())/Point-H;
      
      TimeX=Time[WindowFirstVisibleBar()]+X*Period()*60; 
      PriceY=WindowPriceMax()-Y*Point;
      
      DrawRect( Pref+"Rect", TimeX, PriceY, TimeX+TimeW ,PriceY-PriceH, RectClr, 1, "");
      
      DrawText( Pref+"Allow Hand Moving", TimeX+1*Period()*60, PriceY-1*Point, "", 73, HandClr );
      DrawText( Pref+"Unidirection Alert", TimeX+1*Period()*60, PriceY-(1+StepS)*Point, "", 37, Alert_Clr );
      
      DrawText( Pref+"AO", TimeX+4*Period()*60, PriceY-1*Point, "AO", 0,TxtClr );//0, 10, 0
      DrawText( Pref+"AC", TimeX+4*Period()*60, PriceY-(1+StepS)*Point, "AC", 0,TxtClr );
      DrawText( Pref+"MACD", TimeX+3*Period()*60, PriceY-(1+2*StepS)*Point, "MACD", 0,TxtClr );
      
      DrawText( Pref+"AO direction", TimeX+8*Period()*60, PriceY-1*Point, "", codeAO, ClrAO );
      DrawText( Pref+"AC direction", TimeX+8*Period()*60, PriceY-(1+StepS)*Point, "", codeAC, ClrAC );
      DrawText( Pref+"MACD direction", TimeX+8*Period()*60, PriceY-(1+2*StepS)*Point, "", codeMACD, ClrMACD );
}

//---------------------------------
int DrawRect( string name, datetime T1, double P1,datetime T2, double P2,
                    color Clr=Green, int Width=1, string Text="", int Win=0)
   { 
      if (name=="") name="Text_"+T1;
      
      int Error=ObjectFind(name);// Çàïðîñ 
    if (Error!=Win)// Åñëè îáúåêòà â óê. îêíå íåò :(
    {  
      ObjectCreate(name, OBJ_RECTANGLE, Win,T1,P1,T2,P2);//ñîçäàíèå òðåíäîâîé ëèíèè
    }
     
    ObjectSet(name, OBJPROP_TIME1 ,T1);
    ObjectSet(name, OBJPROP_PRICE1,P1);
    ObjectSet(name, OBJPROP_TIME2 ,T2);
    ObjectSet(name, OBJPROP_PRICE2,P2);
    ObjectSet(name,OBJPROP_BACK, false);
    ObjectSet(name,OBJPROP_STYLE,0);
    ObjectSet(name, OBJPROP_COLOR , Clr);
    ObjectSet(name, OBJPROP_WIDTH , Width);
    ObjectSetText(name,Text);
    
    }
///-----------------------
void Delete_My_Obj(string Prefix)
   {//Alert(ObjectsTotal());
   for(int k=ObjectsTotal()-1; k>=0; k--)  // Ïî êîëè÷åñòâó âñåõ îáúåêòîâ 
     {
      string Obj_Name=ObjectName(k);   // Çàïðàøèâàåì èìÿ îáúåêòà
      string Head=StringSubstr(Obj_Name,0,StringLen(Prefix));// Èçâëåêàåì ïåðâûå ñèì

      if (Head==Prefix)// Íàéäåí îáúåêò, ..
         {
         ObjectDelete(Obj_Name);
         //Alert(Head+";"+Prefix);
         }                
        
     }
   }
///=====================
string PeriodToStr(int Per)
   {
      switch(Per)                 // Ðàñ÷¸ò  äëÿ..     
      {                              // .. ðàçëè÷íûõ ÒÔ     
      case     1: return("M1"); break;// Òàéìôðåéì Ì1      
      case     5: return("M5"); break;// Òàéìôðåéì Ì5      
      case    15: return("M15"); break;// Òàéìôðåéì Ì15      
      case    30: return("M30"); break;// Òàéìôðåéì Ì30      
      case    60: return("H1"); break;// Òàéìôðåéì H1      
      case   240: return("H4"); break;// Òàéìôðåéì H4      
      case  1440: return("D1"); break;// Òàéìôðåéì D1      
      case 10080: return("W1"); break;// Òàéìôðåéì W1      
      case 43200: return("ÌN"); break;// Òàéìôðåéì ÌN     
      }
 }
//==================================
int CalculeH()
   {
      switch(Period())                 // Ðàñ÷¸ò  äëÿ..     
      {                              // .. ðàçëè÷íûõ ÒÔ     
      case     1: return(15); break;// Òàéìôðåéì Ì1      
      case     5: return(15); break;// Òàéìôðåéì Ì5      
      case    15: return(30); break;// Òàéìôðåéì Ì15      
      case    30: return(45); break;// Òàéìôðåéì Ì30      
      case    60: return(60); break;// Òàéìôðåéì H1      
      case   240: return(180); break;// Òàéìôðåéì H4      
      case  1440: return(270); break;// Òàéìôðåéì D1      
      case 10080: return(450); break;// Òàéìôðåéì W1      
      case 43200: return(900); break;// Òàéìôðåéì ÌN     
      }   
    }

Comments