3LB On Chart

Download script
Author: Alijaan
3LB On Chart

This script is designed as a technical analysis tool for the MetaTrader 4 platform. It functions by analyzing price movement trends—specifically looking at "Up" and "Down" trends—to provide the user with real-time visual feedback and trading suggestions directly on the chart.

Core Logic and Behavior

Trend Detection Engine The script scans historical price data to identify the direction of the market. It distinguishes between upward movements and downward movements by comparing recent closing prices against previous price levels.

  • Down Trend Analysis: When the market is moving downward, the script monitors for specific price breaks. If the price begins to show signs of recovery or shifts in behavior, it triggers a change in status.
  • Up Trend Analysis: Conversely, when the market is moving upward, the script tracks the momentum. It looks for specific "breakout" points where the price might be attempting to reverse its current path.

Dynamic Feedback System (The Counter) One of the most unique features of this script is its "Counter" system. As it processes price movements, it assigns a numerical value to the current market state. This number isn't just a random count; it represents a specific stage in a trading sequence.

Real-Time Trading Suggestions The script uses this counter to display dynamic text comments on your screen. Depending on what the "Block Number" (the counter) is, the script provides specific instructions for the trader:

  • Early Stages: It might suggest waiting for the current candle to confirm its direction.
  • Entry Signals: At specific counts, it explicitly suggests opening a new position.
  • Exit Signals: At other specific counts, it advises closing an existing old position.
  • Hold Signals: For certain middle-range counts, it instructs the trader to keep their current position open.
  • Neutral States: Once the count reaches higher numbers, the script shifts to a "Wait... No Suggestion" status, indicating that no immediate action is required based on the current logic.

Visual Representation Technically, the script plots two different visual histograms on your chart (colored Blue and Red). These serve as the visual foundation for the trend tracking, allowing you to see the data points that the script is using to calculate its suggestions.

Summary for the User

Essentially, this tool acts like a "decision assistant." It watches the price trends in the background, calculates which stage of a market move you are currently in, and then prints a clear text message on your screen telling you whether it's time to wait, enter a trade, stay in your current trade, or exit.

Price Data Components
Series array that contains open time of each bar
Miscellaneous
Implements a curve of type %1
10 Views
0 Downloads
0 Favorites
3LB On Chart
//+------------------------------------------------------------------+
//|                                                      Alijaan.mq4 |
//|                                            http://www.4-iran.com |
//|                                            E-Mail:Ali@4-iran.com |
//+------------------------------------------------------------------+
#property copyright "Alijaan"
#property link      "http://www.sarmaye.com"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red


//---- input parameters
extern int       TLB_Start=500;

//---- buffers
double Buffer1[];
double Buffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexBuffer(0,Buffer1);
   SetIndexStyle(1,DRAW_HISTOGRAM);
   SetIndexBuffer(1,Buffer2);
//----
   return(0);
  }   
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
//--------------------------------------------------------------------------------------
   int i,Counter;
   double Line1,Line2,Line3,Line4;
   double s1[];   
   bool First,End,End_Up,End_Down,Trend,Trend_Back;
//--------------------------------------------------------------------------------------
   i = TLB_Start;
   First = True;
   Trend_Back = False;
//--------------------------------------------------------------------------------------
	double t;
   int m,s,k;
   m=Time[0]+Period()*60-CurTime();
   t=m/60.0;
   s=m%60;
   m=(m-m%60)/60;
   t=NormalizeDouble(t,1);
   for (k=1;k<=Bars-1;k++) s1[k]=0.0000001;
   for (k=1;k<=2;k++) s1[k]=t;
//--------------------------------------------------------------------------------------
      Buffer2[i] = Open[i];
      Buffer1[i] = Close[i];
      First = False;
      End = False;
      Counter = 1;
      if (Close[i]>Open[i])
      {
         Trend = True ;
         End_Up = False;
         End_Down = True;
         
      }
      else
      {
         Trend = False;
         End_Up = True;
         End_Down = False;
      }
      Line1 = Close[i];
      Line2 = Open[i];
      Line3 = Open[i];
      Line4 = Open[i];
      i--;




