Graphically display current trend for all time frames in one simple panel...

Graphically display current trend for all time frames in one simple panel – Індыкатар для MetaTrader 4

10985
0
ДОЛЯ

Put all your trends for multiple timeframes in a single panel. Declutter and gain focus.

This is a graphical indicator based on slope-direction-trend indicator that has been published under several other forms.

There has been several versions of this indicator published already but none that displayed all time frames in a single graphical panel on your screen.

One can search https://www.mql5.com/en/search#!keyword=slope%20direction%20line to see multiple results.

I have taken this indicator and made it into a graphical panel displaying all time frames and made a few slight modifications to the original code. One of them is that it allows the user to select the second moving average method used for smoothing. The original code used Linear Weighted for its second pass on the numbers whereas I give the user the option to choose the method for smoothing. When using Linear Weighted for both calculations, it makes the indicator too responsive and thus possibly giving false readings on the current trend. If we use Simple as the second averaging method we get a trend that is more indicative of where the price is going.

Another change that I have made is the ability to not only get the direction of the trend (up, down or flat) but also get its value. I will talk about this in another article I plan on publishing shortly on how to use a double SlopeDirection indicator and create a Expert Advisor with it.

But for now, let’s take a quick look at the code. I first define all the object names I will use. The reason why this is good practice to do is that each time you put an object name between quotes, it allocates space in the program for it. So it they are defined once (by using a define statement) you only use up the space in your code once.

// Define trend directions

#define UPTREND 1

#define DOWNTREND -1

#define FLATTREND 0

 

// Define Objectcs

#define TrendPanelTrendPanel

#define InfoLine1InfoLine1

#define InfoLine2InfoLine2

#define TrendLabelTrend: M1 M5 M15 M30 H1 H4 D1 W1 MN

#define TrendUp “233”

#define TrendDown “234”

#define TrendFlat “232”

#define TrendUnknown “251”

#define StatObjectError “%s(%d) Failed to create ‘%s’. Error = %d

Next, I define two arrays. One with the pixel position for each of the 9 time frames and the second with the time frames. These are defined as global variables.

// Define global variables

int TrendPosition[] = { 44, 64, 88, 114, 136, 156, 174, 194, 216 };

int TrendPeriods[] = { PERIOD_M1, PERIOD_M5, PERIOD_M15, PERIOD_M30, PERIOD_H1, PERIOD_H4, PERIOD_D1, PERIOD_W1, PERIOD_MN1 };

Our indicator OnInit() function calls a function to create the panel and the objects within the panel. It also does a quickDumn Dumncheck on the bars used to calculate the trend. Less than 3 is kind of pointless.

//+——————————————————————+

//| Custom indicator initialization function |

//+——————————————————————+

int OnInit()

{

// Go create objects for indicator panel

калі(Create_Panel() && BarCount >= 3)

return(INIT_SUCCEEDED);

else

return(INIT_FAILED);

}

I will not get into details on how the GetTrend() function really works, there’s already good documentation on this site for that. We’ll just take a look at the graphical DisplayTrend() function.

//+——————————————————————+

//| Display the current trend for all timeframes

//+——————————————————————+

void DisplayTrend(void)

{

int i, cntr, Trend, LastTrend;

string str;

 

для(i=1; Я<10; я ++)

{

str =Trend” + DoubleToStr(Я, 0);

Trend = (int)GetTrend(TrendPeriods[я-1], BarCount, метад);

калі(Trend == FLATTREND)

{

// I’m flat, find the last trend direction

cntr = 1;

do

{

LastTrend = (int)GetTrend(TrendPeriods[я-1], BarCount, метад, фальшывы, cntr++);

} while(LastTrend == Trend);

ObjectSetText(str, TrendFlat, 8, “WingDings”, (LastTrend == UPTREND ? Зялёны : Чырвоны));

ObjectSetInteger(0, str, OBJPROP_YDISTANCE, 6);

}

else

{

ObjectSetText(str, (Trend == UPTREND ? TrendUp : TrendDown), 8, “WingDings”, (Trend == UPTREND ? Зялёны : Чырвоны));

ObjectSetInteger(0, str, OBJPROP_YDISTANCE, 5 + (Trend == UPTREND ? 1 : -1));

}

}

}

у асноўным, we simply loop thru the TrendPeriods[] array (to get all time frames) and set the trend arrow according to that time frame’s trend direction. If the trend is flat, we find the first direction that is not flat to know where the trend was coming from in order to display the side arrow in the color of that direction.

