Группа "Стол заказов MQL"

Рейтинг 2089



РЕКОМЕНДУЮ



Советник по ТМА

Андрей, здравствуйте.
Когда.то вы делали этот советник, который меня полностью устраивает.
Можете просто в него вставить этот индикатор, оставив всё как есть?
Если только ещё безубыток нставить.
Спасибо
Usrednitel.mq4 (28 Kb)
TMA+CG _mqllab.ru.mq 4 (0 Kb)
  • 0
  • Просмотров: 2005
  • 20 апреля 2023, 19:38
  • gek63
Понравилcя материал? Не забудьте поставить плюс и поделиться в социальной сети!

Вступите в группу "Стол заказов MQL", чтобы следить за обновлениями
ПРИСОЕДИНИТЬСЯ К ГРУППЕ
присоединиться
Следующая запись в группе  
Please update this CloseAll function into two Functions.
19 апреля 2023
21 апреля 2023

Комментарии (31)

+
0
Совершенно не правильно написал.
Прошу вместо тех индикаторов, вставить этот.
avatar

  6  gek63 Автор Сообщений: 100

  • 21 апреля 2023, 00:04
+
0
посмотрю сегодня
avatar

  34  AM2 Сообщений: 15894 - Андрей

  • 21 апреля 2023, 06:29
+
+1
перезалейте индикатор
avatar

  34  AM2 Сообщений: 15894 - Андрей

  • 21 апреля 2023, 06:53
+
0
И почему я не могу перезалить индикатор?
Возможно только изображение
avatar

  6  gek63 Автор Сообщений: 100

  • 21 апреля 2023, 11:55
+
0
сделал с подобным индикатором: www.opentraders.ru/downloads/3578/

avatar

  34  AM2 Сообщений: 15894 - Андрей

  • 21 апреля 2023, 07:27
+
0
Спасибо.
Скинь тогда пожалуйста сам индикатор.
Он мне нужен для сигнала.
avatar

  6  gek63 Автор Сообщений: 100

  • 21 апреля 2023, 11:39
+
0
Должен открыть бай, открыл бай и селл?
avatar

  6  gek63 Автор Сообщений: 100

  • 21 апреля 2023, 11:48
+
0
Добавил
avatar

  6  gek63 Автор Сообщений: 100

  • 21 апреля 2023, 12:01
+
0
скиньте индикатор в базу и сюда ссылку на него: www.opentraders.ru/downloads/
avatar

  34  AM2 Сообщений: 15894 - Андрей

  • 21 апреля 2023, 13:44
+
0
avatar

  6  gek63 Автор Сообщений: 100

  • 21 апреля 2023, 14:16
+
0
это ссылка на пустую страницу
avatar

  34  AM2 Сообщений: 15894 - Андрей

  • 21 апреля 2023, 14:59
+
0
Блин, не пойму?
Где можно воткнуть файл, не могу найти.
Андрей, скинь ссылку, куда его определить.
avatar

  6  gek63 Автор Сообщений: 100

  • 21 апреля 2023, 15:19
+
0
Попробуйте сюда. Открытым кодом. Использую функцию:
<code>
code
</code>

Редактирован: 21 апреля 2023, 15:51
avatar

  16  ssg Сообщений: 817

  • 21 апреля 2023, 15:50
+
0
//+------------------------------------------------------------------+
//| TMA+CG.mq4 |
//| mladen |
//| arrowse coded acording to idea presented by rajiv |
//+------------------------------------------------------------------+
#property copyright «rajivxxx»
#property link «rajivxxx@gmail.com / MqlLab.ru»

#property indicator_chart_window
#property indicator_buffers 5
#property indicator_color1 DimGray
#property indicator_color2 Red
#property indicator_color3 LimeGreen
#property indicator_color4 MediumTurquoise
#property indicator_color5 Magenta
#property indicator_style1 STYLE_DOT

//
//
//
//
//

extern string TimeFrame = «current time frame»;
extern int HalfLength = 56;
extern int Price = PRICE_WEIGHTED;
extern double BandsDeviations = 2.0;
extern bool Interpolate = true;
extern bool alertsOn = false;
extern bool alertsOnCurrent = false;
extern bool alertsOnHighLow = true;
extern bool alertsMessage = true;
extern bool alertsSound = false;
extern bool alertsEmail = false;

//
//
//
//
//

double tmBuffer[];
double upBuffer[];
double dnBuffer[];
double wuBuffer[];
double wdBuffer[];
double upArrow[];
double dnArrow[];

//
//
//
//
//

string IndicatorFileName;
bool calculatingTma = false;
bool returningBars = false;
int timeFrame;

//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
//
//
//
//

