You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
-------------------------------
SpeechText Function doesnt speak with the SPEECH_NATIVE. Even in the alertwindow, there is only ENGLISH can be selected in the Language dropdownlistbox once I select the action is VOICE.
//+------------------------------------------------------------------+ //| VoiceQuotes.mq4 | //| | //| | //+------------------------------------------------------------------+ #property copyright "[email]simonchan@tom.com[/email]" #property link "www.chnstock.com" //---- input parameters extern bool Enabled=true; extern bool SpeakEnglish=true; extern bool UseBid=true; extern int SpeakInterval=10; extern bool SpeakSymbol=true; extern int SpeakDelta=1; extern double Range1Min=0.0; extern double Range1Max=99999.9; extern double Range2Min=0.0; extern double Range2Max=0.0; extern bool InitSpeak=false; extern bool LogMessage=false; double LastPrice = 0; int LastSpeakTime = 0; int i_Language = SPEECH_ENGLISH ; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ double GetCurrPrice() { double p; if (UseBid) { p = Bid; } else { p = Ask; } return (p); } string CurrencyGetName(string c) { if (c == "USD") { return ("US Dollar"); } else if (c == "EUR") { return ("EURO"); } else if (c == "GBP") { return ("British Pound"); } else if (c == "JPY") { return ("Japan"); } else if (c == "CAD") { return ("Canada"); } else if (c == "CHF") { return ("Swiss"); } else if (c == "AUD") { return ("Australia"); } else if (c == "SGD") { return ("Sigapore"); } else if (c == "NZD") { return ("Newzeland"); } else if (c == "HKD") { return ("Hongkong Dollar"); } else if (c == "CNY") { return ("RMB"); } else { return (""); } } string GetSymbolName(string name) { string str; str = ""; if (StringLen(name) != 6) { if (name == "USDX" || name == "_DXY") { str = str+"Dollar Index"; } else if (name == "GOLD") { str = str+"Gold"; } } else { string left, right; left = CurrencyGetName(StringSubstr(name, 0, 3)); right = CurrencyGetName(StringSubstr(name, 3, 3)); if (left != "" && right != "") { str = str+(left + " vs " + right); } } return (str); } string GetSpeechText() { string str; str = ""; if (SpeakSymbol) { str = str + GetSymbolName(Symbol()); if (str != "") { if (UseBid) { str = str+"Bid price"; } else { str = str+"Ask price"; } } } double p; p = GetCurrPrice(); str = str+DoubleToStr(p, Digits); if (SpeakDelta != 0 ) { int n = MathPow(10, Digits); double diff = MathAbs(p*n-LastPrice*n); if (diff >= SpeakDelta) { if (p > LastPrice) { str = str+"Move Up "+DoubleToStr(diff,0)+"pips"; } else { str = str+"Drop down "+DoubleToStr(diff,0)+"pips"; } } // Print(LastPrice + "->" + p + " : " + diff); } LastPrice = p; if (LogMessage) Print (str); return (str); } int init() { //---- //---- LastPrice = GetCurrPrice(); LastSpeakTime = 0; if (SpeakEnglish == false) { i_Language = SPEECH_NATIVE; } if (InitSpeak) { string str; str = "Start " + GetSymbolName(Symbol()) + " voice quotes,"; str = str + "Current price is " + DoubleToStr(LastPrice, Digits); SpeechText(str,i_Language); } return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- if (InitSpeak) { string str; str = "Stop " + GetSymbolName(Symbol()) + " voice quotes."; SpeechText(str,i_Language); } //---- return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { //---- if (!Enabled) return (0); if (MathAbs(GetTickCount() - LastSpeakTime) < SpeakInterval * 1000) { return (0); } double p = GetCurrPrice(); if ((p >= Range1Min && p <= Range1Max) || (p >= Range2Max && p <= Range2Min)) { SpeechText(GetSpeechText(),i_Language); LastSpeakTime = GetTickCount(); } //---- return(0); } //+------------------------------------------------------------------+