while(End==False)
{




//Down Trend-----------------------------------------------------------------------------

while(End_Down==false)
{
      if(Trend==False)
      {
         if(Line1>Close[i])
         {
               if(Trend_Back == False)
               {
                  Buffer2[i] = Line1;
                  Buffer1[i] = Close[i];
                  Line4=Line3;
                  Line3=Line2;
                  Line2=Line1;
                  Line1=Close[i];
                  Counter++;
                  i--;
                  if(i<1)
                  {
                     End = True;
                     End_Up = True;
                     End_Down = True;
                  }
               }
               if(Trend_Back == True)
               {
                  Buffer2[i] = Line2;
                  Buffer1[i] = Close[i];
                  Line4=Line1;
                  Line3=Line1;
                  Line2 = Line2;
                  Line1 = Close[i];
                  Trend_Back = False;
                  Counter++;
                  i--;
                  if(i<1)
                  {
                     End = True;
                     End_Up = True;
                     End_Down = True;
                  }
               }
         }
         else
         {
            if(Close[i]>Line4)
            {
               Trend = True;
               Trend_Back = True;
               if(i<1)
               {
                  End = True;
                  End_Up = True;
                  End_Down = True;
               }
            }
            else
            {
               i--;
               if(i<1)
               {
                  End = True;
                  End_Up = True;
                  End_Down = True;
               }
            }
         }
         //if(Open[i]==Close[i])
         //{
         //   i--;
         //   if(i<1)
         //   {
         //      End = True;
         //     End_Up = True;
         //      End_Down = True;
         //   }
         //}         
      }

   if(Trend_Back == True)
   {
      End_Down = True;
      End_Up = False;
      Counter = 0;      
   }
}
//--------------------------------------------------------------------------------------





//Up Trend------------------------------------------------------------------------------
while(End_Up==false)
{
      if(Trend==True)
      {
         if(Line1<Close[i])
         {
               if(Trend_Back == False)
               {
                  Buffer2[i] = Line1;
                  Buffer1[i] = Close[i];
                  Line4=Line3;
                  Line3=Line2;
                  Line2=Line1;
                  Line1=Close[i];
                  Counter++;
                  i--;
                  if(i<1)
                  {
                     End = True;
                     End_Up = True;
                     End_Down = True;
                  }
               }
               if(Trend_Back == True)
               {
                  Buffer2[i] = Line2;
                  Buffer1[i] = Close[i];
                  Line4=Line1;
                  Line3=Line1;
                  Line2 = Line2;
                  Line1 = Close[i];
                  Trend_Back = False;
                  Counter++;
                  i--;
                  if(i<1)
                  {
                     End = True;
                     End_Up = True;
                     End_Down = True;
                  }
               }
         }
         else
         {
            if(Close[i]<Line4)
            {
               Trend = False;
               Trend_Back = True;
               if(i<1)
               {
                  End = True;
                  End_Up = True;
                  End_Down = True;
               }
            }
            else
            {
               i--;
               if(i<1)
               {
                  End = True;
                  End_Up = True;
                  End_Down = True;
               }
            }
         }
         //if(Open[i]==Close[i])
         //{
         //   i--;
         //   if(i<1)
         //  {
         //      End = True;
         //      End_Up = True;
         //      End_Down = True;
         //   }
         //}         
      }
   if(Trend_Back == True)
   {
      End_Up = True;
      End_Down = False;
      Counter = 0;
   }

}
//--------------------------------------------------------------------------------------




switch (Counter)
{
case 1 : 
   Comment("Block Number < " + Counter + " >   -----   " + m + " minutes " + s + " Seconds Left To Bar End   -----   " + "Suggestion <<<||Wait... For The Next Candle To Confirm||>>>");
   return(0);
   break;
case 2 : 
   Comment("Block Number < " + Counter + " >   -----   " + m + " minutes " + s + " Seconds Left To Bar End   -----   " + "Suggestion <<<||Open... New Position||>>>");
   return(0);
   break;   
case 3 : 
   Comment("Block Number < " + Counter + " >   -----   " + m + " minutes " + s + " Seconds Left To Bar End   -----   " + "Suggestion <<<||Close... The Old Position||>>>");
   return(0);
   break;   
case 4 :
   Comment("Block Number < " + Counter + " >   -----   " + m + " minutes " + s + " Seconds Left To Bar End   -----   " + "Suggestion <<<||Open... New Position||>>>");
   return(0);
   break;   
case 5 : 
   Comment("Block Number < " + Counter + " >   -----   " + m + " minutes " + s + " Seconds Left To Bar End   -----   " + "Suggestion <<<||Close... The Old Position||>>>");
   return(0);
   break;
case 6 : 
   Comment("Block Number < " + Counter + " >   -----   " + m + " minutes " + s + " Seconds Left To Bar End   -----   " + "Suggestion <<<||Open... New Position||>>>");
   return(0);
   break;   
case 7 : 
   Comment("Block Number < " + Counter + " >   -----   " + m + " minutes " + s + " Seconds Left To Bar End   -----   " + "Suggestion <<<||Keep... Your Position||>>>");
   return(0);
   break; 
case 8 : 
   Comment("Block Number < " + Counter + " >   -----   " + m + " minutes " + s + " Seconds Left To Bar End   -----   " + "Suggestion <<<||Close... The Old Position||>>>");
   return(0);
   break;    
case 9 : 
   Comment("Block Number < " + Counter + " >   -----   " + m + " minutes " + s + " Seconds Left To Bar End   -----   " + "Suggestion <<<||Open... New Position||>>>");
   return(0);
   break; 
case 10 : 
   Comment("Block Number < " + Counter + " >   -----   " + m + " minutes " + s + " Seconds Left To Bar End   -----   " + "Suggestion <<<||Keep... Your Position||>>>");
   return(0);
   break;    
case 11 : 
   Comment("Block Number < " + Counter + " >   -----   " + m + " minutes " + s + " Seconds Left To Bar End   -----   " + "Suggestion <<<||Keep... Your Position||>>>");
   return(0);
   break;    
case 12 : 
   Comment("Block Number < " + Counter + " >   -----   " + m + " minutes " + s + " Seconds Left To Bar End   -----   " + "Suggestion <<<||Keep... Your Position||>>>");
   return(0);
   break;    
case 13 : 
   Comment("Block Number < " + Counter + " >   -----   " + m + " minutes " + s + " Seconds Left To Bar End   -----   " + "Suggestion <<<||Close... The Old Position||>>>");
   return(0);
   break;   
case 14 : 
   Comment("Block Number < " + Counter + " >   -----   " + m + " minutes " + s + " Seconds Left To Bar End   -----   " + "Suggestion <<<||Wait... No Suggestion||>>>");
   return(0);
   break;       
case 15 : 
   Comment("Block Number < " + Counter + " >   -----   " + m + " minutes " + s + " Seconds Left To Bar End   -----   " + "Suggestion <<<||Wait... No Suggestion||>>>");
   return(0);
   break;      
case 16 : 
   Comment("Block Number < " + Counter + " >   -----   " + m + " minutes " + s + " Seconds Left To Bar End   -----   " + "Suggestion <<<||Wait... No Suggestion||>>>");
   return(0);
   break;      
case 17 : 
   Comment("Block Number < " + Counter + " >   -----   " + m + " minutes " + s + " Seconds Left To Bar End   -----   " + "Suggestion <<<||Wait... No Suggestion||>>>");
   return(0);
   break;      
case 18 : 
   Comment("Block Number < " + Counter + " >   -----   " + m + " minutes " + s + " Seconds Left To Bar End   -----   " + "Suggestion <<<||Wait... No Suggestion||>>>");
   return(0);
   break;      
case 19 : 
   Comment("Block Number < " + Counter + " >   -----   " + m + " minutes " + s + " Seconds Left To Bar End   -----   " + "Suggestion <<<||Wait... No Suggestion||>>>");
   return(0);
   break;      
case 20 : 
   Comment("Block Number < " + Counter + " >   -----   " + m + " minutes " + s + " Seconds Left To Bar End   -----   " + "Suggestion <<<||Wait... No Suggestion||>>>");
   return(0);
   break;      
case 21 : 
   Comment("Block Number < " + Counter + " >   -----   " + m + " minutes " + s + " Seconds Left To Bar End   -----   " + "Suggestion <<<||Wait... No Suggestion||>>>");
   return(0);
   break;         
case 22 : 
   Comment("Block Number < " + Counter + " >   -----   " + m + " minutes " + s + " Seconds Left To Bar End   -----   " + "Suggestion <<<||Wait... No Suggestion||>>>");
   return(0);
   break;     
case 23 : 
   Comment("Block Number < " + Counter + " >   -----   " + m + " minutes " + s + " Seconds Left To Bar End   -----   " + "Suggestion <<<||Wait... No Suggestion||>>>");
   return(0);
   break;        
case 24 : 
   Comment("Block Number < " + Counter + " >   -----   " + m + " minutes " + s + " Seconds Left To Bar End   -----   " + "Suggestion <<<||Wait... No Suggestion||>>>");
   return(0);
   break;        
case 25 : 
   Comment("Block Number < " + Counter + " >   -----   " + m + " minutes " + s + " Seconds Left To Bar End   -----   " + "Suggestion <<<||Wait... No Suggestion||>>>");
   return(0);
   break;  
case 26 : 
   Comment("Block Number < " + Counter + " >   -----   " + m + " minutes " + s + " Seconds Left To Bar End   -----   " + "Suggestion <<<||Wait... No Suggestion||>>>");
   return(0);
   break;        
case 27 : 
   Comment("Block Number < " + Counter + " >   -----   " + m + " minutes " + s + " Seconds Left To Bar End   -----   " + "Suggestion <<<||Wait... No Suggestion||>>>");
   return(0);
   break;        
case 28 : 
   Comment("Block Number < " + Counter + " >   -----   " + m + " minutes " + s + " Seconds Left To Bar End   -----   " + "Suggestion <<<||Wait... No Suggestion||>>>");
   return(0);
   break;        
case 29 : 
   Comment("Block Number < " + Counter + " >   -----   " + m + " minutes " + s + " Seconds Left To Bar End   -----   " + "Suggestion <<<||Wait... No Suggestion||>>>");
   return(0);
   break;        
case 30 : 
   Comment("Block Number < " + Counter + " >   -----   " + m + " minutes " + s + " Seconds Left To Bar End   -----   " + "Suggestion <<<||Wait... No Suggestion||>>>");
   return(0);
   break;        
case 31 : 
   Comment("Block Number < " + Counter + " >   -----   " + m + " minutes " + s + " Seconds Left To Bar End   -----   " + "Suggestion <<<||Wait... No Suggestion||>>>");
   return(0);
   break;              
case 32 : 
   Comment("Block Number < " + Counter + " >   -----   " + m + " minutes " + s + " Seconds Left To Bar End   -----   " + "Suggestion <<<||Wait... No Suggestion||>>>");
   return(0);
   break;        
case 33 : 
   Comment("Block Number < " + Counter + " >   -----   " + m + " minutes " + s + " Seconds Left To Bar End   -----   " + "Suggestion <<<||Wait... No Suggestion||>>>");
   return(0);
   break;        
case 34 : 
   Comment("Block Number < " + Counter + " >   -----   " + m + " minutes " + s + " Seconds Left To Bar End   -----   " + "Suggestion <<<||Wait... No Suggestion||>>>");
   return(0);
   break;        
case 35 : 
   Comment("Block Number < " + Counter + " >   -----   " + m + " minutes " + s + " Seconds Left To Bar End   -----   " + "Suggestion <<<||Wait... No Suggestion||>>>");
   return(0);
   break;        
      
   
   
}





}
}
//+------------------------------------------------------------------+

Comments