int init()
{
timeFrame = stringToTimeFrame(TimeFrame);
HalfLength = MathMax(HalfLength,1);
IndicatorBuffers(7);
SetIndexBuffer(0,tmBuffer); SetIndexDrawBegin(0,HalfLength);
SetIndexBuffer(1,upBuffer); SetIndexDrawBegin(1,HalfLength);
SetIndexBuffer(2,dnBuffer); SetIndexDrawBegin(2,HalfLength);
SetIndexBuffer(3,dnArrow); SetIndexStyle(3,DRAW_ARROW); SetIndexArrow(3,233);
SetIndexBuffer(4,upArrow); SetIndexStyle(4,DRAW_ARROW); SetIndexArrow(4,234);
SetIndexBuffer(5,wuBuffer);
SetIndexBuffer(6,wdBuffer);

if (TimeFrame==«calculateTma») { calculatingTma=true; return(0); }
if (TimeFrame==«returnBars») { returningBars=true; return(0); }

IndicatorFileName = WindowExpertName();
return(0);
}
int deinit() { return(0); }

//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
//
//
//
//
//

int start()
{
int counted_bars=IndicatorCounted();
int i,limit;

if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
limit=MathMin(Bars-1,Bars-counted_bars+HalfLength);

if (returningBars) { tmBuffer[0] = limit; return(0); }
if (calculatingTma) { calculateTma(limit); return(0); }
if (timeFrame > Period()) limit = MathMax(limit,MathMin(Bars-1,iCustom(NULL,timeFrame,IndicatorFileName,«returnBars»,0,0)*timeFrame/Period()));

//
//
//
//
//
for(i = limit; i >= 0; i--)
{
int shift1 = iBarShift(NULL,timeFrame,Time[i]);
datetime time1 = iTime (NULL,timeFrame,shift1);

//
//
//
//
//
tmBuffer[i] = iCustom(NULL,timeFrame,IndicatorFileName,«calculateTma»,HalfLength,Price,BandsDeviations,0,shift1);
upBuffer[i] = iCustom(NULL,timeFrame,IndicatorFileName,«calculateTma»,HalfLength,Price,BandsDeviations,1,shift1);
dnBuffer[i] = iCustom(NULL,timeFrame,IndicatorFileName,«calculateTma»,HalfLength,Price,BandsDeviations,2,shift1);

upArrow[i] = EMPTY_VALUE;
dnArrow[i] = EMPTY_VALUE;
if(High[i]>upBuffer[i] && Close[i]>Open[i] && (Close[i+1]<=Open[i+1] || High[i+1]<upBuffer[i+1])) upArrow[i] = High[i]+iATR(NULL,0,20,i);
if(Low[i]<dnBuffer[i] && Close[i]<Open[i] && (Close[i+1]>=Open[i+1] || Low[i+1]>dnBuffer[i+1])) dnArrow[i] = Low[i]-iATR(NULL,0,20,i);
// if (High[i+1]>upBuffer[i+1] && Close[i+1]>Open[i+1] && Close[i]<Open[i]) upArrow[i] = High[i]+iATR(NULL,0,20,i);
// if ( Low[i+1]<dnBuffer[i+1] && Close[i+1]<Open[i+1] && Close[i]>Open[i]) dnArrow[i] = Low[i]-iATR(NULL,0,20,i); // fix High — Low

if (timeFrame <= Period() || shift1==iBarShift(NULL,timeFrame,Time[i-1])) continue;
if (!Interpolate) continue;

//
//
//
//
//

for(int n = 1; i+n < Bars && Time[i+n] >= time1; n++) continue;
double factor = 1.0 / n;
for(int k = 1; k < n; k++)
{
tmBuffer[i+k] = k*factor*tmBuffer[i+n] + (1.0-k*factor)*tmBuffer[i];
upBuffer[i+k] = k*factor*upBuffer[i+n] + (1.0-k*factor)*upBuffer[i];
dnBuffer[i+k] = k*factor*dnBuffer[i+n] + (1.0-k*factor)*dnBuffer[i];
}
}

//
//
//
//
//
if (alertsOn)
{
if (alertsOnCurrent)
int forBar = 0;
else forBar = 1;
if (alertsOnHighLow)
{
if (High[forBar] > upBuffer[forBar] && High[forBar+1] < upBuffer[forBar+1]) doAlert(«high penetrated upper bar»);
if (Low[forBar] < dnBuffer[forBar] && Low[forBar+1] > dnBuffer[forBar+1]) doAlert(«low penetrated lower bar»);
}
else
{
if (Close[forBar] > upBuffer[forBar] && Close[forBar+1] < upBuffer[forBar+1]) doAlert(«close penetrated upper bar»);
if (Close[forBar] < dnBuffer[forBar] && Close[forBar+1] > dnBuffer[forBar+1]) doAlert(«close penetrated lower bar»);
}
}

return(0);
}

//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
//
//
//
//
//

