MurreyLevels-Dirigible

Author: certain
Price Data Components
Series array that contains the highest prices of each barSeries array that contains the lowest prices of each bar
0 Views
0 Downloads
0 Favorites
MurreyLevels-Dirigible
ÿþ//+------------------------------------------------------------------+

//|                                           MurreyLevels-Ideal.mq4 |

//|                                                          certain |

//|                                               certain@mail15.com |

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

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

//| Makes a colorful Murray levels, that can be dirigible            |

//| by the Ruler line.                                               |

//|                                                                  |

//| If isNeedAutomake=true, it makes first level complect on the     |

//| high/low of the initialBarsForExtremums interval - or on bars    |

//| that you can specify with firstBarNumber and secondBarNumber.    |

//|                                                                  |

//| You can make new complect by clicking on the label in the        |

//| right upper corner                                               |

//|                                                                  |

//| If you will made Ruler line by hand - you will need to change    |

//} timeframe to show levels. Number must be the same as label show. |

//|                                                                  |

//| If you want to hide some complect of levels on some timeframes,  |

//| you can check this timeframes at the Ruler line                  |

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



#property copyright "certain"

#property link      "certain@mail15.com"

#property version   "1.1"

#property strict

#property indicator_chart_window



#define VERSION 1.1

//--- input parameters

input string   Section_of_parameters_01_="---==== Common parameters ====--- ";

input bool     isNeedAutomake=true;

input bool     showOnParentTimeframes=false;

//---

input bool     showPrices=true;

input bool     showLevelsLabels=false;

//---

input int      initialBarsForExtremums=50;

input int      timeCoefficient=5;

input string   prefix="MM-dirigible-";

//---

input string   Section_of_parameters_02_="---==== Initial points numbers ====--- ";

input int      firstBarNumber=0;

input int      secondBarNumber=0;

//---

input string   Section_of_parameters_03_="---==== Colors set ====--- ";

input color    rulerColor=clrRed;

input color    levelsColor_08=clrRed;

input color    levelsColor_4=clrRed;

input color    levelsColor_26=clrLightGreen;

input color    levelsColor_17=clrGreen;

input color    levelsColor_35=clrYellow;

input color    upTextColor=clrGray;

//---

input string   Section_of_parameters_04_="---==== Widths set ====--- ";

input int      rulerWidth=1;

input int      levelsWidth_08=2;

input int      levelsWidth_4=1;

input int      levelsWidth_26=1;

input int      levelsWidth_17=1;

input int      levelsWidth_35=1;

//---

input string   Section_of_parameters_05_="---==== Styles set ====--- ";

input int      rulerStyle=2;

input int      levelsStyle_08=0;

input int      levelsStyle_4=0;

input int      levelsStyle_26=2;

input int      levelsStyle_17=2;

input int      levelsStyle_35=2;



//---

input string            Section_of_parameters_06_="---==== Label cordinates ====--- ";

input int               labelX=200;

input int               labelY=10;

input ENUM_BASE_CORNER  corner=CORNER_RIGHT_UPPER;



//--- global variables

int      complectNumber=0;

string   complectSuffix="Complect#";

string   allComplectsName[];



string   rulerLineShortName="Ruler Line";

string   levelShortName="Level";



int      firstPointBarNumber=0;

int      secondPointBarNumber=0;

double   firstPointPrice,secondPointPrice;

datetime firstPointTime,secondPointTime;



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

//| Custom indicator initialization function                         |

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

int OnInit()

  {

   string   objectName="";

//int      i;

   int      maximumBarNumber=0;

   int      minimumBarNumber=0;



//--- indicator buffers mapping

//--- Data initialization

   ChartSetInteger(0,CHART_EVENT_OBJECT_DELETE,true);



   objectName=GetFullObjectName(rulerLineShortName,complectNumber);

   if(ObjectFind(0,objectName)!=-1)

     {

      CollectAllComplects();

     }

   else

     {

      if(isNeedAutomake)

        {

         MakeRuler();

        }

     }

//DelCurrentLineLevels(objectName);

   DrawMMLevels(objectName);

   SetNextRulerLabel();

   ChartRedraw();

//---

   return(INIT_SUCCEEDED);

  }

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

//|                                                                  |

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

