原帖由 wfy05 于 2005-11-16 09:24 发表
不客气,你用的是什么操作系统? 我这里手头只测试了WinXP.
你用系统控制面板里面的"语音"进行预听语音如果能朗读中文的话MT4应该也没问题.
谢谢!
我用的是W2k with SP4. 控制面板里看不到有"语音“,不知道用什么才能看到。
另外,在MT4的”报警“里,选择”VOICE“的话,Language只有一个选择ENGLISH。
我把所有的“中文”的改成“英文”的,然后不调用NATIVE的就可以讲,不过是英文的,听起来有点郁闷。:L
改动如下,WFY05兄请勿见怪:
//+------------------------------------------------------------------+
//| 语音报价.mq4 |
//| |
//| |
//+------------------------------------------------------------------+
#property copyright "
[email protected]"
#property link "www.talkfx.com"
//---- input parameters
extern bool Enabled=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;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
double GetCurrPrice()
{
double p;
if (UseBid) {
p = Bid;
} else {
p = Ask;
}
return (p);
}
string CurrencyGetName(string c)
{
if (c == "USD") {
return ("USD");
} else if (c == "EUR") {
return ("EURO");
} else if (c == "GBP") {
return ("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");
} 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+"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 + " to " + 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+"Call 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+"Up"+DoubleToStr(diff,0)+"pips";
} else {
str = str+"down"+DoubleToStr(diff,0)+"pips";
}
}
// Print(LastPrice + "->" + p + " : " + diff);
}
LastPrice = p;
if (LogMessage) Print (str);
return (str);
}
int init()
{
//----
//----
LastPrice = GetCurrPrice();
LastSpeakTime = 0;
if (InitSpeak) {
string str;
str = "Start " + GetSymbolName(Symbol()) + " voice quote,";
str = str + "Current price is " + DoubleToStr(LastPrice, Digits);
SpeechText(str);
}
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
if (InitSpeak) {
string str;
str = "Stop " + GetSymbolName(Symbol()) + " voice quote";
SpeechText(str);
}
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----
if (!Enabled) return (0);
double p = GetCurrPrice();
if (MathAbs(GetTickCount() - LastSpeakTime) < SpeakInterval * 1000) {
return (0);
}
if ((p >= Range2Min && p <= Range1Max) || (p >= Range2Max && p <= Range2Min)) {
SpeechText(GetSpeechText());
LastSpeakTime = GetTickCount();
}
//----
return(0);
}
//+------------------------------------------------------------------+