void calculateTma(int limit)
{
int i,j,k;
double FullLength = 2.0*HalfLength+1.0;
//
//
//
//
//
for (i=limit; i>=0; i--)
{
double sum = (HalfLength+1)*iMA(NULL,0,1,0,MODE_SMA,Price,i);
double sumw = (HalfLength+1);
for(j=1, k=HalfLength; j<=HalfLength; j++, k--)
{
sum += k*iMA(NULL,0,1,0,MODE_SMA,Price,i+j);
sumw += k;

if (j<=i)
{
sum += k*iMA(NULL,0,1,0,MODE_SMA,Price,i-j);
sumw += k;
}
}
tmBuffer[i] = sum/sumw;

//
//
//
//
//
double diff = iMA(NULL,0,1,0,MODE_SMA,Price,i)-tmBuffer[i];
if (i> (Bars-HalfLength-1)) continue;
if (i==(Bars-HalfLength-1))
{
upBuffer[i] = tmBuffer[i];
dnBuffer[i] = tmBuffer[i];
if (diff>=0)
{
wuBuffer[i] = MathPow(diff,2);
wdBuffer[i] = 0;
}
else
{
wdBuffer[i] = MathPow(diff,2);
wuBuffer[i] = 0;
}
continue;
}
//
//
//
//
//
if(diff>=0)
{
wuBuffer[i] = (wuBuffer[i+1]*(FullLength-1)+MathPow(diff,2))/FullLength;
wdBuffer[i] = wdBuffer[i+1]*(FullLength-1)/FullLength;
}
else
{
wdBuffer[i] = (wdBuffer[i+1]*(FullLength-1)+MathPow(diff,2))/FullLength;
wuBuffer[i] = wuBuffer[i+1]*(FullLength-1)/FullLength;
}
upBuffer[i] = tmBuffer[i] + BandsDeviations*MathSqrt(wuBuffer[i]);
dnBuffer[i] = tmBuffer[i] — BandsDeviations*MathSqrt(wdBuffer[i]);
}
}

//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
//
//
//
//
//

void doAlert(string doWhat)
{
static string previousAlert="";
static datetime previousTime;
string message;

//
//
//
//
//
if (previousAlert!=doWhat || previousTime!=Time[0])
{
previousAlert = doWhat;
previousTime = Time[0];

message= StringConcatenate(Symbol()," at ",TimeToStr(TimeLocal(),TIME_SECONDS)," THA: ",doWhat);
if (alertsMessage) Alert(message);
if (alertsEmail) SendMail(StringConcatenate(Symbol(),«TMA „),message);
if (alertsSound) PlaySound(“alert2.wav»);
}
}

//
//
//
//
//

int stringToTimeFrame(string tfs)
{
for(int l = StringLen(tfs)-1; l >= 0; l--)
{
int k = StringGetChar(tfs,l);
if((k > 96 && k < 123) || (k > 223 && k < 256))
tfs = StringSetChar(tfs, 1, l — 32);
else
if(k > -33 && k < 0)
tfs = StringSetChar(tfs, 1, l + 224);
}
int tf=0;
if (tfs==«M1» || tfs==«1») tf=PERIOD_M1;
if (tfs==«M5» || tfs==«5») tf=PERIOD_M5;
if (tfs==«M15»|| tfs==«15») tf=PERIOD_M15;
if (tfs==«M30»|| tfs==«30») tf=PERIOD_M30;
if (tfs==«H1» || tfs==«60») tf=PERIOD_H1;
if (tfs==«H4» || tfs==«240») tf=PERIOD_H4;
if (tfs==«D1» || tfs==«1440») tf=PERIOD_D1;
if (tfs==«W1» || tfs==«10080») tf=PERIOD_W1;
if (tfs==«MN» || tfs==«43200») tf=PERIOD_MN1;
if (tf==0 || tf<Period()) tf=Period();
return(tf);
}
avatar

  6  gek63 Автор Сообщений: 100

  • 21 апреля 2023, 15:54
+
0
Вот видите как всё просто оказалось. Было бы желание.*hi* 
avatar

  16  ssg Сообщений: 817

  • 21 апреля 2023, 15:57
+
0
Поторопился похвалить. Используйте функцию

code

Сейчас если то что выложено скопировать в метаэдитер в таком виде будет куча ошибок при компиляции. Сами попробуйте. Вы почему так небрежно относитесь к участникам сайта. Что то выложили примитивным образом. При таком отношении к людям ждите соответствующего отношения.
avatar

  16  ssg Сообщений: 817

  • 21 апреля 2023, 17:56
+
0
В меню — файлы, пробовали туда закачать?
avatar

  17  Boris54 Сообщений: 761 - ПенSионер

  • 21 апреля 2023, 15:44
+
0
Почему нажимаешь«ответить», нет скрепки, куда прикреплять файлы?
Только картинки можно крепить.
avatar

  6  gek63 Автор Сообщений: 100

  • 21 апреля 2023, 15:57