void CollectAllComplects()

  {

//---

   string   objectName="";

   int      i;

//---

   objectName=GetFullObjectName(rulerLineShortName,complectNumber);

   for(i=0; ObjectFind(0,objectName)!=-1; i++)

     {

      complectNumber = i+1;

      ArrayResize(allComplectsName,complectNumber);

      allComplectsName[i]=objectName;

      DelCurrentLineLevels(objectName);

      DrawMMLevels(objectName);

      objectName=GetFullObjectName(rulerLineShortName,complectNumber);

     }

   SetNextRulerLabel();

  }

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

//|                                                                  |

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

void OnDeinit(const int reason)

  {

   ObjectDelete(0,"MM-next-Ruler");

  }

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

//| Custom indicator iteration function                              |

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

int OnCalculate(const int rates_total,

                const int prev_calculated,

                const datetime &time[],

                const double &open[],

                const double &high[],

                const double &low[],

                const double &close[],

                const long &tick_volume[],

                const long &volume[],

                const int &spread[])

  {



//---



//--- return value of prev_calculated for next call

   return(rates_total);

  }

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

//| ChartEvent function                                              |

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

void OnChartEvent(const int id,

                  const long &lparam,

                  const double &dparam,

                  const string &sparam)

  {

   string pref = "";

   int elementNumber;

   string elementNameSuffix = StringSubstr(

                                 sparam,

                                 StringFind(sparam,"-",StringLen(prefix+complectSuffix))+1

                              );

   string elementNamePrefix = StringSubstr(sparam,0,StringLen(prefix));



//---

   switch(id)

     {

      case CHARTEVENT_OBJECT_DRAG:

        {

         if(elementNamePrefix == prefix && elementNameSuffix == rulerLineShortName)

           {

            DelCurrentLineLevels(sparam);

            DrawMMLevels(sparam);

           }

         break;

        }

      case CHARTEVENT_OBJECT_DELETE:

        {

         if(elementNamePrefix == prefix && elementNameSuffix == rulerLineShortName)

           {

            elementNumber = DelCurrentLineLevels(sparam);

            allComplectsName[elementNumber]="";

           }

         break;

        }

      case CHARTEVENT_OBJECT_CLICK:

        {

         if(sparam == "MM-next-Ruler")

           {

            MakeRuler();

            DrawMMLevels(

               GetFullObjectName(rulerLineShortName,

                                 complectNumber-1

                                )

            );

            //SetNextRulerLabel();

           }

         break;

        }

     }

   CollectAllComplects();

   SetNextRulerLabel();

   ChartRedraw();

  }

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

//| Draw any trendline on the chart                                  |

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

void DrawLine(string      objectName,

              datetime    _firstPointTime,

              double      _firstPointPrice,

              datetime    _secondPointTime,

              double      _secondPointPrice,

              color       lineColor,

              int         lineStyle=2,

              int         lineWidth=1,

              bool        isRay=false

             )

  {

//---

   ObjectCreate(0,objectName,OBJ_TREND,0,

                _firstPointTime, _firstPointPrice,

                _secondPointTime,_secondPointPrice);

   ObjectSetInteger(0,objectName,OBJPROP_COLOR,lineColor);

   ObjectSetInteger(0,objectName,OBJPROP_WIDTH,lineWidth);

   ObjectSetInteger(0,objectName,OBJPROP_STYLE,lineStyle);

   ObjectSetInteger(0,objectName,OBJPROP_RAY,isRay);



  }

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

//| Draw all Murray Levels                                           |

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

