Trendline 30M,2HR,8HR,Daily and Weekly Time intervals

MQL4 Indicators

Specification

I need someone to add on some more time intervals to the Trendlines indicator. Currently its for the 5M,15M,1HR,4HR.

I need the 30M,2HR,8HR,Daily and Weekly added. Now i know on MT4 you don't actually have the 2HR and 8HR time interval but i have a time converter indicator. Nonethless thats the code below and i simply again just need the 30Min,2HR,8HR,Daily and Weekly added. Thanks a bunch.



//+------------------------------------------------------------------+
//|                                                   Trendlines.mq4 |
//|                                      Copyright © 2006, John Hitt |
//|                                           jhitt@kanji.dyndns.org |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, John Hitt"
#property link      "jhitt@kanji.dyndns.org"

#property indicator_chart_window

extern color H4_R=RoyalBlue;
extern color H4_S=FireBrick;
extern color H1_R=RoyalBlue;
extern color H1_S=FireBrick;
extern color M15_R=RoyalBlue;
extern color M15_S=FireBrick;

#define RESISTANCE 1
#define SUPPORT 2

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   ObjectDelete("H4_R");
   ObjectDelete("H4_S");
   ObjectDelete("H1_R");
   ObjectDelete("H1_S");
   ObjectDelete("M15_R");
   ObjectDelete("M15_S");
   ObjectDelete("M5_R");
   ObjectDelete("M5_S");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   datetime currentbar = 0;
  
   if (currentbar != Time[0])
   {
      switch (Period())
      {
         case PERIOD_H4:
            Draw_H4_Trends();
            break;
         case PERIOD_H1:
            Draw_H4_Trends();
            Draw_H1_Trends();
            break;
         case PERIOD_M15:
            Draw_H1_Trends();
            Draw_M15_Trends();
            break;
         case PERIOD_M5:
            Draw_M15_Trends();
            break;
       }
   }  

   return(0);
  }


void Draw_M15_Trends()
{
   int sbar=0;
   int ebar=0;
   int i;
   double rate_array[][6];
  
   ArrayCopyRates(rate_array, Symbol(), PERIOD_M15);
  
   for (i=2; i < Bars; i++)
   {
      if (HigherHigh(i, 1, rate_array) == true)
      {
        //Print("HiherHigh: ", i);
        if (ebar == 0)
          ebar = i;
        else if (sbar == 0 && rate_array[i][3] > rate_array[ebar][3]) // use 3 for high
          sbar = i;
      }
      if (sbar !=0 && ebar !=0)
         break;
   }
   DrawTrendline ("M15_R", ebar, sbar, PERIOD_M15, RESISTANCE, rate_array);
 
   ebar = 0;
   sbar = 0;
  
   for (i=2; i < Bars; i++)
   {
      if (LowerLow(i, 1, rate_array) == true)
      {
        if (ebar == 0)
          ebar = i;
        else if (sbar == 0 && rate_array[i][2] < rate_array[ebar][2]) // use 2 for low
          sbar = i;
      }
      if (sbar !=0 && ebar !=0)
         break;
   }
   DrawTrendline ("M15_S", ebar, sbar, PERIOD_M15, SUPPORT, rate_array);

}

void Draw_H1_Trends()
{
   int sbar=0;
   int ebar=0;
   int i;
   double rate_array[][6];
  
   ArrayCopyRates(rate_array, Symbol(), PERIOD_H1);
  
   for (i=2; i < Bars; i++)
   {
      if (HigherHigh(i, 1, rate_array) == true)
      {
        //Print("HiherHigh: ", i);
        if (ebar == 0)
          ebar = i;
        else if (sbar == 0 && rate_array[i][3] > rate_array[ebar][3]) // use 3 for high
          sbar = i;
      }
      if (sbar !=0 && ebar !=0)
         break;
   }
   DrawTrendline ("H1_R", ebar, sbar, PERIOD_H1, RESISTANCE, rate_array);
 
   ebar = 0;
   sbar = 0;
  
   for (i=2; i < Bars; i++)
   {
      if (LowerLow(i, 1, rate_array) == true)
      {
        if (ebar == 0)
          ebar = i;
        else if (sbar == 0 && rate_array[i][2] < rate_array[ebar][2]) // use 2 for low
          sbar = i;
      }
      if (sbar !=0 && ebar !=0)
         break;
   }
   DrawTrendline ("H1_S", ebar, sbar, PERIOD_H1, SUPPORT, rate_array);

}