+
0
скиньте файлом. то что вы скинули это безобразие
avatar

  34  AM2 Сообщений: 15894 - Андрей

  • 21 апреля 2023, 16:41
+
0
как?
ткните носом
avatar

  6  gek63 Автор Сообщений: 100

  • 23 апреля 2023, 19:09
+
0
dropmefiles.net/ru/me3cK — уже бы давно могли найти этот индюк в сети и скинуть сюда…
ru.files.fm/u/mghvzg8wc — на всякий случай другой обменник.
Редактирован: 22 апреля 2023, 10:48
avatar

  10  FEEX Сообщений: 361 - Владимир

  • 22 апреля 2023, 10:40
+
0
dropmefiles.net/ru/me3cK — уже бы давно могли найти этот индюк в сети и скинуть сюда…
ru.files.fm/u/mghvzg8wc — на всякий случай другой обменник.


первая ссылка битая. вторая выдает:

Предотвращен переход на опасный сайт
avatar

  34  AM2 Сообщений: 15894 - Андрей

  • 22 апреля 2023, 15:13
+
0
это легальный обменник))) Андрей, вам надо что с вашими антивирусами делать)
avatar

  10  FEEX Сообщений: 361 - Владимир

  • 25 апреля 2023, 14:41
+
0
у этих индикаторов буферы одинаковые, остается только поменять имя в советнике
avatar

  34  AM2 Сообщений: 15894 - Андрей

  • 22 апреля 2023, 16:02
+
0
//+------------------------------------------------------------------+
//| TMA+CG.mq4 |
//| mladen |
//| arrowse coded acording to idea presented by rajiv |
//+------------------------------------------------------------------+
#property copyright «rajivxxx»
#property link «rajivxxx@gmail.com / MqlLab.ru»

#property indicator_chart_window
#property indicator_buffers 5
#property indicator_color1 DimGray
#property indicator_color2 Red
#property indicator_color3 LimeGreen
#property indicator_color4 MediumTurquoise
#property indicator_color5 Magenta
#property indicator_style1 STYLE_DOT

//
//
//
//
//

extern string TimeFrame = «current time frame»;
extern int HalfLength = 56;
extern int Price = PRICE_WEIGHTED;
extern double BandsDeviations = 2.0;
extern bool Interpolate = true;
extern bool alertsOn = false;
extern bool alertsOnCurrent = false;
extern bool alertsOnHighLow = true;
extern bool alertsMessage = true;
extern bool alertsSound = false;
extern bool alertsEmail = false;

//
//
//
//
//

double tmBuffer[];
double upBuffer[];
double dnBuffer[];
double wuBuffer[];
double wdBuffer[];
double upArrow[];
double dnArrow[];

//
//
//
//
//

string IndicatorFileName;
bool calculatingTma = false;
bool returningBars = false;
int timeFrame;

//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
//
//
//
//

int init()
{
timeFrame = stringToTimeFrame(TimeFrame);
HalfLength = MathMax(HalfLength,1);
IndicatorBuffers(7);
SetIndexBuffer(0,tmBuffer); SetIndexDrawBegin(0,HalfLength);
SetIndexBuffer(1,upBuffer); SetIndexDrawBegin(1,HalfLength);
SetIndexBuffer(2,dnBuffer); SetIndexDrawBegin(2,HalfLength);
SetIndexBuffer(3,dnArrow); SetIndexStyle(3,DRAW_ARROW); SetIndexArrow(3,233);
SetIndexBuffer(4,upArrow); SetIndexStyle(4,DRAW_ARROW); SetIndexArrow(4,234);
SetIndexBuffer(5,wuBuffer);
SetIndexBuffer(6,wdBuffer);

if (TimeFrame==«calculateTma») { calculatingTma=true; return(0); }
if (TimeFrame==«returnBars») { returningBars=true; return(0); }

IndicatorFileName = WindowExpertName();
return(0);
}
int deinit() { return(0); }

//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
//
//
//
//
//