The Create_Panel() function in our OnInit() creates the objects anchored to the bottom left of the screens and uses TrendPosition[] to place the arrows in the right place.

//+——————————————————————+

//| Create the trend panel in the bottom left of the screen

//+——————————————————————+

bool Create_Panel(void)

{

int i;

string str;

// Create the trend indicator window

калі(ObjectCreate(TrendPanel, OBJ_RECTANGLE_LABEL, 0, 0, 0))

{

ObjectSetInteger(0, TrendPanel, OBJPROP_XDISTANCE, 1);

ObjectSetInteger(0, TrendPanel, OBJPROP_YDISTANCE, 29);

ObjectSetInteger(0, TrendPanel, OBJPROP_XSIZE, 240);

ObjectSetInteger(0, TrendPanel, OBJPROP_YSIZE, 26);

ObjectSetInteger(0, TrendPanel, OBJPROP_BGCOLOR, White);

ObjectSetInteger(0, TrendPanel, OBJPROP_BORDER_TYPE, 0);

ObjectSetInteger(0, TrendPanel, OBJPROP_CORNER, CORNER_LEFT_LOWER);

ObjectSetInteger(0, TrendPanel, OBJPROP_COLOR, Чырвоны);

ObjectSetInteger(0, TrendPanel, OBJPROP_STYLE, STYLE_SOLID);

ObjectSetInteger(0, TrendPanel, OBJPROP_WIDTH, 2);

ObjectSetInteger(0, TrendPanel, OBJPROP_BACK, фальшывы);

ObjectSetInteger(0, TrendPanel, OBJPROP_SELECTABLE, фальшывы);

ObjectSetInteger(0, TrendPanel, OBJPROP_SELECTED, фальшывы);

ObjectSetInteger(0, TrendPanel, OBJPROP_HIDDEN, праўда);

ObjectSetString(0, TrendPanel, OBJPROP_TOOLTIP, “n”);

}

else

{ PrintFormat(StatObjectError, __FUNCTION__, __LINE__, TrendPanel, GetLastError()); return(фальшывы); }

калі(ObjectCreate(InfoLine1, OBJ_LABEL, 0, 0, 0))

{

ObjectSet(InfoLine1, OBJPROP_CORNER, CORNER_LEFT_LOWER);

ObjectSet(InfoLine1, OBJPROP_XDISTANCE, 6);

ObjectSet(InfoLine1, OBJPROP_YDISTANCE, 15);

ObjectSetInteger(0, InfoLine1, OBJPROP_SELECTABLE, фальшывы);

ObjectSetInteger(0, InfoLine1, OBJPROP_HIDDEN, праўда);

ObjectSetString(0, InfoLine1, OBJPROP_TOOLTIP, “n”);

ObjectSetText(InfoLine1, TrendLabel, 8, “Arial”, Black);

}

else

{ PrintFormat(StatObjectError, __FUNCTION__, __LINE__, InfoLine1, GetLastError()); return(фальшывы); }

 

калі(ObjectCreate(InfoLine2, OBJ_LABEL, 0, 0, 0))

{

ObjectSet(InfoLine2, OBJPROP_CORNER, CORNER_LEFT_LOWER);

ObjectSet(InfoLine2, OBJPROP_XDISTANCE, 6);

ObjectSet(InfoLine2, OBJPROP_YDISTANCE, 5);

ObjectSetInteger(0, InfoLine2, OBJPROP_SELECTABLE, фальшывы);

ObjectSetInteger(0, InfoLine2, OBJPROP_HIDDEN, праўда);

ObjectSetString(0, InfoLine2, OBJPROP_TOOLTIP, “n”);

ObjectSetText(InfoLine2, ” ” + DoubleToStr(BarCount, 0) + ” / ” + DoubleToStr(метад, 0), 8, “Arial”, Black);

}

else

{ PrintFormat(StatObjectError, __FUNCTION__, __LINE__, InfoLine2, GetLastError()); return(фальшывы); }

// Create trend object and display current trend

для(i=1; Я<10; я ++)

{

str =Trend” + DoubleToStr(Я, 0);

калі(ObjectCreate(str, OBJ_LABEL, 0, 0, 0))

{

ObjectSet(str, OBJPROP_CORNER, CORNER_LEFT_LOWER);

ObjectSet(str, OBJPROP_XDISTANCE, TrendPosition[я-1]);

ObjectSet(str, OBJPROP_YDISTANCE, 5);

ObjectSetInteger(0, str, OBJPROP_SELECTABLE, фальшывы);

ObjectSetInteger(0, str, OBJPROP_HIDDEN, праўда);

ObjectSetString(0, str, OBJPROP_TOOLTIP, “n”);

}

else

{ PrintFormat(StatObjectError, __FUNCTION__, __LINE__, str, GetLastError()); return(фальшывы); }

}

// Go display current trend

DisplayTrend();

// All good

return(праўда);

}