void Draw_H4_Trends()
{
   int sbar=0;
   int ebar=0;
   int i;
   double rate_array[][6];
  
   ArrayCopyRates(rate_array, Symbol(), PERIOD_H4);
  
   for (i=2; i < Bars; i++)
   {
      if (HigherHigh(i, 1, rate_array) == true)
      {
        //Print("HiherHigh: ", i);
        if (ebar == 0)
          ebar = i;
        else if (sbar == 0 && rate_array[i][3] > rate_array[ebar][3]) // use 3 for high
          sbar = i;
      }
      if (sbar !=0 && ebar !=0)
         break;
   }
   DrawTrendline ("H4_R", ebar, sbar, PERIOD_H4, RESISTANCE, rate_array);
 
   ebar = 0;
   sbar = 0;
  
   for (i=2; i < Bars; i++)
   {
      if (LowerLow(i, 1, rate_array) == true)
      {
        if (ebar == 0)
          ebar = i;
        else if (sbar == 0 && rate_array[i][2] < rate_array[ebar][2]) // use 2 for low
          sbar = i;
      }
      if (sbar !=0 && ebar !=0)
         break;
   }
   DrawTrendline ("H4_S", ebar, sbar, PERIOD_H4, SUPPORT, rate_array);
}

 bool HigherHigh (int point, int shift, double array[][6])
  {
    if (shift == 0)
     return (true);

    if (array[point][3] >= array[point+shift][3] && array[point][3] >= array[point-shift][3])
    {
      if (array[point][3] == array[point+shift][3] || array[point][3] == array[point-shift][3])
      {
        if ((point - shift - 1) == 0)
          return (false);
        if (array[point][3] > array[point+shift+1][3] && array[point][3] > array[point-shift-1][3])
          return (HigherHigh (point, shift-1, array));
        else
          return (false);
      } else {
        return (HigherHigh (point, shift-1, array));
      }
    }   
    else
      return (false);
  }
 
  bool LowerLow (int point, int shift, double array[][6])
  {
    if (shift == 0)
     return (true);
    
    if (array[point][2] <= array[point+shift][2] && array[point][2] <= array[point-shift][2])
    {
      if (array[point][2] == array[point+shift][2] || array[point][2] == array[point-shift][2])
      {
        if ((point-shift-1) == 0)
         return (false);
        if (array[point][2] < array[point+shift+1][2] && array[point][2] < array[point-shift-1][2])
          return(LowerLow (point, shift-1, array));
        else
          return (false);
      } else {
        return(LowerLow (point, shift-1, array));
      }
    }
    else
      return (false);
  }
 
 int GetRealPosition(int p1, double array[][6], int which, datetime value, double peak)
 {
   int i;
 
   for (i=0; i < Bars; i++)
   {
     if (array[i][0] == value || array[i][0] < value)
     {
        if (which == RESISTANCE)
        {
          if (array[i][3] == peak) return (i);
          if (array[i-1][3] == peak) return (i-1);
          if (array[i-2][3] == peak) return (i-2);
          if (array[i-3][3] == peak) return (i-3);
         } else {
          if (array[i][2] == peak) return (i);
          if (array[i-1][2] == peak) return (i-1);
          if (array[i-2][2] == peak) return (i-2);
          if (array[i-3][2] == peak) return (i-3);
         }
         if (array[i][0] < value) return (i);
     }
   }
   return (-1);
}
 
 int DrawTrendline (string name, int p1, int p2, int timeframe, int which, double r_array[][6])
 {
   color hue;
   int thickness = 1;
   int style = STYLE_DASH;
   double array[][6];
 
   ArrayCopyRates(array, Symbol(), Period());
   
   if (which == RESISTANCE)
   {
     hue = RoyalBlue;
     if (Period() != timeframe)
     {
       p1 = GetRealPosition(p1, array, which, r_array[p1][0], r_array[p1][3]);
       p2 = GetRealPosition(p2, array, which, r_array[p2][0], r_array[p2][3]);
     }
   }
   else
   {
     hue = FireBrick;
     if (Period() != timeframe)
     {
       p1 = GetRealPosition(p1, array, which, r_array[p1][0], r_array[p1][2]);
       p2 = GetRealPosition(p2, array, which, r_array[p2][0], r_array[p2][2]);
     }
   }
     
   switch(timeframe)
   {
      case PERIOD_H4:
         thickness = 2;
         style = STYLE_SOLID;
         if (which == RESISTANCE)
           hue = H4_R;
         else
           hue = H4_S;
         break;
      case PERIOD_H1:
         style = STYLE_SOLID;
         thickness = 1;
         if (which == RESISTANCE)
           hue = H1_R;
         else
           hue = H1_S;
         break;
      case PERIOD_M15:
         style = STYLE_DASHDOTDOT;
         thickness = 1;
         if (which == RESISTANCE)
           hue = M15_R;
         else
           hue = M15_S;
         break;
   }
  
   if (ObjectFind(name) < 0)
   {
     if (which == SUPPORT)
       ObjectCreate(name, OBJ_TREND, 0, array[p2][0], array[p2][2], array[p1][0], array[p1][2]);
     else
       ObjectCreate(name, OBJ_TREND, 0, array[p2][2], array[p2][3], array[p1][0], array[p1][3]);
      
     ObjectSet(name, OBJPROP_COLOR, hue);
     ObjectSet(name, OBJPROP_RAY, true);
     ObjectSet(name, OBJPROP_BACK, true);
     ObjectSet(name, OBJPROP_WIDTH, thickness);
     ObjectSet(name, OBJPROP_STYLE, style);
   }
  
   if (which == SUPPORT)
   { // Lows (0 == Time)
     ObjectMove (name, 0, array[p2][0], array[p2][2]);
     ObjectMove (name, 1, array[p1][0], array[p1][2]); 
   }
   else
   { // Highs
     ObjectMove (name, 0, array[p2][0], array[p2][3]);
     ObjectMove (name, 1, array[p1][0], array[p1][3]);  
   }
  
   ObjectsRedraw();
   return(0);
 }