int start()
{
int counted_bars=IndicatorCounted();
int i,limit;

if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
limit=MathMin(Bars-1,Bars-counted_bars+HalfLength);

if (returningBars) { tmBuffer[0] = limit; return(0); }
if (calculatingTma) { calculateTma(limit); return(0); }
if (timeFrame > Period()) limit = MathMax(limit,MathMin(Bars-1,iCustom(NULL,timeFrame,IndicatorFileName,«returnBars»,0,0)*timeFrame/Period()));

//
//
//
//
//
for(i = limit; i >= 0; i--)
{
int shift1 = iBarShift(NULL,timeFrame,Time[i]);
datetime time1 = iTime (NULL,timeFrame,shift1);

//
//
//
//
//
tmBuffer[i] = iCustom(NULL,timeFrame,IndicatorFileName,«calculateTma»,HalfLength,Price,BandsDeviations,0,shift1);
upBuffer[i] = iCustom(NULL,timeFrame,IndicatorFileName,«calculateTma»,HalfLength,Price,BandsDeviations,1,shift1);
dnBuffer[i] = iCustom(NULL,timeFrame,IndicatorFileName,«calculateTma»,HalfLength,Price,BandsDeviations,2,shift1);

upArrow[i] = EMPTY_VALUE;
dnArrow[i] = EMPTY_VALUE;
if(High[i]>upBuffer[i] && Close[i]>Open[i] && (Close[i+1]<=Open[i+1] || High[i+1]<upBuffer[i+1])) upArrow[i] = High[i]+iATR(NULL,0,20,i);
if(Low[i]<dnBuffer[i] && Close[i]<Open[i] && (Close[i+1]>=Open[i+1] || Low[i+1]>dnBuffer[i+1])) dnArrow[i] = Low[i]-iATR(NULL,0,20,i);
// if (High[i+1]>upBuffer[i+1] && Close[i+1]>Open[i+1] && Close[i]<Open[i]) upArrow[i] = High[i]+iATR(NULL,0,20,i);
// if ( Low[i+1]<dnBuffer[i+1] && Close[i+1]<Open[i+1] && Close[i]>Open[i]) dnArrow[i] = Low[i]-iATR(NULL,0,20,i); // fix High — Low

if (timeFrame <= Period() || shift1==iBarShift(NULL,timeFrame,Time[i-1])) continue;
if (!Interpolate) continue;

//
//
//
//
//

for(int n = 1; i+n < Bars && Time[i+n] >= time1; n++) continue;
double factor = 1.0 / n;
for(int k = 1; k < n; k++)
{
tmBuffer[i+k] = k*factor*tmBuffer[i+n] + (1.0-k*factor)*tmBuffer[i];
upBuffer[i+k] = k*factor*upBuffer[i+n] + (1.0-k*factor)*upBuffer[i];
dnBuffer[i+k] = k*factor*dnBuffer[i+n] + (1.0-k*factor)*dnBuffer[i];
}
}

//
//
//
//
//
if (alertsOn)
{
if (alertsOnCurrent)
int forBar = 0;
else forBar = 1;
if (alertsOnHighLow)
{
if (High[forBar] > upBuffer[forBar] && High[forBar+1] < upBuffer[forBar+1]) doAlert(«high penetrated upper bar»);
if (Low[forBar] < dnBuffer[forBar] && Low[forBar+1] > dnBuffer[forBar+1]) doAlert(«low penetrated lower bar»);
}
else
{
if (Close[forBar] > upBuffer[forBar] && Close[forBar+1] < upBuffer[forBar+1]) doAlert(«close penetrated upper bar»);
if (Close[forBar] < dnBuffer[forBar] && Close[forBar+1] > dnBuffer[forBar+1]) doAlert(«close penetrated lower bar»);
}
}

return(0);
}

//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
//
//
//
//
//

void calculateTma(int limit)
{
int i,j,k;
double FullLength = 2.0*HalfLength+1.0;
//
//
//
//
//
for (i=limit; i>=0; i--)
{
double sum = (HalfLength+1)*iMA(NULL,0,1,0,MODE_SMA,Price,i);
double sumw = (HalfLength+1);
for(j=1, k=HalfLength; j<=HalfLength; j++, k--)
{
sum += k*iMA(NULL,0,1,0,MODE_SMA,Price,i+j);
sumw += k;

if (j<=i)
{
sum += k*iMA(NULL,0,1,0,MODE_SMA,Price,i-j);
sumw += k;
}
}
tmBuffer[i] = sum/sumw;

//
//
//
//
//
double diff = iMA(NULL,0,1,0,MODE_SMA,Price,i)-tmBuffer[i];
if (i> (Bars-HalfLength-1)) continue;
if (i==(Bars-HalfLength-1))
{
upBuffer[i] = tmBuffer[i];
dnBuffer[i] = tmBuffer[i];
if (diff>=0)
{
wuBuffer[i] = MathPow(diff,2);
wdBuffer[i] = 0;
}
else
{
wdBuffer[i] = MathPow(diff,2);
wuBuffer[i] = 0;
}
continue;
}
//
//
//
//
//
if(diff>=0)
{
wuBuffer[i] = (wuBuffer[i+1]*(FullLength-1)+MathPow(diff,2))/FullLength;
wdBuffer[i] = wdBuffer[i+1]*(FullLength-1)/FullLength;
}
else
{
wdBuffer[i] = (wdBuffer[i+1]*(FullLength-1)+MathPow(diff,2))/FullLength;
wuBuffer[i] = wuBuffer[i+1]*(FullLength-1)/FullLength;
}
upBuffer[i] = tmBuffer[i] + BandsDeviations*MathSqrt(wuBuffer[i]);
dnBuffer[i] = tmBuffer[i] — BandsDeviations*MathSqrt(wdBuffer[i]);
}
}