void DrawMMLevels(string rulerFullName)

  {

   string   levelFullName;

   string   currentLevelName;

   string   currentLabelName;

   string   levelTooltip;



   double   trendVolatility;

   double   levelAmount;

   int      lineLength;

   int      i;



   color    currentColor;

   int      currentWidth;

   int      currentStyle;

   double   currentPrice;

   long     currentTimeframes;



   datetime secondLevelTime;

//int      secondDayOfWeek;

//---

   if(ObjectFind(0,rulerFullName)!=-1)

     {

      //--- Initiations

      CalculateStartingPoints(rulerFullName);

      trendVolatility = NormalizeDouble((firstPointPrice-secondPointPrice),Digits());

      levelAmount = NormalizeDouble((trendVolatility/8),Digits());

      lineLength = MathAbs(firstPointBarNumber-secondPointBarNumber)*timeCoefficient;

      secondLevelTime = GetTimeWithShift(firstPointTime, lineLength);

      currentTimeframes = ObjectGetInteger(0,rulerFullName,OBJPROP_TIMEFRAMES);



      //--- Drawing

      for(i=-2; i<11; i++)

        {

         currentLevelName = levelShortName + " "+IntegerToString(i);

         levelFullName = GetFullObjectName(currentLevelName,GetComplectNumber(rulerFullName));

         switch(i)

           {

            case 0:

            case 8:

              {

               currentColor = levelsColor_08;

               currentWidth = levelsWidth_08;

               currentStyle = levelsStyle_08;

               break;

              }

            case 3:

            case 5:

              {

               currentColor = levelsColor_35;

               currentWidth = levelsWidth_35;

               currentStyle = levelsStyle_35;

               break;

              }

            case 2:

            case 6:

              {

               currentColor = levelsColor_26;

               currentWidth = levelsWidth_26;

               currentStyle = levelsStyle_26;

               break;

              }

            case 4:

              {

               currentColor = levelsColor_4;

               currentWidth = levelsWidth_4;

               currentStyle = levelsStyle_4;

               break;

              }

            default:

              {

               currentColor = levelsColor_17;

               currentWidth = levelsWidth_17;

               currentStyle = levelsStyle_17;

              }

           }

         currentPrice = firstPointPrice-levelAmount*i;

         DrawLine(levelFullName,firstPointTime,currentPrice,

                  secondLevelTime,currentPrice,

                  currentColor,currentStyle,currentWidth);

         ObjectSetInteger(0,levelFullName,OBJPROP_TIMEFRAMES,currentTimeframes);

         levelTooltip = levelFullName+"\n"+(string)i+"/8" + " (" + GetTimeframeName(currentTimeframes) +")";

         if(showPrices)

           {

            levelTooltip += "\n"+DoubleToString(currentPrice,Digits());

            ObjectSetString(0,levelFullName,OBJPROP_TOOLTIP,levelTooltip);

            if(showLevelsLabels)

              {

               currentLabelName = GetFullObjectName(

                                     "Label"+IntegerToString(i),

                                     GetComplectNumber(rulerFullName)

                                  );

               ObjectCreate(0,currentLabelName,OBJ_ARROW_LEFT_PRICE,0,firstPointTime,currentPrice);

               ObjectSetInteger(0,currentLabelName,OBJPROP_TIMEFRAMES,currentTimeframes);

               ObjectSetInteger(0,currentLabelName,OBJPROP_COLOR,currentColor);

              }

           }

        }

     }

  }



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

//| Utility function - get full name from the short one.             |

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

string GetFullObjectName(string shortName,int complect)

  {

//---

   return(prefix +

          complectSuffix +

          IntegerToString(complect)+

          "-" + shortName

         );

  }

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

//| Utility function - get element number in array - or -1, if it    |

//| does not exists.                                                 |

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

int ArraySearch(const string& array[], string needle)

  {

   int elementNumber =-1;

   int i;

   int range = ArrayRange(array,0);

//---

   for(i=0; i<range; i++)

     {

      if(array[i]==needle)

        {

         elementNumber = i;

         break;

        }

     }

   return (elementNumber);

  }

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

//| Utility function - get complect number by element name.          |

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

int GetComplectNumber(string elementName,

                      string numberDelimiter="#",

                      string commonDeliniter="-")

  {

   string splits[];



//---

   StringSplit(elementName,

               StringGetCharacter(numberDelimiter,0),

               splits);

   return (

             (int)StringToInteger(

                StringSubstr(splits[1],0,

                             StringFind(splits[1],

                                        commonDeliniter)

                            )

             )

          );

  }

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

//| Utility function - delete levels by ruler line full name.        |

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

int DelCurrentLineLevels(string rulerName)

  {

   string pref, currentGroup;

   int nPos,dashPos;

//---

   pref = StringSubstr(

             rulerName,0,

             StringLen(rulerName)-StringLen(rulerLineShortName)

          );

   currentGroup = pref + levelShortName;

   ObjectsDeleteAll(0,currentGroup);

   currentGroup = pref + "Label";

   ObjectsDeleteAll(0,currentGroup);

   nPos = StringFind(rulerName,"#");

   dashPos = StringFind(rulerName,"-",nPos);

   return (int)StringToInteger( // Element number in array

             StringSubstr(rulerName,nPos+1,dashPos-nPos-1)

          );

  }



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