Responded

1
Developer 1
Rating
(464)
Projects
692
56%
Arbitration
43
30% / 33%
Overdue
112
16%
Working
2
Developer 2
Rating
(792)
Projects
1361
72%
Arbitration
112
29% / 48%
Overdue
340
25%
Working
3
Developer 3
Rating
(90)
Projects
159
61%
Arbitration
40
18% / 63%
Overdue
70
44%
Free
4
Developer 4
Rating
(118)
Projects
201
42%
Arbitration
44
9% / 68%
Overdue
47
23%
Free
5
Developer 5
Rating
(339)
Projects
809
73%
Arbitration
30
33% / 37%
Overdue
194
24%
Free
6
Developer 6
Rating
(169)
Projects
218
50%
Arbitration
6
17% / 67%
Overdue
11
5%
Free
7
Developer 7
Rating
(47)
Projects
140
49%
Arbitration
9
56% / 0%
Overdue
27
19%
Free
8
Developer 8
Rating
(272)
Projects
394
63%
Arbitration
70
53% / 26%
Overdue
198
50%
Free
9
Developer 9
Rating
(62)
Projects
140
46%
Arbitration
19
42% / 16%
Overdue
32
23%
Free
10
Developer 10
Rating
(7)
Projects
15
47%
Arbitration
6
33% / 17%
Overdue
4
27%
Free
11
Developer 11
Rating
(13)
Projects
20
30%
Arbitration
5
20% / 80%
Overdue
5
25%
Free
12
Developer 12
Rating
Projects
0
0%
Arbitration
0
Overdue
0
Free
13
Developer 13
Rating
Projects
5
40%
Arbitration
0
Overdue
0
Free
Similar orders
Hello, I need to optimize my indicator so that it works in several time frames. and then convert it to mq5 The task will be carried out remotely by ANYDESK
I would need an indicator which makes averages on chart (like the one existing already on mt4 where you can choose between EMA, SMA, ...) but what i need is on chart a button plus and minus which i could press in order to change the average visually on chart( so i dont have to come back in the settings of the indicator each time to introduce a new average number) And average in mt4 is limited basically at 4000 but
Hello, I need a developer who will help me to modify my current EA. It used to show news directly from forex factory on my MT4 and MT5 but now it is not showing. I want an Developer who has previous experience in creating NEWS EA which has the option to filter news and show alerts on the Charts. The modification will be done for both the MT4 and MT5 EA
I have an indicator with me , i only got the ex4 file with me,i want the new indicator to also print arrows when the old indicator print out arrow...i want the new file to be able to send out push alerts
I want to add a ma cross to my indicator and ea and I want to add a risk management EA dashboard to the EA I Have the a risk management tool that does what I want to add to the EA and I have A EA that shows what Buttons I want to add #.1 I want to add the ma cross to the indicator and ea #.2 I want to add Buy sell limit to the EA I have a ea that has most of this in it already but the ea is bugged so I want to add
Hello Everyone, On Trading view there a Indicator named as ' Nadaraya-Watson Envelope [LuxAlgo]' I want Buy Alert when that Indicator gives Blue arrow below lower line and vice versa, Sell alert when the Indicator gives Orange Arrow upside of the Upper line
I have the ea with me , can you please change the comment? i only got the ex4 file with me , please do chnage the comment only and i need you to put license and cloud lock to this ea can any body do it
1. I want function that will use the totalBuyLots and totalSellLots to place trades when there is reverse trade direction. For example, if there is an open trade of buy, 0.1, 0.1, 0.1, then if the trade direction change to sell, meaning a sell trad is opened, then the totalBuyLots which now 0.3 will be used to open the sell of 0.3 lots. Same if a sell trade is opened first, then total lots will be use d when
Hello Sir - I am looking for some thing like this. 1- Moving Average MA value as line on Chart with label. i.e. 5min, 50, Exponential ( Labels should be selectable, Hide / Unhide, or display on Right / Left) 2- The line colors and style should be selectable. 3- Alert if price equals to MA Value. Please mention if you will be sharing code with me for future improvements
Seeking an expert in LSTM (Long Short-Term Memory) for MT4 to implement the most cutting-edge and advanced form of LSTM with full feature integration. The ideal candidate will possess extensive experience in leveraging LSTM technology within MT4, ensuring optimal performance and profitability. Join us in revolutionizing trading strategies with state-of-the-art LSTM algorithms tailored for MT4. Add a zig zag to the

Project information

Budget
10 - 15 USD
For the developer
9 - 13.5 USD
Deadline
from 1 to 3 day(s)