//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
//
//
//
//
//

void doAlert(string doWhat)
{
static string previousAlert="";
static datetime previousTime;
string message;

//
//
//
//
//
if (previousAlert!=doWhat || previousTime!=Time[0])
{
previousAlert = doWhat;
previousTime = Time[0];

message= StringConcatenate(Symbol()," at ",TimeToStr(TimeLocal(),TIME_SECONDS)," THA: ",doWhat);
if (alertsMessage) Alert(message);
if (alertsEmail) SendMail(StringConcatenate(Symbol(),«TMA „),message);
if (alertsSound) PlaySound(“alert2.wav»);
}
}

//
//
//
//
//

int stringToTimeFrame(string tfs)
{
for(int l = StringLen(tfs)-1; l >= 0; l--)
{
int k = StringGetChar(tfs,l);
if((k > 96 && k < 123) || (k > 223 && k < 256))
tfs = StringSetChar(tfs, 1, l — 32);
else
if(k > -33 && k < 0)
tfs = StringSetChar(tfs, 1, l + 224);
}
int tf=0;
if (tfs==«M1» || tfs==«1») tf=PERIOD_M1;
if (tfs==«M5» || tfs==«5») tf=PERIOD_M5;
if (tfs==«M15»|| tfs==«15») tf=PERIOD_M15;
if (tfs==«M30»|| tfs==«30») tf=PERIOD_M30;
if (tfs==«H1» || tfs==«60») tf=PERIOD_H1;
if (tfs==«H4» || tfs==«240») tf=PERIOD_H4;
if (tfs==«D1» || tfs==«1440») tf=PERIOD_D1;
if (tfs==«W1» || tfs==«10080») tf=PERIOD_W1;
if (tfs==«MN» || tfs==«43200») tf=PERIOD_MN1;
if (tf==0 || tf<Period()) tf=Period();
return(tf);
}
avatar

  4  tesc Сообщений: 3

  • 23 апреля 2023, 15:21
+
0
А во теперь это скопируйте в Метаэдитер и скомпилируйте. Как не понимаете, что синтаксис Метаэдитера и сообщения разные. Прикрепляйте через code
<code>


<code>//+------------------------------------------------------------------+
//|                                  TriangularMA centered bands.mq4 |
//|                                                           mladen |
//| forex-tsd elite section only                                     |
//+------------------------------------------------------------------+
#property copyright "mladen"
#property link      "mladenfx@gmail.com"
</code>


А так как выложил alex30774 при копировании и компеляции ошибок не будет! Вы хоть проверяйте что другим предлагаете. Или это преднамеренно делаете?
Редактирован: 23 апреля 2023, 22:46
avatar

  16  ssg Сообщений: 817

  • 23 апреля 2023, 22:40
+
+1
avatar

  4  tesc Сообщений: 3

  • 23 апреля 2023, 15:25
+
0
Если вы на том сайте зарегистрированны, то это не значит, что идругие тоже на нём зарегистрированны.Программист поленится регистрироваться.
avatar

  19  alex30774 Сообщений: 716

  • 23 апреля 2023, 18:41
+
0
//+------------------------------------------------------------------+
//|                                                       TMA+CG.mq4 |
//|                                                           mladen |
//| arrowse coded acording to idea presented by rajiv                |
//+------------------------------------------------------------------+
#property copyright "rajivxxx"
#property link      "rajivxxx@gmail.com / MqlLab.ru"

#property indicator_chart_window
#property indicator_buffers 5
#property indicator_color1  DimGray
#property indicator_color2  Red
#property indicator_color3  LimeGreen
#property indicator_color4  MediumTurquoise
#property indicator_color5  Magenta
#property indicator_style1  STYLE_DOT

//
//
//
//
//

extern string TimeFrame       = "current time frame";
extern int    HalfLength      = 56;
extern int    Price           = PRICE_WEIGHTED;
extern double BandsDeviations = 2.0;
extern bool   Interpolate     = true;
extern bool   alertsOn        = false;
extern bool   alertsOnCurrent = false;
extern bool   alertsOnHighLow = true;
extern bool   alertsMessage   = true;
extern bool   alertsSound     = false;
extern bool   alertsEmail     = false;

//
//
//
//
//

double tmBuffer[];
double upBuffer[];
double dnBuffer[];
double wuBuffer[];
double wdBuffer[];
double upArrow[];
double dnArrow[];

//
//
//
//
//

string IndicatorFileName;
bool   calculatingTma = false;
bool   returningBars  = false;
int    timeFrame;

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
//
//
//
//