//| Utility function - calculates from which pont we start to draw   |

//| levels.                                                          |

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

void CalculateStartingPoints(string rulerFullName)

  {

   double   price1,price2;

   datetime time1,time2;

   int      bar1,bar2;

//---

   if(ObjectFind(0,rulerFullName)!=-1)

     {

      price1 = ObjectGetDouble(0,rulerFullName,OBJPROP_PRICE,0);

      time1 = ObjectGetTimeByValue(0,rulerFullName,price1);

      bar1 = iBarShift(Symbol(),PERIOD_CURRENT,time1);

      price2 = ObjectGetDouble(0,rulerFullName,OBJPROP_PRICE,1);

      time2 = ObjectGetTimeByValue(0,rulerFullName,price2);

      bar2 = iBarShift(Symbol(),PERIOD_CURRENT,time2);

      if(time1<time2)

        {

         firstPointTime = time1;

         firstPointBarNumber = bar1;

         secondPointTime = time2;

         secondPointBarNumber = bar2;

         firstPointPrice = price1;

         secondPointPrice = price2;

        }

      else

        {

         firstPointTime = time2;

         firstPointBarNumber = bar2;

         secondPointTime = time1;

         secondPointBarNumber = bar1;

         firstPointPrice = price2;

         secondPointPrice = price1;

        }

     }

   else

     {

      firstPointTime = iTime(Symbol(),PERIOD_CURRENT,1);

      firstPointBarNumber = 1;

      secondPointTime = iTime(Symbol(),PERIOD_CURRENT,1);

      secondPointBarNumber = 1;

      firstPointPrice = iHigh(Symbol(),PERIOD_CURRENT,1);

      secondPointPrice = iLow(Symbol(),PERIOD_CURRENT,0);

     }

  }

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

//| Makes ruler line                                                 |

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

void MakeRuler()

  {

   string   objectName="";

   int      i;

   int      maximumBarNumber=0;

   int      minimumBarNumber=0;

//---

   objectName=GetFullObjectName(rulerLineShortName,complectNumber);

   if(ObjectFind(0,objectName)!=-1 || !isNeedAutomake)

      return;



//---

   if(firstBarNumber==0 && secondBarNumber==0)

     {

      double l_High[],l_Low[];

      ArraySetAsSeries(l_High,true);

      ArraySetAsSeries(l_Low,true);

      CopyHigh(Symbol(),PERIOD_CURRENT,0,initialBarsForExtremums+1,l_High);

      CopyLow(Symbol(),PERIOD_CURRENT,0,initialBarsForExtremums+1,l_Low);

      maximumBarNumber=ArrayMaximum(l_High);

      minimumBarNumber=ArrayMinimum(l_Low);

      if(maximumBarNumber==0)

        {

         for(i=3; i<initialBarsForExtremums; i++)

           {

            if(l_High[i]>l_High[i+1] &&

               l_High[i]>l_High[i+2] &&

               l_High[i]>l_High[i-1] &&

               l_High[i]>l_High[i-2])

              {

               maximumBarNumber=i;

               break;

              }

           }

        }

      if(minimumBarNumber==0)

        {

         for(i=3; i<initialBarsForExtremums; i++)

           {

            if(l_Low[i]<l_Low[i+1] &&

               l_Low[i]<l_Low[i+2] &&

               l_Low[i]<l_Low[i-1] &&

               l_Low[i]<l_Low[i-2])

              {

               minimumBarNumber=i;

               break;

              }

           }

        }

      if(minimumBarNumber > maximumBarNumber)

        {

         firstPointBarNumber = minimumBarNumber;

         secondPointBarNumber = maximumBarNumber;

        }

      else

        {

         firstPointBarNumber = maximumBarNumber;

         secondPointBarNumber = minimumBarNumber;

        }

     }

   else

     {

      if(firstBarNumber > secondBarNumber)

        {

         firstPointBarNumber = firstBarNumber;

         secondPointBarNumber = secondBarNumber;

        }

      else

        {

         firstPointBarNumber = secondBarNumber;

         secondPointBarNumber = firstBarNumber;

        }

     }

//---

   if(iLow(Symbol(),PERIOD_CURRENT,firstPointBarNumber)<iLow(Symbol(),PERIOD_CURRENT,firstPointBarNumber-1) &&

      iHigh(Symbol(),PERIOD_CURRENT,firstPointBarNumber)<iHigh(Symbol(),PERIOD_CURRENT,secondPointBarNumber))

     {

      DrawLine(objectName,

               iTime(Symbol(),PERIOD_CURRENT,firstPointBarNumber),iLow(Symbol(),PERIOD_CURRENT,firstPointBarNumber),

               iTime(Symbol(),PERIOD_CURRENT,secondPointBarNumber),iHigh(Symbol(),PERIOD_CURRENT,secondPointBarNumber),

               rulerColor, rulerStyle, rulerWidth);

     }

   else

     {

      DrawLine(objectName,

               iTime(Symbol(),PERIOD_CURRENT,firstPointBarNumber),iHigh(Symbol(),PERIOD_CURRENT,firstPointBarNumber),

               iTime(Symbol(),PERIOD_CURRENT,secondPointBarNumber),iLow(Symbol(),PERIOD_CURRENT,secondPointBarNumber),

               rulerColor, rulerStyle, rulerWidth);

     }

   ObjectSetInteger(0,objectName, OBJPROP_SELECTABLE, true);

   ObjectSetInteger(0,objectName, OBJPROP_SELECTED, true);

//---

   if(!showOnParentTimeframes)

     {

      ObjectSetInteger(0,objectName,OBJPROP_TIMEFRAMES,

                       GetCurrentTimeframes()

                      );

     }

//---

   ArrayResize(allComplectsName,complectNumber+1);

   allComplectsName[complectNumber]=objectName;

   complectNumber++;

   SetNextRulerLabel();

//TODO: Make file to save complects with different numbers (not continuose).

  }

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

