truetl button.mq5
Сообщите нам, если считаете, что материал размещён без разрешения.
Сообщить о материале
Обращение по товару «truetl button.mq5» отправится на рассмотрение. Укажите контакт для ответа и опишите причину.
О программе
truetl button.mq4 — индикатор для платформы MetaTrader 4, который отрисовывает линии тренда на графике цен. Индикатор строит восходящие и нисходящие трендовые линии, определяет их длительность и выделяет линии, просуществовавшие дольше заданного периода. Имеет кнопку на графике для включения и выключения отображения объектов индикатора. Поддерживает режимы ускоренного анализа для таймфреймов M1 и M5, а также опциональную функцию определения линий по методу трёх касаний.
Настройки программы
| Настройка | Описание |
|---|---|
| Auto_Refresh | Автообновление — Включает или отключает автоматическое обновление расчёта линий тренда при изменении данных на графике |
| Normal_TL_Period | Период обычной линии — Пороговое значение в барах, определяющее классификацию линии тренда как обычной или долгосрочной |
| Three_Touch | Трёхкасание — Включает дополнительную проверку линий тренда по методу трёх касаний цены |
| M1_Fast_Analysis | Ускоренный анализ M1 — Активирует режим ускоренного расчёта линий тренда на минутном таймфрейме M1 |
| M5_Fast_Analysis | Ускоренный анализ M5 — Активирует режим ускоренного расчёта линий тренда на пятиминутном таймфрейме M5 |
| Mark_Highest_and_Lowest_TL | Отметка максимумов и минимумов — Включает выделение самых высоких и низких линий тренда на графике |
| Expiration_Day_Alert | День оповещения об истечении — Задаёт количество дней до истечения, при котором срабатывает уведомление |
| Normal_TL_Color | Цвет обычной линии — Задаёт цвет отрисовки обычных линий тренда |
| Long_TL_Color | Цвет долгосрочной линии — Задаёт цвет отрисовки долгосрочных линий тренда |
| Three_Touch_TL_Widht | Ширина линий трёхкасания — Задает толщину линий тренда, выявленных по методу трёх касаний |
| Three_Touch_TL_Color | Цвет линий трёхкасания — Задаёт цвет отрисовки линий тренда, выявленных по методу трёх касаний |
| button_x | Координата X кнопки — Задаёт горизонтальную позицию кнопки управления видимостью индикатора на графике |
| button_y | Координата Y кнопки — Задаёт вертикальную позицию кнопки управления видимостью индикатора на графике |
Поиск по коду файла
#property version "1.0"
#property strict
#property indicator_chart_window
#include <WinUser32.mqh>
#import "user32.dll"
int RegisterWindowMessageA(string a0);
#import
extern bool Auto_Refresh = TRUE;
extern int Normal_TL_Period = 500;
extern bool Three_Touch = TRUE;
extern bool M1_Fast_Analysis = TRUE;
extern bool M5_Fast_Analysis = TRUE;
extern bool Mark_Highest_and_Lowest_TL = TRUE;
extern int Expiration_Day_Alert = 5;
extern color Normal_TL_Color = clrDarkGreen;
extern color Long_TL_Color = clrGoldenrod;
extern int Three_Touch_TL_Widht = 2;
extern color Three_Touch_TL_Color = clrDimGray;
extern int button_x = 20;
extern int button_y = 30;
double ExtBuffer01;
class VisibilityCotroller
{
string buttonId;
string visibilityId;
bool show_data;
bool recalc;
public:
void Init(string id, string indicatorName, string caption, int x, int y)
{
recalc = false;
visibilityId = indicatorName + "_visibility";
double val;
if (GlobalVariableGet(visibilityId, val))
show_data = val != 0;
buttonId = id;
ChartSetInteger(0, CHART_EVENT_MOUSE_MOVE, 1);
createButton(buttonId, caption, 65, 20, "Impact", 8, clrDarkRed, clrBlack, clrWhite);
ObjectSetInteger(0, buttonId, OBJPROP_YDISTANCE, x);
ObjectSetInteger(0, buttonId, OBJPROP_XDISTANCE, y);
}
bool HandleButtonClicks()
{
if (ObjectGetInteger(0, buttonId, OBJPROP_STATE))
{
ObjectSetInteger(0, buttonId, OBJPROP_STATE, false);
show_data = !show_data;
GlobalVariableSet(visibilityId, show_data ? 1.0 : 0.0);
recalc = true;
return true;
}
return false;
}
bool IsRecalcNeeded()
{
return recalc;
}
void ResetRecalc()
{
recalc = false;
}
bool IsVisible()
{
return show_data;
}
private:
void createButton(string buttonID,string buttonText,int width,int height,string font,int fontSize,color bgColor,color borderColor,color txtColor)
{
ObjectDelete(0,buttonID);
ObjectCreate(0,buttonID,OBJ_BUTTON,0,0,0);
ObjectSetInteger(0,buttonID,OBJPROP_COLOR,txtColor);
ObjectSetInteger(0,buttonID,OBJPROP_BGCOLOR,bgColor);
ObjectSetInteger(0,buttonID,OBJPROP_BORDER_COLOR,borderColor);
ObjectSetInteger(0,buttonID,OBJPROP_BORDER_TYPE,BORDER_RAISED);
ObjectSetInteger(0,buttonID,OBJPROP_XDISTANCE,9999);
ObjectSetInteger(0,buttonID,OBJPROP_YDISTANCE,9999);
ObjectSetInteger(0,buttonID,OBJPROP_XSIZE,width);
ObjectSetInteger(0,buttonID,OBJPROP_YSIZE,height);
ObjectSetString(0,buttonID,OBJPROP_FONT,font);
ObjectSetString(0,buttonID,OBJPROP_TEXT,buttonText);
ObjectSetInteger(0,buttonID,OBJPROP_FONTSIZE,fontSize);
ObjectSetInteger(0,buttonID,OBJPROP_SELECTABLE,0);
ObjectSetInteger(0,buttonID,OBJPROP_CORNER,2);
ObjectSetInteger(0,buttonID,OBJPROP_HIDDEN,1);
}
};
VisibilityCotroller _visibility;
string IndicatorName;
string IndicatorObjPrefix;
string GenerateIndicatorName(const string target)
{
string name = target;
int try = 2;
while (WindowFind(name) != -1)
{
name = target + " #" + IntegerToString(try++);
}
return name;
}
int init() {
// код доступен только после оплаты
}
void Clean()
{
ObjectsDeleteAll(ChartID(), IndicatorObjPrefix);
}
int deinit() {
ObjectsDeleteAll(ChartID(), "_" + IndicatorObjPrefix);
Clean();
return (0);
}
void OnChartEvent(const int id,
const long &lparam,
const double &dparam,
const string &sparam)
{
if (_visibility.HandleButtonClicks())
start();
}
int start() {
// код доступен только после оплаты
}
int TrendLine20;
int Shift21;
double doubleTrendLine22;
int TrendLine23;
int TrendLine24;
double Semafor01;
int Semafor02;
double doubleSemafor03;
int Semafor04;
double doubleSemafor05;
int wolf01;
int wolf02;
double wolf03;
double wolf04;
double wolf05;
double Elliott01;
double Elliott02;
double Elliott03;
double Elliott04;
double Elliott05;
double UpTrendLine01;
double UpTrendLine02;
double DownTrendLine01;
int Counter01;
int Counter02;
if (Normal_TL_Period > 1000 || Normal_TL_Period < 100)
Normal_TL_Period = 500;
_visibility.HandleButtonClicks();
if (!_visibility.IsVisible())
{
ExtBuffer01 = 0;
Clean();
ObjectCreate(IndicatorObjPrefix + "calctl", OBJ_HLINE, 0, 0, 0);
ObjectCreate(IndicatorObjPrefix + "visibletl", OBJ_HLINE, 0, 0, 0);
ObjectCreate(IndicatorObjPrefix + "downmax", OBJ_TREND, 0, 0, 0, 0, 0);
ObjectCreate(IndicatorObjPrefix + "upmax", OBJ_TREND, 0, 0, 0, 0, 0);
return 0;
}
bool refreshed = _visibility.IsRecalcNeeded();
_visibility.ResetRecalc();
int Mando = MathMax(0, WindowFirstVisibleBar() - WindowBarsPerChart());
double maxbars01 = Bars;
if (ExtBuffer01 == 0)
ExtBuffer01 = maxbars01;
if (maxbars01 > ExtBuffer01) {
ExtBuffer01 = maxbars01;
if (Auto_Refresh == TRUE && Mando == 0)
ObjectSet(IndicatorObjPrefix + "calctl", OBJPROP_PRICE1, -1);
}
if (Auto_Refresh == TRUE && (IndicatorCounted() == 0 || refreshed))
ObjectSet(IndicatorObjPrefix + "calctl", OBJPROP_PRICE1, -1);
if (ObjectGet(IndicatorObjPrefix + "visibletl", OBJPROP_PRICE1) == -1.0) {
for (int ForexStation = 0; ForexStation <= 100; ForexStation++) {
ObjectDelete(IndicatorObjPrefix + "downtrendline" + IntegerToString(ForexStation));
ObjectDelete(IndicatorObjPrefix + "uptrendline" + IntegerToString(ForexStation));
ObjectDelete(IndicatorObjPrefix + "downtrendline" + IntegerToString(ForexStation) + "tt");
ObjectDelete(IndicatorObjPrefix + "uptrendline" + IntegerToString(ForexStation) + "tt");
}
}
if (ObjectGet(IndicatorObjPrefix + "calctl", OBJPROP_PRICE1) == -1.0 && ObjectGet("visibletl", OBJPROP_PRICE1) == 0.0) {
for (int ForexStation = 0; ForexStation <= 100; ForexStation++) {
ObjectDelete(IndicatorObjPrefix + "downtrendline" + IntegerToString(ForexStation));
ObjectDelete(IndicatorObjPrefix + "uptrendline" + IntegerToString(ForexStation));
ObjectDelete(IndicatorObjPrefix + "downtrendline" + IntegerToString(ForexStation) + "tt");
ObjectDelete(IndicatorObjPrefix + "uptrendline" + IntegerToString(ForexStation) + "tt");
}
TrendLine20 = 150000;
if (Period() == PERIOD_M1 && M1_Fast_Analysis == TRUE) TrendLine20 = 8000;
if (Period() == PERIOD_M5 && M5_Fast_Analysis == TRUE) TrendLine20 = 2400;
if (Period() == PERIOD_MN1) {
TrendLine20 = 150;
Three_Touch = FALSE;
Normal_TL_Period = 150;
}
Shift21 = Mando + MathMin(Bars - Mando - 10, TrendLine20);
doubleTrendLine22 = iHigh(NULL, 0, Shift21);
TrendLine24 = Mando + MathMin(Bars - Mando - 10, TrendLine20);
Semafor01 = iHigh(NULL, 0, TrendLine24);
for (int Line01 = 1; Line01 < 50; Line01++) {
if ((iFractals(NULL, 0, MODE_UPPER, Mando + Line01) > 0.0 && Line01 > 2) || (Close[Mando + Line01 + 1] > Open[Mando + Line01 + 1] && Close[Mando + Line01 + 1] - (Low[Mando +
Line01 + 1]) < 0.6 * (High[Mando + Line01 + 1] - (Low[Mando + Line01 + 1])) && Close[Mando + Line01] < Open[Mando + Line01]) || (Close[Mando + Line01 + 1] <= Open[Mando +
Line01 + 1] && Close[Mando + Line01] < Open[Mando + Line01]) || (Close[Mando + Line01] < Open[Mando + Line01] && Close[Mando + Line01] < Low[Mando + Line01 + 1])) {
TrendLine23 = Mando + Line01;
break;
}
}
for (int LineCounter01 = 1; LineCounter01 <= 30; LineCounter01++) {
if (Shift21 > TrendLine23 + 6.0) {
ObjectCreate(IndicatorObjPrefix + "downtrendline" + IntegerToString(LineCounter01), OBJ_TREND, 0, iTime(NULL, 0, Shift21), doubleTrendLine22, iTime(NULL, 0, Shift21), doubleTrendLine22);
for (int Line01 = Shift21; Line01 >= TrendLine23; Line01--) {
if (ObjectGet(IndicatorObjPrefix + "downtrendline" + IntegerToString(LineCounter01), OBJPROP_PRICE1) == ObjectGet(IndicatorObjPrefix + "downtrendline" + IntegerToString(LineCounter01), OBJPROP_PRICE2)) {
ObjectMove(IndicatorObjPrefix + "downtrendline" + IntegerToString(LineCounter01), 1, iTime(NULL, 0, Line01 - 1), iHigh(NULL, 0, Line01 - 1));
Shift21 = Line01 - 1;
doubleTrendLine22 = iHigh(NULL, 0, Line01 - 1);
}
doubleSemafor03 = ObjectGetValueByShift(IndicatorObjPrefix + "downtrendline" + IntegerToString(LineCounter01), Line01);
if (doubleSemafor03 < iHigh(NULL, 0, Line01)) {
ObjectMove(IndicatorObjPrefix + "downtrendline" + IntegerToString(LineCounter01), 1, iTime(NULL, 0, Line01), iHigh(NULL, 0, Line01));
Shift21 = Line01;
doubleTrendLine22 = iHigh(NULL, 0, Line01);
}
}
}
if (ObjectGet(IndicatorObjPrefix + "downtrendline" + IntegerToString(LineCounter01), OBJPROP_PRICE1) < ObjectGet(IndicatorObjPrefix + "downtrendline" + IntegerToString(LineCounter01), OBJPROP_PRICE2)) ObjectDelete(IndicatorObjPrefix + "downtrendline" + IntegerToString(LineCounter01));
if (iBarShift(NULL, 0, ObjectGet(IndicatorObjPrefix + "downtrendline" + IntegerToString(LineCounter01), OBJPROP_TIME1)) - Mando >= Normal_TL_Period) {
ObjectSet(IndicatorObjPrefix + "downtrendline" + IntegerToString(LineCounter01), OBJPROP_COLOR, Long_TL_Color);
ObjectSetText(IndicatorObjPrefix + "downtrendline" + IntegerToString(LineCounter01), "Long");
} else {
ObjectSet(IndicatorObjPrefix + "downtrendline" + IntegerToString(LineCounter01), OBJPROP_COLOR, Normal_TL_Color);
ObjectSetText(IndicatorObjPrefix + "downtrendline" + IntegerToString(LineCounter01), "Normal");
}
}
for (int Line01 = 1; Line01 < 50; Line01++) {
if ((iFractals(NULL, 0, MODE_LOWER, Mando + Line01) > 0.0 && Line01 > 2) || (Close[Mando + Line01 + 1] < Open[Mando + Line01 + 1] && High[Mando + Line01 + 1] - (Close[Mando +
Line01 + 1]) < 0.6 * (High[Mando + Line01 + 1] - (Low[Mando + Line01 + 1])) && Close[Mando + Line01] > Open[Mando + Line01]) || (Close[Mando + Line01 + 1] >= Open[Mando +
Line01 + 1] && Close[Mando + Line01] > Open[Mando + Line01]) || (Close[Mando + Line01] > Open[Mando + Line01] && Close[Mando + Line01] > High[Mando + Line01 + 1])) {
Semafor02 = Mando + Line01;
break;
}
}
for (int LineCounter01 = 1; LineCounter01 <= 30; LineCounter01++) {
if (TrendLine24 > Semafor02 + 6.0) {
ObjectCreate(IndicatorObjPrefix + "uptrendline" + IntegerToString(LineCounter01), OBJ_TREND, 0, iTime(NULL, 0, TrendLine24), Semafor01, iTime(NULL, 0, TrendLine24), Semafor01);
for (int Line01 = TrendLine24; Line01 >= Semafor02; Line01--) {
if (ObjectGet(IndicatorObjPrefix + "uptrendline" + IntegerToString(LineCounter01), OBJPROP_TIME1) == ObjectGet(IndicatorObjPrefix + "uptrendline" + IntegerToString(LineCounter01), OBJPROP_TIME2)) {
ObjectMove(IndicatorObjPrefix + "uptrendline" + IntegerToString(LineCounter01), 1, iTime(NULL, 0, Line01 - 1), iLow(NULL, 0, Line01 - 1));
TrendLine24 = Line01 - 1;
Semafor01 = iLow(NULL, 0, Line01 - 1);
}
doubleSemafor03 = ObjectGetValueByShift(IndicatorObjPrefix + "uptrendline" + IntegerToString(LineCounter01), Line01);
if (iLow(NULL, 0, Line01) < doubleSemafor03) {
ObjectMove(IndicatorObjPrefix + "uptrendline" + IntegerToString(LineCounter01), 1, iTime(NULL, 0, Line01), iLow(NULL, 0, Line01));
TrendLine24 = Line01;
Semafor01 = iLow(NULL, 0, Line01);
}
}
}
if (ObjectGet(IndicatorObjPrefix + "uptrendline" + IntegerToString(LineCounter01), OBJPROP_PRICE1) > ObjectGet(IndicatorObjPrefix + "uptrendline" + IntegerToString(LineCounter01), OBJPROP_PRICE2)) ObjectDelete(IndicatorObjPrefix + "uptrendline" + IntegerToString(LineCounter01));
if (iBarShift(NULL, 0, ObjectGet(IndicatorObjPrefix + "uptrendline" + IntegerToString(LineCounter01), OBJPROP_TIME1)) - Mando >= Normal_TL_Period) {
ObjectSet(IndicatorObjPrefix + "uptrendline" + IntegerToString(LineCounter01), OBJPROP_COLOR, Long_TL_Color);
ObjectSetText(IndicatorObjPrefix + "uptrendline" + IntegerToString(LineCounter01), "Long");
} else {
ObjectSet(IndicatorObjPrefix + "uptrendline" + IntegerToString(LineCounter01), OBJPROP_COLOR, Normal_TL_Color);
ObjectSetText(IndicatorObjPrefix + "uptrendline" + IntegerToString(LineCounter01), "Normal");
}
}
Показано первые 50% кода (символов: 20236)
Открыть по тарифу
Купите тариф с пакетом открытий или войдите, если тариф уже есть. Открытый файл останется в вашем кабинете навсегда.
Разовая покупка файла
На этой странице откроется полный исходный код файла вместо ознакомительного фрагмента.
Зачем нужен email? После подтверждения оплаты файл сохранится в кабинете на этот email. Если аккаунта ещё нет, мы создадим его и пришлём ссылку для задания пароля. Если аккаунт уже есть, покупка добавится в него. Укажите адрес, к которому у вас есть доступ.
Чтобы оформить заказ, введите email и перейдите к оплате.