int init()
{
   timeFrame  = stringToTimeFrame(TimeFrame);
   HalfLength = MathMax(HalfLength,1);
   IndicatorBuffers(7);
         SetIndexBuffer(0,tmBuffer);  SetIndexDrawBegin(0,HalfLength);
         SetIndexBuffer(1,upBuffer);  SetIndexDrawBegin(1,HalfLength);
         SetIndexBuffer(2,dnBuffer);  SetIndexDrawBegin(2,HalfLength);
         SetIndexBuffer(3,dnArrow);   SetIndexStyle(3,DRAW_ARROW); SetIndexArrow(3,233);
         SetIndexBuffer(4,upArrow);   SetIndexStyle(4,DRAW_ARROW); SetIndexArrow(4,234);
         SetIndexBuffer(5,wuBuffer);
         SetIndexBuffer(6,wdBuffer);

         if (TimeFrame=="calculateTma")  { calculatingTma=true; return(0); }
         if (TimeFrame=="returnBars")    { returningBars=true;  return(0); }

   
   IndicatorFileName = WindowExpertName();
   return(0);
}
int deinit() { return(0); }

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
//
//
//
//
//
avatar

  19  alex30774 Сообщений: 716

  • 23 апреля 2023, 18:46
+
0
int start()
{
   int counted_bars=IndicatorCounted();
   int i,limit;

   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
           limit=MathMin(Bars-1,Bars-counted_bars+HalfLength);

           if (returningBars)  { tmBuffer[0] = limit; return(0); }
           if (calculatingTma) { calculateTma(limit); return(0); }
           if (timeFrame > Period()) limit = MathMax(limit,MathMin(Bars-1,iCustom(NULL,timeFrame,IndicatorFileName,"returnBars",0,0)*timeFrame/Period()));

   //
   //
   //
   //
   //
   
 	for(i = limit; i >= 0; i--)
   {
      int      shift1 = iBarShift(NULL,timeFrame,Time[i]);
      datetime time1  = iTime    (NULL,timeFrame,shift1);

      //
      //
      //
      //
      //
      
         tmBuffer[i] = iCustom(NULL,timeFrame,IndicatorFileName,"calculateTma",HalfLength,Price,BandsDeviations,0,shift1);
         upBuffer[i] = iCustom(NULL,timeFrame,IndicatorFileName,"calculateTma",HalfLength,Price,BandsDeviations,1,shift1);
         dnBuffer[i] = iCustom(NULL,timeFrame,IndicatorFileName,"calculateTma",HalfLength,Price,BandsDeviations,2,shift1);

         upArrow[i] = EMPTY_VALUE;
         dnArrow[i] = EMPTY_VALUE;            
         if(High[i]>upBuffer[i] && Close[i]>Open[i] && (Close[i+1]<=Open[i+1] || High[i+1]<upBuffer[i+1])) upArrow[i] = High[i]+iATR(NULL,0,20,i);
         if(Low[i]<dnBuffer[i] && Close[i]<Open[i] && (Close[i+1]>=Open[i+1] || Low[i+1]>dnBuffer[i+1])) dnArrow[i] = Low[i]-iATR(NULL,0,20,i);
         
          //  if (High[i+1]>upBuffer[i+1] && Close[i+1]>Open[i+1] && Close[i]<Open[i]) upArrow[i] = High[i]+iATR(NULL,0,20,i);
          //  if ( Low[i+1]<dnBuffer[i+1] && Close[i+1]<Open[i+1] && Close[i]>Open[i]) dnArrow[i] = Low[i]-iATR(NULL,0,20,i); // fix High - Low

         if (timeFrame <= Period() || shift1==iBarShift(NULL,timeFrame,Time[i-1])) continue;
         if (!Interpolate) continue;

      //
      //
      //
      //
      //

         for(int n = 1; i+n < Bars && Time[i+n] >= time1; n++) continue;
         double factor = 1.0 / n;
         for(int k = 1; k < n; k++)
            {
               tmBuffer[i+k] = k*factor*tmBuffer[i+n] + (1.0-k*factor)*tmBuffer[i];
               upBuffer[i+k] = k*factor*upBuffer[i+n] + (1.0-k*factor)*upBuffer[i];
               dnBuffer[i+k] = k*factor*dnBuffer[i+n] + (1.0-k*factor)*dnBuffer[i];
            }               
   }

   //
   //
   //
   //
   //
   
   if (alertsOn)
   {
      if (alertsOnCurrent)
            int forBar = 0;
      else      forBar = 1;
      if (alertsOnHighLow)       
      {
         if (High[forBar] > upBuffer[forBar] && High[forBar+1] < upBuffer[forBar+1]) doAlert("high penetrated upper bar");
         if (Low[forBar]  < dnBuffer[forBar] && Low[forBar+1]  > dnBuffer[forBar+1]) doAlert("low penetrated lower bar");
      }
      else
      {
         if (Close[forBar] > upBuffer[forBar] && Close[forBar+1] < upBuffer[forBar+1]) doAlert("close penetrated upper bar");
         if (Close[forBar] < dnBuffer[forBar] && Close[forBar+1] > dnBuffer[forBar+1]) doAlert("close penetrated lower bar");
      }
   } 

   return(0);
}

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
//
//
//
//
//