//| Crearte label with next ruler number                             |

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

void SetNextRulerLabel()

  {

   string labelName = "MM-next-Ruler";

//---

   ENUM_ANCHOR_POINT anchor = ANCHOR_RIGHT_UPPER;

   switch(corner)

     {

      case CORNER_LEFT_UPPER:

         anchor = ANCHOR_LEFT_UPPER;

         break;

      case CORNER_LEFT_LOWER:

         anchor = ANCHOR_LEFT_LOWER;

         break;

      case CORNER_RIGHT_LOWER:

         anchor = ANCHOR_RIGHT_LOWER;

         break;

      case CORNER_RIGHT_UPPER:

         anchor = ANCHOR_RIGHT_UPPER;

         break;

     }

//---

   if(ObjectFind(0,labelName)==-1)

     {

      ObjectCreate(0,labelName,OBJ_LABEL,0,0,

                   ChartGetDouble(0,CHART_PRICE_MAX)

                  );

      ObjectSetInteger(0,labelName,OBJPROP_YDISTANCE,labelY);

      ObjectSetInteger(0,labelName,OBJPROP_XDISTANCE,labelX);

      ObjectSetInteger(0,labelName,OBJPROP_ANCHOR,anchor);

      ObjectSetInteger(0,labelName,OBJPROP_CORNER,corner);

      ObjectSetInteger(0,labelName,OBJPROP_COLOR,upTextColor);

     }



   ObjectSetString(0,"MM-next-Ruler",OBJPROP_TEXT,"Next MM Ruler number is " +

                   IntegerToString(complectNumber)

                  );

   ChartRedraw(0);

  }

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

//| Get timeframes set for current period                            |

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

