Author: Alexey Volchanskiy 2016
Price Data Components
0 Views
0 Downloads
0 Favorites
pricelines
ÿþ//+------------------------------------------------------------------+

//|                                         PriceLines.mq5 

//|                                         Alexey Volchanskiy 

//|                                         http://mql.gnomio.com

//|  

//+------------------------------------------------------------------+

#property copyright "Alexey Volchanskiy 2016"

#property link      "http://mql.gnomio.com"

#property version "2.15"

#property description "The script Price Lines marks price levels on the chart"

#property description "It helps to recognize the currency fluctuation in one touch"



#property script_show_inputs



input bool     DeleteLines = false;

input bool     AutoRange   = true;

input double   BeginPrice  = 1.0;

input double   EndPrice    = 1.7;

input int      Step        = 25;

input int      Step2       = 100;

input string   LineName    = "PrLn";

input color    LineColor1  = Yellow;

input color    LineColor2  = clrCornsilk;

input int      Width1      = 1;

input int      Width2      = 2;



double step,begin,end;

int step2;

//+------------------------------------------------------------------+

//|                                                                  |

//+------------------------------------------------------------------+

int OnStart()

  {

   begin=BeginPrice;

   end=EndPrice;

   step2=Step2;

   CalculateRange();

   DeleteHLines();

   if(!DeleteLines)

      DrawHLines(begin,end);

   else

      DeleteHLines();

   return(0);

  }

//+------------------------------------------------------------------+

//|                                                                  |

//+------------------------------------------------------------------+

void DrawHLines(double pBegin,double pEnd)

  {

   int lnum=0;

   color clr;

   int width,BeginInt;

   while(pBegin<pEnd)

     {

      BeginInt=(int)MathRound(pBegin*MathPow(10,Digits()));

      if(BeginInt%step2==0)

        {

         clr=LineColor2;

         width=Width2;

        }

      else

        {

         clr=LineColor1;

         width=Width1;

        }

      string name=LineName+IntegerToString(lnum);

      bool res=ObjectCreate(0,name,OBJ_HLINE,0,0,pBegin);

      ObjectSetInteger(0,name,OBJPROP_COLOR,clr);

      ObjectSetInteger(0,name,OBJPROP_STYLE,STYLE_DASH);

      ObjectSetInteger(0,name,OBJPROP_WIDTH,width);

      pBegin+=step;

      lnum++;

     }

  }

//+------------------------------------------------------------------+

//|                                                                  |

//+------------------------------------------------------------------+

void DeleteHLines()

  {

   int nL=ObjectsTotal(0,0,OBJ_HLINE);

   string name;

   for(int n=nL-1; n>=0; n--) // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! B>;L:> ?> C1K20=8N

     {

      name=ObjectName(0,n,0,OBJ_HLINE);

      if(ObjectGetInteger(0,name,OBJPROP_TYPE)!=OBJ_HLINE)

         continue;

      int nch= StringFind(name,LineName);

      if(nch == 0)

         ObjectDelete(0,name);

     }

  }

//+------------------------------------------------------------------+

//|                                                                  |

//+------------------------------------------------------------------+

void CalculateRange()

  {

   int k1=1;   // :>MDD8F85=B B>G=>AB8, 4;O 4-E7=0:>2KE & = 1, 4;O 5-B87=0:0 = 10

   int RoundBegin=_Digits-2;

   if(_Digits==5)

     {

      k1=10;

      RoundBegin-=1;

     }

   step=Step/MathPow(10,_Digits)*k1;

   step2*=k1;

   if(!AutoRange) return;

   double min = ChartGetDouble(0,CHART_PRICE_MIN);

   double max = ChartGetDouble(0,CHART_PRICE_MAX);

   double range=(max-min)*3;

   max += range;

   min -= range;

   begin= StringToDouble(DoubleToString(min,RoundBegin));

   end=max;

   return;

  }

//+------------------------------------------------------------------+

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 ---