| Нужен алерт к индикатору Laguerre |
//+------------------------------------------------------------------+
//| Laguerre.mq4 |
//| Emerald King |
//| mailto:info@emerald-king.com |
//+------------------------------------------------------------------+
#property copyright "Emerald King"
#property link "mailto:info@emerald-king.com"
#property indicator_separate_window
#property indicator_color1 Magenta
#property indicator_level2 0.75
#property indicator_level3 0.45
#property indicator_level4 0.15
//---- input parameters
extern double gamma=0.7;
extern int CountBars=950;
double L0 = 0;
double L1 = 0;
double L2 = 0;
double L3 = 0;
double L0A = 0;
double L1A = 0;
double L2A = 0;
double L3A = 0;
double LRSI = 0;
double CU = 0;
double CD = 0;
double val1[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
//----
SetIndexBuffer(0,val1);
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//---- TODO: add your code here
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
if (CountBars>Bars) CountBars=Bars;
SetIndexDrawBegin(0,Bars-CountBars);
int i;
int counted_bars=IndicatorCounted();
//if(CountBars<=Lookback) return(0);
//---- initial zero
//if(counted_bars<1)
//{
// for(i=1;i<=Lookback;i++) val1[CountBars-i]=0.0;
//}
i=CountBars-1;
while(i>=0)
{
L0A = L0;
L1A = L1;
L2A = L2;
L3A = L3;
L0 = (1 - gamma)*Close[i] + gamma*L0A;
L1 = - gamma *L0 + L0A + gamma *L1A;
L2 = - gamma *L1 + L1A + gamma *L2A;
L3 = - gamma *L2 + L2A + gamma *L3A;
CU = 0;
CD = 0;
if (L0 >= L1) CU = L0 - L1; else CD = L1 - L0;
if (L1 >= L2) CU = CU + L1 - L2; else CD = CD + L2 - L1;
if (L2 >= L3) CU = CU + L2 - L3; else CD = CD + L3 - L2;
if (CU + CD != 0) LRSI = CU / (CU + CD);
val1[i] = LRSI;
i--;
}
return(0);
}
//+------------------------------------------------------------------+
22 мая 2015
|
22 мая 2015
|
Комментарии (19)
18 Andrju81 Сообщений: 245 - Андрей
А это мой простяцкий код: www.opentraders.ru/downloads/746/
35 AM2 Сообщений: 16665 - Андрей
27 Oxy Сообщений: 3430 - ..ιllιlι.lι.ιllι.ιlι..
35 AM2 Сообщений: 16665 - Андрей
27 Oxy Сообщений: 3430 - ..ιllιlι.lι.ιllι.ιlι..
35 AM2 Сообщений: 16665 - Андрей
13 Buff Сообщений: 402 - Артем
35 AM2 Сообщений: 16665 - Андрей
<code>//+------------------------------------------------------------------+ //| Laguerre+Alerts+Arrow.mq4 | //| Copyright © 2015, Андрей Владимирович Носарь | //| | //+------------------------------------------------------------------+ #property copyright "Copyright © 2015, Андрей Владимирович Носарь" #property version "1.00" #property description "Помните!!! Торговля на финансовых рынках связана с высоким уровнем риска." #property description "Клиент принимает на себя риски, связанные с неисправностями программного" #property description "обеспечения,телекоммуникационного оборудования и иными техническими проблемами." #property description "Разработчик не несет ответственности за убытки, понесенные Клиентом вследствие незнания." #property strict #property indicator_chart_window #property indicator_separate_window #property indicator_buffers 1 #property indicator_color1 Red #property indicator_level2 0.75 #property indicator_level3 0.45 #property indicator_level4 0.15 extern string _1_Levels = " Настройки уровней для сигналов "; extern double Level_Up = 0.15; // Уровень покупки extern double Level_Down = 0.75; // Уровень продажи extern string _P_WhereOutput = " Куда выводить сообщения"; extern bool UseAlert = True; // Использовать диалоговое окно extern bool UseSendMail = True; // Посылать электронное письмо extern bool UseSendPush = False; // Посылать сообщение на мобильные терминалы extern bool UseSound = False; // Использовать звук extern string BvUpSound = "news.wav"; // Звук бычьего тренда extern string BvDownSound = "email.wav";// Звук медвежьего тренда extern bool Arrow = True; // Ставить стрелки на сигналах int shift = 0; // Cигналный бар: 0 - на текущем 1 - на закрытом int timeee; // Внутренняя переменная string nameInd; //---- input parameters extern double gamma=0.7; extern int CountBars=950; double L0 = 0; double L1 = 0; double L2 = 0; double L3 = 0; double L0A = 0; double L1A = 0; double L2A = 0; double L3A = 0; double LRSI = 0; double CU = 0; double CD = 0; double val1[]; void SetArrow(int cd, color cl, string nm=" ", datetime t1=0, double p1=0, int sz=3) { if (nm==" ") nm=DoubleToStr(Time[0], 0); if (t1<=0) t1=Time[0]; if (p1<=0) p1=Bid; nameInd=WindowExpertName( ); int wind=WindowFind(nameInd); if (wind==-1)wind=0; if (ObjectFind(nm)<0) ObjectCreate(nm, OBJ_ARROW, wind, 0,0); ObjectSet(nm, OBJPROP_TIME1 , t1); ObjectSet(nm, OBJPROP_PRICE1 , p1); ObjectSet(nm, OBJPROP_ARROWCODE, cd); ObjectSet(nm, OBJPROP_COLOR , cl); ObjectSet(nm, OBJPROP_WIDTH , sz); } void AlertArrow(string text=" ",int arrowdir=0) { nameInd=WindowExpertName( ); int wind=WindowFind(nameInd); if (wind==-1)wind=0; ObjectCreate("",OBJ_LABEL,wind,0,0); ObjectSetText("","",10,"Arial Bold",Red); ObjectSet("",OBJPROP_CORNER,2); ObjectSet("",OBJPROP_XDISTANCE,200); ObjectSet("",OBJPROP_YDISTANCE,10); if(UseAlert) Alert(text); if(Arrow) if (arrowdir==1) SetArrow(241,Blue,nameInd+DoubleToStr(Time[shift],0),Time[shift],Low[shift]); if(Arrow) if (arrowdir==2) SetArrow(242,Red,nameInd+DoubleToStr(Time[shift],0),Time[shift],High[shift]); if (!IsTesting())if(UseSendMail) SendMail(text, text); if (!IsTesting())if(UseSendPush) SendNotification(text); } //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators //---- SetIndexBuffer(0,val1); return(0); } //+------------------------------------------------------------------+ //| Custor indicator deinitialization function | //+------------------------------------------------------------------+ void deinit() { Comment(" "); nameInd=WindowExpertName( ); int obj_total=ObjectsTotal(); for(int i=0;i<obj_total;i++) { string name=nameInd+DoubleToStr(Time[i],0); ObjectDelete(name); } } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { if (CountBars>Bars) CountBars=Bars; SetIndexDrawBegin(0,Bars-CountBars); int i; int counted_bars=IndicatorCounted(); //if(CountBars<=Lookback) return(0); //---- initial zero //if(counted_bars<1) //{ // for(i=1;i<=Lookback;i++) val1[CountBars-i]=0.0; //} i=CountBars-1; while(i>=0) { L0A = L0; L1A = L1; L2A = L2; L3A = L3; L0 = (1 - gamma)*Close[i] + gamma*L0A; L1 = - gamma *L0 + L0A + gamma *L1A; L2 = - gamma *L1 + L1A + gamma *L2A; L3 = - gamma *L2 + L2A + gamma *L3A; CU = 0; CD = 0; if (L0 >= L1) CU = L0 - L1; else CD = L1 - L0; if (L1 >= L2) CU = CU + L1 - L2; else CD = CD + L2 - L1; if (L2 >= L3) CU = CU + L2 - L3; else CD = CD + L3 - L2; if (CU + CD != 0) LRSI = CU / (CU + CD); val1[i] = LRSI; i--; } if(timeee!=Time[0] && val1[2] < Level_Up && val1[1] >= Level_Up) { AlertArrow(Symbol()+" "+IntegerToString(Period())+" "+ nameInd+" UP Trend ",1); timeee=(int)Time[0]; if (!IsTesting()) if (UseSound) PlaySound(BvUpSound); } if(timeee!=Time[0] && val1[2] > Level_Down && val1[1] <= Level_Down) { AlertArrow(Symbol()+" "+IntegerToString(Period())+" "+ nameInd+" Down Trend ",2); timeee=(int)Time[0]; if (!IsTesting()) if (UseSound) PlaySound(BvDownSound); } return(0); } //+------------------------------------------------------------------+</code>Редактирован: 31 марта 2017, 20:4718 Andrju81 Сообщений: 245 - Андрей
27 Oxy Сообщений: 3430 - ..ιllιlι.lι.ιllι.ιlι..
18 Andrju81 Сообщений: 245 - Андрей
35 AM2 Сообщений: 16665 - Андрей
27 Oxy Сообщений: 3430 - ..ιllιlι.lι.ιllι.ιlι..
18 Andrju81 Сообщений: 245 - Андрей
27 Oxy Сообщений: 3430 - ..ιllιlι.lι.ιllι.ιlι..
35 AM2 Сообщений: 16665 - Андрей
получилось!
27 Oxy Сообщений: 3430 - ..ιllιlι.lι.ιllι.ιlι..
18 Andrju81 Сообщений: 245 - Андрей
27 Oxy Сообщений: 3430 - ..ιllιlι.lι.ιllι.ιlι..
Зарегистрируйтесь или авторизуйтесь, чтобы оставить комментарий