JJN-Infobar

Author: Copyright � 2010, JJ Newark
JJN-Infobar
This script is designed to display a small informational panel directly on your trading chart. It gives you a quick overview of market conditions without cluttering your main chart view.

Here's a breakdown of what it does, piece by piece:

**1. Initial Setup & Customization:**

*   The script starts by setting up some basic information, like copyright details and a link to the author's website.
*   It then allows you, the user, to customize several aspects of the information panel. These include:
    *   **Indicator Settings:** Parameters for technical indicators like ADX, PSAR, RSI, Stochastic Oscillator and MACD that it uses to assess market trends. You can adjust things like the periods used for calculations.
    *   **Display Settings:**  You control how the information is displayed. You can customize the colors used for upward trends, downward trends, and flat/sideways movement. You can also choose the text color, separator line color, and whether to display a background for the info panel and its color. You can also set the location (X and Y coordinates) of the panel on the chart. Finally, there's an option to specify how many decimal places to show for the current price.

**2. Displaying the Information Panel:**

*   The script creates a series of labels (text boxes) on the chart to display the information.
*   It creates a background to the panel to improve visibility, if the user chooses to do so.
*   It displays a title for the information panel ("JJN-InfoBar").
*   It draws horizontal lines to visually separate different sections of the panel.
*   It labels the timeframes being monitored ("1 5 15 30 H1 H4 D W M"). These represent different intervals of time that the script will analyze (1 minute, 5 minutes, etc., up to monthly).

**3. Real-Time Analysis and Display:**

*   The script constantly updates the information on the panel with the latest market data.
*   **RSI, Stochastic, and MACD:** It calculates the current values of the Relative Strength Index (RSI), Stochastic Oscillator, and Moving Average Convergence Divergence (MACD) indicators. It shows these values in the panel, along with an arrow (up, down, or sideways) indicating the current trend of each indicator.
*   **Spread:** It displays the current spread (the difference between the buying and selling price) for the currency pair.
*   **Remaining Bar Time:** It shows the time remaining until the current chart bar closes. This helps you anticipate potential market changes as the bar nears its end.
*   **Current Price:** The current price is displayed in a large, easily readable format. The color of the price changes based on whether the current price is higher or lower than the previous price, giving you an immediate visual cue about price direction.

**4. Multi-Timeframe Analysis:**

*   The script analyzes market trends across multiple timeframes (1 minute, 5 minutes, 15 minutes, etc.). This is a core feature of the panel.
*   For each timeframe, it calculates the values of the ADX and PSAR indicators.
*   Based on the ADX and PSAR values, it determines the overall trend for that timeframe:
    *   **Upward Trend:**  If the Parabolic SAR (PSAR) is below the current price AND the ADX indicates the trend is positive, it signals an upward trend for that timeframe.
    *   **Downward Trend:** If the PSAR is above the current price AND the ADX indicates the trend is negative, it signals a downward trend.
    *   **Sideways/No Trend:** If neither of the above conditions is met, it indicates a sideways or uncertain trend.
*   The script then displays a small colored arrow for each timeframe on the information panel. The color of the arrow corresponds to the identified trend (up, down, or sideways).

**In summary:**

The script acts as a mini-dashboard, providing a quick visual assessment of market trends across multiple timeframes, along with real-time information about indicator values, spread, remaining bar time, and current price. This allows traders to quickly gauge overall market sentiment and make informed trading decisions.
Price Data Components
Series array that contains close prices for each bar
Indicators Used
Relative strength indexStochastic oscillatorMACD HistogramMovement directional indexParabolic Stop and Reverse system
3 Views
0 Downloads
0 Favorites
JJN-Infobar
//+------------------------------------------------------------------+
//|                                                  JJN-InfoBar.mq4 |
//|                                      Copyright © 2010, JJ Newark |
//|                                           http://jjnewark.atw.hu |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2010, JJ Newark"
#property link      "http://jjnewark.atw.hu"

#property indicator_chart_window

int tframe[]={1,5,15,30,60,240,1440,10080,43200};
int tfnumber=9;    