long GetCurrentTimeframes()

  {

   long currentTimeframes;



   switch(Period())

     {

      case PERIOD_M1:

        {

         currentTimeframes = OBJ_PERIOD_M1;

         break;

        }

      case PERIOD_M5:

        {

         currentTimeframes = OBJ_PERIOD_M1|OBJ_PERIOD_M5;

         break;

        }

      case PERIOD_M15:

        {

         currentTimeframes = OBJ_PERIOD_M1|OBJ_PERIOD_M5|OBJ_PERIOD_M15;

         break;

        }

      case PERIOD_M30:

        {

         currentTimeframes = OBJ_PERIOD_M1|OBJ_PERIOD_M5|OBJ_PERIOD_M15|

                             OBJ_PERIOD_M30;

         break;

        }

      case PERIOD_H1:

        {

         currentTimeframes = OBJ_PERIOD_M1|OBJ_PERIOD_M5|OBJ_PERIOD_M15|

                             OBJ_PERIOD_M30|OBJ_PERIOD_H1;

         break;

        }

      case PERIOD_H4:

        {

         currentTimeframes = OBJ_PERIOD_M1|OBJ_PERIOD_M5|OBJ_PERIOD_M15|

                             OBJ_PERIOD_M30|OBJ_PERIOD_H1|OBJ_PERIOD_H4;

         break;

        }

      case PERIOD_D1:

        {

         currentTimeframes = OBJ_PERIOD_M1|OBJ_PERIOD_M5|OBJ_PERIOD_M15|

                             OBJ_PERIOD_M30|OBJ_PERIOD_H1|OBJ_PERIOD_H4|OBJ_PERIOD_D1;

         break;

        }

      case PERIOD_W1:

        {

         currentTimeframes = OBJ_PERIOD_M1|OBJ_PERIOD_M5|OBJ_PERIOD_M15|

                             OBJ_PERIOD_M30|OBJ_PERIOD_H1|OBJ_PERIOD_H4|OBJ_PERIOD_D1|

                             OBJ_PERIOD_W1;

         break;

        }

      default:

        {

         currentTimeframes = OBJ_ALL_PERIODS;

        }

     }

//---

   return (currentTimeframes);

  }



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

//| Get name of current time frame                                   |

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

string GetTimeframeName(long minutesInFrame)

  {

   string timeFrameName = "";

//---



   switch(minutesInFrame)

     {

      case OBJ_PERIOD_M1:

         timeFrameName = "1m";

         break;

      case OBJ_PERIOD_M1|OBJ_PERIOD_M5:

         timeFrameName = "5m";

         break;

      case OBJ_PERIOD_M1|OBJ_PERIOD_M5|OBJ_PERIOD_M15:

         timeFrameName = "15m";

         break;

      case OBJ_PERIOD_M1|OBJ_PERIOD_M5|OBJ_PERIOD_M15|OBJ_PERIOD_M30:

         timeFrameName = "30m";

         break;

      case OBJ_PERIOD_M1|OBJ_PERIOD_M5|OBJ_PERIOD_M15|OBJ_PERIOD_M30|OBJ_PERIOD_H1:

         timeFrameName = "1h";

         break;

      case OBJ_PERIOD_M1|OBJ_PERIOD_M5|OBJ_PERIOD_M15|OBJ_PERIOD_M30|OBJ_PERIOD_H1|OBJ_PERIOD_H4:

         timeFrameName = "4h";

         break;

      case OBJ_PERIOD_M1|OBJ_PERIOD_M5|OBJ_PERIOD_M15|OBJ_PERIOD_M30|OBJ_PERIOD_H1|OBJ_PERIOD_H4|OBJ_PERIOD_D1:

         timeFrameName = "1D";

         break;

      case OBJ_PERIOD_M1|OBJ_PERIOD_M5|OBJ_PERIOD_M15|OBJ_PERIOD_M30|OBJ_PERIOD_H1|OBJ_PERIOD_H4|OBJ_PERIOD_D1|OBJ_PERIOD_W1:

         timeFrameName = "1W";

         break;

      case OBJ_ALL_PERIODS:

         timeFrameName = "1Mn";

     }

//---

   return (timeFrameName);

  }

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

//| Function return right point of chart if end point of figure is   |

//| on Saturday or Sunday                                            |

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

datetime GetTimeWithShift(datetime shiftedTime,int lineLength)

  {

   datetime farTime = shiftedTime;

   double price = iHigh(Symbol(),PERIOD_CURRENT,iBarShift(Symbol(),PERIOD_CURRENT,shiftedTime));

   int x,y,farX,subwindow=0;

//---



   ChartTimePriceToXY(0,0,shiftedTime,price,x,y);

   farX = x+(int)(lineLength*MathPow(2,ChartGetInteger(0,CHART_SCALE)));

   if(farX <= ChartGetInteger(0,CHART_WIDTH_IN_PIXELS))

     {

      ChartXYToTimePrice(0,farX,y,subwindow,farTime,price);

     }

   else

     {

      farTime = shiftedTime + lineLength*PeriodSeconds();

     }

//---

   return (farTime);

  }

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



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

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