Редактирован: 23 апреля 2023, 18:49
avatar

  19  alex30774 Сообщений: 716

  • 23 апреля 2023, 18:48
+
0
//----------------------------
void calculateTma(int limit)
{
   int i,j,k;
   double FullLength = 2.0*HalfLength+1.0;
   
   //
   //
   //
   //
   //
   
   for (i=limit; i>=0; i--)
   {
      double sum  = (HalfLength+1)*iMA(NULL,0,1,0,MODE_SMA,Price,i);
      double sumw = (HalfLength+1);
      for(j=1, k=HalfLength; j<=HalfLength; j++, k--)
      {
         sum  += k*iMA(NULL,0,1,0,MODE_SMA,Price,i+j);
         sumw += k;

         if (j<=i)
         {
            sum  += k*iMA(NULL,0,1,0,MODE_SMA,Price,i-j);
            sumw += k;
         }
      }
      tmBuffer[i] = sum/sumw;

      //
      //
      //
      //
      //
            
         double diff = iMA(NULL,0,1,0,MODE_SMA,Price,i)-tmBuffer[i];
         if (i> (Bars-HalfLength-1)) continue;
         if (i==(Bars-HalfLength-1))
         {
            upBuffer[i] = tmBuffer[i];
            dnBuffer[i] = tmBuffer[i];
            if (diff>=0)
               {
                  wuBuffer[i] = MathPow(diff,2);
                  wdBuffer[i] = 0;
               }
            else
               {               
                  wdBuffer[i] = MathPow(diff,2);
                  wuBuffer[i] = 0;
               }                  
            continue;
         }
      
         //
         //
         //
         //
         //
         
         if(diff>=0)
            {
               wuBuffer[i] = (wuBuffer[i+1]*(FullLength-1)+MathPow(diff,2))/FullLength;
               wdBuffer[i] =  wdBuffer[i+1]*(FullLength-1)/FullLength;
            }
         else
            {
               wdBuffer[i] = (wdBuffer[i+1]*(FullLength-1)+MathPow(diff,2))/FullLength;
               wuBuffer[i] =  wuBuffer[i+1]*(FullLength-1)/FullLength;
            }
         upBuffer[i] = tmBuffer[i] + BandsDeviations*MathSqrt(wuBuffer[i]);
         dnBuffer[i] = tmBuffer[i] - BandsDeviations*MathSqrt(wdBuffer[i]);
   }
}
    


//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
//
//
//
//
//

void doAlert(string doWhat)
{
   static string   previousAlert="";
   static datetime previousTime;
   string message;

   //
   //
   //
   //
   //
   
   if (previousAlert!=doWhat || previousTime!=Time[0]) 
   {
      previousAlert = doWhat;
      previousTime  = Time[0];

      message= StringConcatenate(Symbol()," at ",TimeToStr(TimeLocal(),TIME_SECONDS)," THA : ",doWhat);
         if (alertsMessage) Alert(message);
         if (alertsEmail)   SendMail(StringConcatenate(Symbol(),"TMA "),message);
         if (alertsSound)   PlaySound("alert2.wav");
    }
}

//
//
//
//
//

int stringToTimeFrame(string tfs)
{
   for(int l = StringLen(tfs)-1; l >= 0; l--)
   {
      int k = StringGetChar(tfs,l);
          if((k > 96 && k < 123) || (k > 223 && k < 256))
               tfs = StringSetChar(tfs, 1, l - 32);
          else 
              if(k > -33 && k < 0)
                  tfs = StringSetChar(tfs, 1, l + 224);
   }
   int tf=0;
         if (tfs=="M1" || tfs=="1")     tf=PERIOD_M1;
         if (tfs=="M5" || tfs=="5")     tf=PERIOD_M5;
         if (tfs=="M15"|| tfs=="15")    tf=PERIOD_M15;
         if (tfs=="M30"|| tfs=="30")    tf=PERIOD_M30;
         if (tfs=="H1" || tfs=="60")    tf=PERIOD_H1;
         if (tfs=="H4" || tfs=="240")   tf=PERIOD_H4;
         if (tfs=="D1" || tfs=="1440")  tf=PERIOD_D1;
         if (tfs=="W1" || tfs=="10080") tf=PERIOD_W1;
         if (tfs=="MN" || tfs=="43200") tf=PERIOD_MN1;
         if (tf==0 || tf<Period())      tf=Period();
   return(tf);
} 
avatar

  19  alex30774 Сообщений: 716

  • 23 апреля 2023, 18:49

Зарегистрируйтесь или авторизуйтесь, чтобы оставить комментарий
Начать торговлю с Альпари