|
Programmierung MQL5 Hier gehts rund ums Programmieren in MQL5. |
|
Themen-Optionen | Thema durchsuchen | Ansicht |
|
|||
akustische Benachrichtigung MACD-Signal
Hallo,
würde sehr gerne eine akustische Benachrichtigung erhalten, wenn der MACD ein Kauf- bzw. Verkaufssignal gibt. Gibt es da bereits etwas bzw. wie kann man das implementieren? Grüße Antomi |
|
|||
Meinst du so was ?
Code:
extern bool alerts.On = false; extern bool alerts.OnCurrent = false; extern bool alerts.Message = true; extern bool alerts.Sound = false; extern bool alerts.Email = false; void doAlert(string doWhat) { static string previousAlert="nothing"; static datetime previousTime; string message; if (previousAlert != doWhat || previousTime != Time[0]) { previousAlert = doWhat; previousTime = Time[0]; // // // // // message = StringConcatenate(Symbol()," at ",TimeToStr(TimeLocal(),TIME_SECONDS)," Aroon oscillator - ",doWhat); if (alerts.Message) Alert(message); if (alerts.Email) SendMail("Arron oscillator",message); if (alerts.Sound) PlaySound("alert2.wav"); } |
|
|||
akustische Benachrichtigung MACD-Signal
Wahrscheinlich. Würde gerne einen eigenen Sound integrieren.
Bin leider völlig unerfahren bei der Programmierung der Indikatoren. |
|
|||
Na dann
Schick mir dein Sound und den MACD wo der rein soll
|
|
|||
Alarm für MACD
Das ist ja super, ganz herzlichen Dank!!
Zunächst der Indikator. Sobald die Farbe der Punkte umspringt, soll das Signal abgespielt werden. Jetzt mus sich noch versuchen die mp3-Datei rüber zuschicken. Das System scheint mp3-Dateien nicht zu akzeptieren. Ich spiele noch etwas damit herum, ob ich es irgendwie hin bekomme. |
|
|||
Alarm für MACD
Okay, musste die mp3-Dateien als ZIP-Datei verpacken.
Hoffe, dass es jetzt klappt. Bin echt gespannt, wie Du das hin bekommst und wie es funktioniert. DANKE!! |
|
|||
Zitat:
Hoffe es klappt so kann ich nicht testen da es Mq5 ist bin nur Mq4 Code:
//+------------------------------------------------------------------+ //| BB MACD | //| Copyright © 2009, EarnForex | //| http://www.earnforex.com/ | //+------------------------------------------------------------------+ #property copyright "Copyright © 2009, EarnForex" #property link "http://www.earnforex.com" #property version "1.01" #property description "BB MACD - Bollinger Bands with MACD mutation based on Moving Averages" #property description "and Standard Deviation indicators." //---- indicator settings #property indicator_separate_window #property indicator_buffers 8 #property indicator_plots 3 #property indicator_color1 Lime, Magenta //Up/down bullets #property indicator_type1 DRAW_COLOR_ARROW #property indicator_style1 STYLE_SOLID #property indicator_width1 1 #property indicator_color2 Blue //Upperband #property indicator_type2 DRAW_LINE #property indicator_style2 STYLE_SOLID #property indicator_width2 1 #property indicator_color3 Red //Lowerband #property indicator_type3 DRAW_LINE #property indicator_style3 STYLE_SOLID #property indicator_width3 1 //---- indicator parameters input int FastLen = 12; input int SlowLen = 26; input int Length = 10; input int barsCount = 400; input double StDv = 2.5; //---- indicator buffers double ExtMapBuffer1[]; // bbMacd double ExtMapBuffer2[]; // bbMacd Color double ExtMapBuffer3[]; // Upperband Line double ExtMapBuffer4[]; // Lowerband Line double ExtMapBuffer5[]; // Data for "iMAOnArray()" double MABuff1[]; double MABuff2[]; double bbMacd[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ void OnInit() { IndicatorSetString(INDICATOR_SHORTNAME, "BB MACD(" + IntegerToString(FastLen) + "," + IntegerToString(SlowLen) + "," + IntegerToString(Length) + ")"); IndicatorSetInteger(INDICATOR_DIGITS, _Digits + 1); //---- indicator buffers mapping SetIndexBuffer(0, ExtMapBuffer1, INDICATOR_DATA); SetIndexBuffer(1, ExtMapBuffer2, INDICATOR_COLOR_INDEX); SetIndexBuffer(2, ExtMapBuffer3, INDICATOR_DATA); SetIndexBuffer(3, ExtMapBuffer4, INDICATOR_DATA); SetIndexBuffer(4, ExtMapBuffer5, INDICATOR_CALCULATIONS); SetIndexBuffer(5, MABuff1, INDICATOR_CALCULATIONS); SetIndexBuffer(6, MABuff2, INDICATOR_CALCULATIONS); SetIndexBuffer(7, bbMacd, INDICATOR_CALCULATIONS); //Set the correct order: 0 is the latest, N - is the oldest ArraySetAsSeries(ExtMapBuffer1, true); ArraySetAsSeries(ExtMapBuffer2, true); ArraySetAsSeries(ExtMapBuffer3, true); ArraySetAsSeries(ExtMapBuffer4, true); ArraySetAsSeries(ExtMapBuffer5, true); ArraySetAsSeries(MABuff1, true); ArraySetAsSeries(MABuff2, true); ArraySetAsSeries(bbMacd, true); PlotIndexSetInteger(0, PLOT_ARROW, 108); //---- name for DataWindow and indicator subwindow label PlotIndexSetString(0, PLOT_LABEL, "bbMacd"); PlotIndexSetString(2, PLOT_LABEL, "Upperband"); PlotIndexSetString(3, PLOT_LABEL, "Lowerband"); } //+------------------------------------------------------------------+ //| Custom BB_MACD | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { int limit; int counted_bars = prev_calculated; if (counted_bars < 0) return(-1); if (counted_bars > 0) counted_bars--; if (barsCount > 0) limit = MathMin((rates_total - counted_bars), barsCount); else limit = rates_total - counted_bars; //---- int myMA = iMA(NULL, 0, FastLen, 0, MODE_EMA, PRICE_CLOSE); if (CopyBuffer(myMA, 0, 0, rates_total, MABuff1) != rates_total) return(0); myMA = iMA(NULL, 0, SlowLen, 0, MODE_EMA, PRICE_CLOSE); if (CopyBuffer(myMA, 0, 0, rates_total, MABuff2) != rates_total) return(0); for (int i = 0; i < limit; i++) bbMacd[i] = MABuff1[i] - MABuff2[i]; //---- CalculateEMA(limit - 1, Length, bbMacd); for (int i = 0; i < limit; i++) { double avg = ExtMapBuffer5[i]; // MA on Array double sDev = StdDevFunc(i, Length, bbMacd); //StdDev on Array ExtMapBuffer1[i] = bbMacd[i]; // bbMacd if (bbMacd[i] > bbMacd[i + 1]) ExtMapBuffer2[i] = 0; PlaySound ("LONG.mp3"); // Uptrend else if (bbMacd[i] < bbMacd[i + 1]) ExtMapBuffer2[i] = 1; PlaySound ("SHORT.mp3"); // Downtrend ExtMapBuffer3[i] = avg + (StDv * sDev); // Upperband ExtMapBuffer4[i] = avg - (StDv * sDev); // Lowerband } return(rates_total); } //+------------------------------------------------------------------+ //| Exponential Moving Average | //| Fills the buffer array with EMA values. | //+------------------------------------------------------------------+ void CalculateEMA(int begin, int period, const double &price[]) { double SmoothFactor = 2.0 / (1.0 + period); int start; //First time if (ExtMapBuffer5[ArrayMaximum(ExtMapBuffer5)] <= 0) { ExtMapBuffer5[begin] = price[begin]; start = begin - 1; } else start = begin; for(int i = start; i >= 0; i--) ExtMapBuffer5[i] = price[i] * SmoothFactor + ExtMapBuffer5[i + 1] * (1.0 - SmoothFactor); } //+------------------------------------------------------------------+ //| Calculate Standard Deviation | //| Returns StdDev for the given position (bar). | //+------------------------------------------------------------------+ double StdDevFunc(int position, int period, const double &price[]) { double dTmp = 0.0; for (int i = 0; i < period; i++) dTmp += MathPow(price[position + i] - ExtMapBuffer5[position], 2); dTmp = MathSqrt(dTmp / period); return(dTmp); } //+------------------------------------------------------------------+ |
|
|||
Alarm für MACD
Vielen Dank für die schnelle Bearbeitung.
Bin gerade bei der Installation. Frage: wo muss ich die Sound-Dateien hinterlegen? MT5 muss ja irgendwie darauf zugreifen können. |
|
|||
eEigendlich damit rein H:\Program Files (x86)\Admiral Markets MT4\Sounds
|
|
|||
Alarm für MACD
Leider funktioniert es so nicht. MT5 startet nicht bzw. hängt sich auf.
Habe den BB_MACD zunächst ohne Sound installiert aber bei der Kompilierung treten zwei Fehler auf. Erstens bei der Bezeichnung. In der zweiten Zeile muss der BB_MACD umbenannt werden. Habe ihn mal BB_Sound_MACD getauft. Nehme an, dass dieser Name in Zeile 2 muss. Den Fehler in Zeile 123 sehe ich nicht, habe Dir ein Image mitgeschickt. |
Lesezeichen |
Stichworte |
akustisches signal, sound abspielen, sound alert |
|
|