FibProgression

Download script
FibProgression

This tool is designed to automatically generate a series of horizontal reference lines on your trading chart based on a mathematical progression. It serves as a visual aid for traders who need to identify specific price levels derived from an initial high or low point.

How the Logic Works

1. User Customization The script allows you to define the starting point of your analysis by selecting a specific high or low price. You can also customize the visual appearance, such as the number of lines displayed, their thickness, and their color. Furthermore, you can choose whether the progression should move upward from your starting point or downward.

2. Dynamic Line Generation Instead of placing simple static levels, this script uses a mathematical sequence to determine where each line appears. It calculates these positions by adding increasing values to your chosen price point. These increments are tied together in a "progressive" manner—meaning each new line's distance from the previous one grows according to a specific internal calculation.

3. Automatic Placement Once the script is activated, it automatically calculates and draws all requested lines simultaneously. It handles the complex math behind the spacing so that you don't have to manually calculate where each level should be placed. The lines are drawn as solid horizontal markers, providing a clear "map" of price levels across your chart.

4. Clean Management The script is designed to be efficient and organized. It includes a built-in management system that ensures it only draws the specific number of lines you requested. When you remove the indicator from your chart, it automatically cleans up and deletes those lines, leaving your workspace tidy.

Summary for the Trader

Think of this as an automated "level mapper." You give it a starting price, and it instantly plots out a series of escalating zones. It is intended for traders who prefer to visualize price movements based on structured, expanding intervals rather than standard fixed percentages.

8 Views
0 Downloads
0 Favorites
FibProgression
//+------------------------------------------------------------------+
//|                                               FibProgression.mq4
//+------------------------------------------------------------------+
#property indicator_chart_window

extern double highLow           = 0.0;
extern int    fibProgLines      = 6;
extern bool   progressionUpward = FALSE;
extern color  color1            = Yellow;
extern int    lineThickness     = 1;
//----
int  fibProgressStart = 0;
bool onceThrough      = FALSE;
//+------------------------------------------------------------------+
//| Custom indicator initialization function
//+------------------------------------------------------------------+
int init()
{
   int i, startIndx = 0;
//----
   if((lineThickness < 1) || (lineThickness > 5 ))
      lineThickness = 1;
   if((fibProgLines < 2) || (fibProgLines > 20))
      fibProgLines = 6;
   while(TRUE)
   {
      for(fibProgressStart = startIndx; ; fibProgressStart++)
         if(ObjectFind("Prog" + fibProgressStart) == -1)
            break;
      for(i = fibProgressStart; i < (fibProgressStart + fibProgLines); i++)
         if(ObjectFind("Prog" + i) == 0)
            break;
      if(i == (fibProgressStart + fibProgLines))
         break;
      else
         startIndx += (fibProgressStart + fibProgLines);
   }
//----
   return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function
//+------------------------------------------------------------------+
int deinit()
{
   int i;
//----
   for(i = fibProgressStart; i < (fibProgressStart + fibProgLines); i++)
      ObjectDelete("Prog" + i);
//----
   return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function
//+------------------------------------------------------------------+
int start()
{
   int i, prevAdder = 34, adder = 55;
   double tmp00, tmp01, tmp02;
//----
   if(!onceThrough)
      for(i = fibProgressStart; i < (fibProgressStart + fibProgLines); i++)
      {
         tmp00 = adder * Point;
         tmp01 = prevAdder * Point;
         if(progressionUpward)
            tmp02 = highLow + tmp00;
         else
            tmp02 = highLow - tmp00;
         ObjectCreate("Prog" + i, OBJ_HLINE, 0, Time[1], tmp02);
         ObjectSet("Prog" + i, OBJPROP_STYLE, STYLE_SOLID);
         ObjectSet("Prog" + i, OBJPROP_COLOR, color1);
         ObjectSet("Prog" + i, OBJPROP_WIDTH, lineThickness);
         adder += prevAdder;
         prevAdder = adder - prevAdder;
      }
   onceThrough = TRUE;
//----
   return(0);
}
//+------------------------------------------------------------------+

Comments