extern string     _Copyright_                 = "http://jjnewark.atw.hu";
extern string     _IndicatorSetup_            = ">>> Indicator Setup:<<<";
extern int        ADX_Period                  = 14;
extern int        ADX_Price                   = PRICE_CLOSE;
extern double     Step_Psar                   = 0.02;
extern double     Max_Psar                    = 0.2;
extern int        RSI_Period                  = 14;
extern int        Stoch_KPeriod               = 5;
extern int        Stoch_DPeriod               = 3;
extern int        Stoch_Slowing               = 3;
extern int        Macd_FastP                  = 12;
extern int        Macd_SlowP                  = 26;
extern int        Macd_SignalP                = 9;

extern string     _DisplaySetup_              = ">>> Display Setup:<<<";
extern string     Help_for_BigPrice_Decimals  = "Used only: 2,3,4,5!";
extern int        BigPrice_Decimals           = 5;
extern color      UpColor                     = Lime;
extern color      DownColor                   = OrangeRed;
extern color      FlatColor                   = Gold;
extern color      TextColor                   = Silver;
extern color      SeparatorColor              = DimGray;
extern bool       ShowBackground              = TRUE;
extern color      BackgroundColor             = Black;
extern int        PosX                        = 0;
extern int        PosY                        = 0;

double Psar;
double PADX,NADX;
string TimeFrameStr;
double IndVal[9];
double Rsi1,Rsi2,Stoch_Main,Stoch_Signal,Macd_Main,Macd_Signal;
double Prev_Price;
string q="s";


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
  
   
   if(ShowBackground)
   {
   for(int x=0;x<6;x++) // 
   for(int w=0;w<6;w++)
      {
         ObjectCreate("Bkgrd"+x+q+w,OBJ_LABEL,0,0,0,0,0);
         ObjectSet("Bkgrd"+x+q+w,OBJPROP_CORNER,0);
         ObjectSet("Bkgrd"+x+q+w,OBJPROP_XDISTANCE,x*24+PosX+10);
         ObjectSet("Bkgrd"+x+q+w,OBJPROP_YDISTANCE,w*24+PosY);
         ObjectSetText("Bkgrd"+x+q+w,CharToStr(110),32,"Wingdings",BackgroundColor);
      }
   } 
      
      
   for(int j=0;j<tfnumber;j++)
      {
         ObjectCreate("Ind"+j,OBJ_LABEL,0,0,0,0,0);
         ObjectSet("Ind"+j,OBJPROP_CORNER,0);
         ObjectSet("Ind"+j,OBJPROP_XDISTANCE,j*16+PosX+15);
         ObjectSet("Ind"+j,OBJPROP_YDISTANCE,PosY+32);
         ObjectSetText("Ind"+j,CharToStr(110),12,"Wingdings",White);
      }


   ObjectCreate("IndName",OBJ_LABEL,0,0,0,0,0);
   ObjectSet("IndName",OBJPROP_CORNER,0);
   ObjectSet("IndName",OBJPROP_XDISTANCE,PosX+56);
   ObjectSet("IndName",OBJPROP_YDISTANCE,PosY+10);
   ObjectSetText("IndName","JJN-InfoBar",8,"Tahoma",TextColor);
   
   ObjectCreate("Line0",OBJ_LABEL,0,0,0,0,0);
   ObjectSet("Line0",OBJPROP_CORNER,0);
   ObjectSet("Line0",OBJPROP_XDISTANCE,PosX+17);
   ObjectSet("Line0",OBJPROP_YDISTANCE,PosY+16);
   ObjectSetText("Line0","----------------------------------",8,"Tahoma",SeparatorColor);
   
   ObjectCreate("Line1",OBJ_LABEL,0,0,0,0,0);
   ObjectSet("Line1",OBJPROP_CORNER,0);
   ObjectSet("Line1",OBJPROP_XDISTANCE,PosX+17);
   ObjectSet("Line1",OBJPROP_YDISTANCE,PosY+18);
   ObjectSetText("Line1","----------------------------------",8,"Tahoma",SeparatorColor);

   ObjectCreate("TFrame",OBJ_LABEL,0,0,0,0,0);
   ObjectSet("TFrame",OBJPROP_CORNER,0);
   ObjectSet("TFrame",OBJPROP_XDISTANCE,PosX+17);
   ObjectSet("TFrame",OBJPROP_YDISTANCE,PosY+24);
   ObjectSetText("TFrame","1    5   15  30  H1 H4  D  W   M",8,"Tahoma",TextColor);
   
   ObjectCreate("Line2",OBJ_LABEL,0,0,0,0,0);
   ObjectSet("Line2",OBJPROP_CORNER,0);
   ObjectSet("Line2",OBJPROP_XDISTANCE,PosX+16);
   ObjectSet("Line2",OBJPROP_YDISTANCE,PosY+40);
   ObjectSetText("Line2","..............................................",8,"Tahoma",SeparatorColor);

   ObjectCreate("Line3",OBJ_LABEL,0,0,0,0,0);
   ObjectSet("Line3",OBJPROP_CORNER,0);
   ObjectSet("Line3",OBJPROP_XDISTANCE,PosX+16);
   ObjectSet("Line3",OBJPROP_YDISTANCE,PosY+55);
   ObjectSetText("Line3","..............................................",8,"Tahoma",SeparatorColor);
   
   ObjectCreate("Line4",OBJ_LABEL,0,0,0,0,0);
   ObjectSet("Line4",OBJPROP_CORNER,0);
   ObjectSet("Line4",OBJPROP_XDISTANCE,PosX+16);
   ObjectSet("Line4",OBJPROP_YDISTANCE,PosY+70);
   ObjectSetText("Line4","..............................................",8,"Tahoma",SeparatorColor);
   
   ObjectCreate("Line5",OBJ_LABEL,0,0,0,0,0);
   ObjectSet("Line5",OBJPROP_CORNER,0);
   ObjectSet("Line5",OBJPROP_XDISTANCE,PosX+17);
   ObjectSet("Line5",OBJPROP_YDISTANCE,PosY+131);
   ObjectSetText("Line5","----------------------------------",8,"Tahoma",SeparatorColor);
   
   ObjectCreate("Line6",OBJ_LABEL,0,0,0,0,0);
   ObjectSet("Line6",OBJPROP_CORNER,0);
   ObjectSet("Line6",OBJPROP_XDISTANCE,PosX+17);
   ObjectSet("Line6",OBJPROP_YDISTANCE,PosY+133);
   ObjectSetText("Line6","----------------------------------",8,"Tahoma",SeparatorColor);
   
   ObjectCreate("GGekko",OBJ_LABEL,0,0,0,0,0);
   ObjectSet("GGekko",OBJPROP_CORNER,0);
   ObjectSet("GGekko",OBJPROP_XDISTANCE,PosX+35);
   ObjectSet("GGekko",OBJPROP_YDISTANCE,PosY+140);
   ObjectSetText("GGekko","http://jjnewark.atw.hu",8,"Tahoma",TextColor);
   
   
   

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----

   ObjectDelete("TFrame");
   for(int k=0;k<tfnumber;k++)
      ObjectDelete("Ind"+k);
   ObjectDelete("Line0");
   ObjectDelete("Line1");
   ObjectDelete("Line2");
   ObjectDelete("Line3");
   ObjectDelete("Line4");
   ObjectDelete("Line5");
   ObjectDelete("Line6");
   ObjectDelete("GGekko");
   ObjectDelete("IndName");
      
   ObjectDelete("Time_remain");
   ObjectDelete("Rsi_val");
   ObjectDelete("Stoch_val");
   ObjectDelete("Macd_val");
   ObjectDelete("Rsi_updown");
   ObjectDelete("Stoch_updown");
   ObjectDelete("Macd_updown");
   ObjectDelete("Spread");
   ObjectDelete("PriceDisplay");
   
   for(int x=0;x<46;x++)
   for(int w=0;w<130;w++)
      {
         ObjectDelete("Bkgrd"+x+q+w);
      }
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   
//----
   
     
  
   Rsi1=iRSI(NULL,0,RSI_Period,PRICE_CLOSE,0);
   Rsi2=iRSI(NULL,0,RSI_Period,PRICE_CLOSE,1);
   ObjectCreate("Rsi_val",OBJ_LABEL,0,0,0,0,0);
   ObjectSet("Rsi_val",OBJPROP_CORNER,0);
   ObjectSet("Rsi_val",OBJPROP_XDISTANCE,PosX+17);
   ObjectSet("Rsi_val",OBJPROP_YDISTANCE,PosY+50);
   ObjectSetText("Rsi_val",StringConcatenate("RSI: ",DoubleToStr(Rsi1,0)),8,"Tahoma",TextColor);
       
   ObjectCreate("Rsi_updown",OBJ_LABEL,0,0,0,0,0);
   ObjectSet("Rsi_updown",OBJPROP_CORNER,0);
   ObjectSet("Rsi_updown",OBJPROP_XDISTANCE,PosX+63);
   ObjectSet("Rsi_updown",OBJPROP_YDISTANCE,PosY+48);
   if(Rsi1>Rsi2)
   ObjectSetText("Rsi_updown",CharToStr(110),12,"Wingdings",UpColor); 
   if(Rsi1<Rsi2)
   ObjectSetText("Rsi_updown",CharToStr(110),12,"Wingdings",DownColor);
   if(Rsi1==Rsi2)
   ObjectSetText("Rsi_updown",CharToStr(110),12,"Wingdings",FlatColor);
   
   Stoch_Main=iStochastic(NULL,0,Stoch_KPeriod,Stoch_DPeriod,Stoch_Slowing,MODE_SMA,0,MODE_MAIN,0);
   Stoch_Signal=iStochastic(NULL,0,Stoch_KPeriod,Stoch_DPeriod,Stoch_Slowing,MODE_SMA,0,MODE_SIGNAL,0);
   ObjectCreate("Stoch_val",OBJ_LABEL,0,0,0,0,0);
   ObjectSet("Stoch_val",OBJPROP_CORNER,0);
   ObjectSet("Stoch_val",OBJPROP_XDISTANCE,PosX+81);
   ObjectSet("Stoch_val",OBJPROP_YDISTANCE,PosY+50);
   ObjectSetText("Stoch_val",StringConcatenate("STOCH: ",DoubleToStr(Stoch_Main,0)),8,"Tahoma",TextColor);
   
   ObjectCreate("Stoch_updown",OBJ_LABEL,0,0,0,0,0);
   ObjectSet("Stoch_updown",OBJPROP_CORNER,0);
   ObjectSet("Stoch_updown",OBJPROP_XDISTANCE,PosX+143);
   ObjectSet("Stoch_updown",OBJPROP_YDISTANCE,PosY+48);
   if(Stoch_Main>Stoch_Signal)
   ObjectSetText("Stoch_updown",CharToStr(110),12,"Wingdings",UpColor); 
   if(Stoch_Main<Stoch_Signal)
   ObjectSetText("Stoch_updown",CharToStr(110),12,"Wingdings",DownColor);
   if(Stoch_Main==Stoch_Signal)
   ObjectSetText("Stoch_updown",CharToStr(110),12,"Wingdings",FlatColor);
   
   Macd_Main=iMACD(NULL,0,Macd_FastP,Macd_SlowP,Macd_SignalP,PRICE_CLOSE,MODE_MAIN,0);
   Macd_Signal=iMACD(NULL,0,Macd_FastP,Macd_SlowP,Macd_SignalP,PRICE_CLOSE,MODE_SIGNAL,0);
   ObjectCreate("Macd_val",OBJ_LABEL,0,0,0,0,0);
   ObjectSet("Macd_val",OBJPROP_CORNER,0);
   ObjectSet("Macd_val",OBJPROP_XDISTANCE,PosX+17);
   ObjectSet("Macd_val",OBJPROP_YDISTANCE,PosY+65);
   ObjectSetText("Macd_val","MACD trend",8,"Tahoma",TextColor);
   
   ObjectCreate("Macd_updown",OBJ_LABEL,0,0,0,0,0);
   ObjectSet("Macd_updown",OBJPROP_CORNER,0);
   ObjectSet("Macd_updown",OBJPROP_XDISTANCE,PosX+79);
   ObjectSet("Macd_updown",OBJPROP_YDISTANCE,PosY+63);
   if(Macd_Main>Macd_Signal)
   ObjectSetText("Macd_updown",CharToStr(110),12,"Wingdings",UpColor); 
   if(Macd_Main<Macd_Signal)
   ObjectSetText("Macd_updown",CharToStr(110),12,"Wingdings",DownColor);
   if(Macd_Main==Macd_Signal)
   ObjectSetText("Macd_updown",CharToStr(110),12,"Wingdings",FlatColor);
   
   ObjectCreate("Spread",OBJ_LABEL,0,0,0,0,0);
   ObjectSet("Spread",OBJPROP_CORNER,0);
   ObjectSet("Spread",OBJPROP_XDISTANCE,PosX+103);
   ObjectSet("Spread",OBJPROP_YDISTANCE,PosY+65);
   ObjectSetText("Spread",StringConcatenate("Spread: ",MarketInfo(Symbol(),MODE_SPREAD)),8,"Tahoma",TextColor);
      
   datetime closetime=Time[0]+(Time[0]-Time[1])-TimeCurrent();
   ObjectCreate("Time_remain",OBJ_LABEL,0,0,0,0,0);
   ObjectSet("Time_remain",OBJPROP_CORNER,0);
   ObjectSet("Time_remain",OBJPROP_XDISTANCE,PosX+17);
   ObjectSet("Time_remain",OBJPROP_YDISTANCE,PosY+80);
   ObjectSetText("Time_remain",StringConcatenate("Remaining bartime:  ",TimeToStr(closetime,TIME_SECONDS)),8,"Tahoma",TextColor);
   
   ObjectCreate("PriceDisplay",OBJ_LABEL,0,0,0,0,0);
   ObjectSet("PriceDisplay",OBJPROP_CORNER,0);
   if(BigPrice_Decimals==2)
   ObjectSet("PriceDisplay",OBJPROP_XDISTANCE,PosX+44);
   if(BigPrice_Decimals==3)
   ObjectSet("PriceDisplay",OBJPROP_XDISTANCE,PosX+40);
   if(BigPrice_Decimals==4)
   ObjectSet("PriceDisplay",OBJPROP_XDISTANCE,PosX+36);
   if(BigPrice_Decimals==5)
   ObjectSet("PriceDisplay",OBJPROP_XDISTANCE,PosX+28);
   ObjectSet("PriceDisplay",OBJPROP_YDISTANCE,PosY+95);
   if(iClose(NULL,0,0)>Prev_Price)
   ObjectSetText("PriceDisplay",DoubleToStr(iClose(NULL,0,0),BigPrice_Decimals),24,"Tahoma",UpColor);
   if(iClose(NULL,0,0)<Prev_Price)
   ObjectSetText("PriceDisplay",DoubleToStr(iClose(NULL,0,0),BigPrice_Decimals),24,"Tahoma",DownColor);
   Prev_Price=iClose(NULL,0,0);  
   
   
      
    
   for(int x=0;x<tfnumber;x++)
      {
      
      PADX=iADX(NULL,tframe[x],ADX_Period ,ADX_Price,1,0);
      NADX=iADX(NULL,tframe[x],ADX_Period ,ADX_Price,2,0);
      Psar=iSAR(NULL,tframe[x],Step_Psar,Max_Psar,0) ;
        if (Psar < iClose(NULL,tframe[x],0) && PADX > NADX)
        {
        IndVal[x]=1;
        }
        else if (Psar > iClose(NULL,tframe[x],0) && NADX > PADX)
        {
        IndVal[x]=-1;
        }
        else IndVal[x]=0;
      }
   
   
   
      for(int y=0;y<tfnumber;y++)
      {
         if(IndVal[y]==-1) ObjectSetText("Ind"+y,CharToStr(110),12,"Wingdings",DownColor);
         if(IndVal[y]==0) ObjectSetText("Ind"+y,CharToStr(110),12,"Wingdings",FlatColor);
         if(IndVal[y]==1) ObjectSetText("Ind"+y,CharToStr(110),12,"Wingdings",UpColor);
      }  
           
   
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---