Percent_Levels

Download script
Author: Aleksandr Pak, Almaty
Percent_Levels

This tool is designed to help traders visualize potential price targets and support zones based on specific percentage calculations relative to a chosen starting point. Rather than relying on standard lagging indicators, it uses a mathematical approach to project "levels" of interest on your chart.

How the Logic Works

1. The Reference Point The script identifies a primary anchor point on your chart—specifically, the closing price of a candle marked by a vertical line (the "StartML" line). This serves as the base value from which all other calculations originate.

2. Level Generation Once the starting price is established, the tool automatically generates a series of horizontal price levels above and below that point. The number of levels displayed is governed by the "Control Level" setting (defaulting to 6 levels per side).

3. Percentage-Based Projections Each level is determined by specific percentage values defined in the settings. For example, it takes the base price and calculates a distance based on the percentages provided (such as 0.4%, 0.6%, etc.). It then draws a line at that exact mathematical distance both above and below your starting point.

4. Visual Representation

  • Upper Levels: These are typically displayed in a distinct color (defaulting to Lime) to represent potential upward targets or resistance zones.
  • Lower Levels: These are displayed in a different color (defaulting to Blue) to represent potential downward targets or support zones.
  • Dynamic Extension: You can choose whether these levels appear as short segments or as infinite "rays" that extend across the chart, allowing you to see future price targets more clearly.

Summary for the User

In simple terms, this script acts as a mathematical map. You place a vertical line where you want your analysis to begin, and the tool instantly draws a symmetrical web of target prices based on fixed percentages. It helps remove guesswork by providing clear, consistent visual markers for where price might move next according to your specific percentage preferences.

11 Views
0 Downloads
0 Favorites
Percent_Levels
//+------------------------------------------------------------------+
//|                                                Malish6Levels.mq4 |
//|                                            Aleksandr Pak, Almaty |
//|                                                   ekr-ap@mail.ru |
//+------------------------------------------------------------------+
#property copyright "Aleksandr Pak, Almaty"
#property link      "ekr-ap@mail.ru"
//#property show_inputs

extern int control_level=6; //not great value = 6
extern bool ray=False;
extern color col_up=Lime;
extern color col_down=Blue;
extern double percent_lev1=0.4;
extern double percent_lev2=0.6;
extern double percent_lev3=0.8;
extern double percent_lev4=1;
extern double percent_lev5=1.2;
extern double percent_lev6=1.4;

int contr_level;
double lev[10];
int init()
  {         
      contr_level=2*control_level+1;
      if(control_level>7) {control_level=7; contr_level=13;}
           for(int i=1;i<contr_level;i++) 
            {  
               ObjectCreate(StringConcatenate
               ("ML",DoubleToStr(i,0)),OBJ_TREND,0,Time[10],Close[1],Time[1],Close[1]);
            }     
      lev[1]=percent_lev1/100.;
      lev[2]=percent_lev2/100.;
      lev[3]=percent_lev3/100.;
      lev[4]=percent_lev4/100.;
      lev[5]=percent_lev5/100.;
      lev[6]=percent_lev6/100.;
      if(ObjectFind("StartML")<0) ObjectCreate("StartML",OBJ_VLINE,0,Time[10],0);     
   return(0);
  }

int start()
  { 
   double   ts=ObjectGet("StartML",OBJPROP_TIME1);
   double   t=ts-5*60*Period();
   double   t2=t+15*60*Period();
   int      b=iBarShift(NULL,0,ts ,FALSE);
   double   p= Close[b];   
   for (int i=1; i<control_level+1;i++)
   {        string n= StringConcatenate ("ML",DoubleToStr(i,0));               
            double pl=p+p*lev[i];
            ObjectSet(n,OBJPROP_RAY,ray);         
            ObjectSet(n,OBJPROP_COLOR,col_up);         
            ObjectSet(n,OBJPROP_TIME1,t);
            ObjectSet(n,OBJPROP_PRICE1,pl);
            ObjectSet(n,OBJPROP_TIME2,t2);
            ObjectSet(n,OBJPROP_PRICE2,pl);
            n= StringConcatenate ("ML",DoubleToStr(i+control_level,0));
            pl=p-p*lev[i];
             ObjectSet(n,OBJPROP_RAY,ray);    
            ObjectSet(n,OBJPROP_COLOR,col_down);
            ObjectSet(n,OBJPROP_TIME1,t);
            ObjectSet(n,OBJPROP_PRICE1,pl);
            ObjectSet(n,OBJPROP_TIME2,t2);
            ObjectSet(n,OBJPROP_PRICE2,pl);
    }  
    WindowRedraw();
   return(0);
  }

Comments