This function will return TRUE if it succeeded in creating all the objects, or return FALSE if an error occurred creating an object. The nice thing is that the indicator will display in the EXPERT tab of your console the error code and the line number of the code where the error occurred.

We also need to update the trend indicator for each new tick we receive. This is done by calling DisplayTrend() in our start() function.

//+——————————————————————+

//| Custom indicator iteration function |

//+——————————————————————+

int start()

{

// Display current trend for all timeframes

DisplayTrend();

return(0);

}

Lastly, we destroy all objects created by the indicator when we close the indicator.

//+——————————————————————+

//| Deinitialization function |

//+——————————————————————+

voidOnDeinit(constint reason)

{

// Delete indicator’s objects

калі(ObjectFind(TrendPanel) >= 0) ObjectDelete(TrendPanel);

калі(ObjectFind(InfoLine1) >= 0) ObjectDelete(InfoLine1);

калі(ObjectFind(InfoLine2) >= 0) ObjectDelete(InfoLine2);

для(INT I = 1; Я<10; я ++)

калі(ObjectFind(“Trend”+DoubleToStr(Я, 0)) >= 0) ObjectDelete(“Trend”+DoubleToStr(Я, 0));

}

That’s basically it. You now have a nice indicator panel showing the current trend for all time frames in the lower left of your screen.

MT4 індыкатары – Інструкцыі па загрузцы

Graphically display current trend for all time frames in one simple panel – Індыкатар для MetaTrader 4 з'яўляецца Metatrader 4 (MT4) Індыкатар і сутнасць форекс-індыкатара заключаецца ў пераўтварэнні назапашаных гістарычных дадзеных.

Graphically display current trend for all time frames in one simple panel – Індыкатар для MetaTrader 4 забяспечвае магчымасць выяўлення розных асаблівасцяў і заканамернасцяў у дынаміку коштаў, якія нябачныя няўзброеным вокам.

На падставе гэтай інфармацыі, трэйдары могуць выказаць здагадку далейшае рух цэны і карэктаваць свае стратэгіі, адпаведна,.

How to install Graphically display current trend for all time frames in one simple panel – Індыкатар для MetaTrader 4.mq4?

  • Download Graphically display current trend for all time frames in one simple panel – Індыкатар для MetaTrader 4.mq4
  • Copy Graphically display current trend for all time frames in one simple panel – Індыкатар для MetaTrader 4.mq4 вашага Metatrader каталога / эксперты / паказчыкі /
  • Запусціце або перазапусціце ваш Metatrader Client
  • Выберыце Дыяграма і тэрміны, дзе вы хочаце, каб праверыць свой індыкатар
  • Пошук “Прыстасаваныя індыкатары” у навігатары ў асноўным засталося ў Metatrader Client
  • Right click on Graphically display current trend for all time frames in one simple panel – Індыкатар для MetaTrader 4.mq4
  • Далучыць да графіку
  • Змяніць налады або націсніце кнопку ОК
  • Indicator Graphically display current trend for all time frames in one simple panel – Індыкатар для MetaTrader 4.mq4 даступная на вашым графіцы

How to remove Graphically display current trend for all time frames in one simple panel – Індыкатар для MetaTrader 4.mq4 ад вашага Metatrader 4 Графік?

  • Выберыце схему, дзе ёсць Індыкатар працуе ў Metatrader Client
  • Пстрыкніце правай кнопкай мышы на графік
  • “Спіс індыкатараў”
  • Выберыце індыкатар і выдаляць

ня ХТ-ня-дэпазіт-бонус
MT4 індыкатары Спампаваць ніжэй:

Graphically display current trend for all time frames in one simple panel – Індыкатар для MetaTrader 4

БЕЗ КАМЕНТАРЫЯЎ

пакінуць каментар