#import "SpeechText.dll" int MT_SpeechText(string text, int async); #import //---- input parameters //extern string Version="1.4"; //extern string BuildInfo = "2006.01.18 by wfy05@talkforex.com"; //extern string Format = "%SELL_CURR% ¶Ò %BUY_CURR% %ACTION% ¼ÛΪ %PRICE% %ADD_DIR% %ADD%"; //extern string Format = "%SELL_CURR% %BUY_CURR% %PRICE%"; extern string Format = "%PRICE%"; extern int time_frame=1; extern bool UseBid=true; //extern int SpeakInterval=10; //extern int SpeakDelta=0; extern double Range1Min=0.0; extern double Range1Max=99999.9; extern double Range2Min=0.0; extern double Range2Max=0.0; extern bool Enabled=true; extern bool InitSpeak=false; extern bool LogMessage=false; double LastPrice = 0; int LastSpeakTime = 0; string StrListGetVar(string & array[], string name) { int i, n; n = ArraySize(array)/2; for (i=0; i n1+1) { out = StringConcatenate(out, StringVarGetValue(StringSubstr(str, n1+1, n2-n1-1))); } else if (n2 == n1 + 1) { out = StringConcatenate(out, "%"); } start = n2+1; } return (out); } string StrList[] = { "SELL_CURR",, "BUY_CURR",, "PRICE",, "ACTION",, "ADD_DIR",, "ADD",, "BID_PRICE",, "ASK_PRICE",, }; string StringVarGetValue(string name) { return (StrListGetVar(StrList, name)); } bool StringVarSetValue(string name, string value) { return (StrListSetVar(StrList, name, value)); } void DoSpeech() { string str; UpdateVars(); str = StringReplaceVar(Format); MT_SpeechText(str, 1); LastSpeakTime = GetTickCount(); if (LogMessage) Print (str); return; } double GetPriceChanged() { double diff; double p = GetCurrPrice(); int n = MathPow(10, Digits); diff = p * n -LastPrice *n; return (diff); } double GetCurrPrice() { double p; if (UseBid) { p = Bid; } else { p = Ask; } return (p); } void UpdateVars() { StringVarSetValue("BID_PRICE", DoubleToStr(Bid, Digits)); StringVarSetValue("ASK_PRICE", DoubleToStr(Ask, Digits)); StringVarSetValue("PRICE", DoubleToStr(GetCurrPrice(), Digits)); string add, adddir; double diff = GetPriceChanged(); double abs_diff = MathAbs(diff); double p = GetCurrPrice(); if (abs_diff != 0) { if (diff > 0) { adddir = "UP"; } else if (diff < 0) { adddir = "DOWN"; } add = DoubleToStr(abs_diff, 0) + "µã"; } else { adddir = ""; add = ""; } LastPrice = p; StringVarSetValue("ADD_DIR", adddir); StringVarSetValue("ADD", add); return; } void InitVars() { StringVarSetValue("SELL_CURR", GetSymbolCurrency(true)); StringVarSetValue("BUY_CURR", GetSymbolCurrency(false)); if (UseBid) { StringVarSetValue("ACTION", "BUY"); } else { StringVarSetValue("ACTION", "SELL"); } return; } //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { //---- LastPrice = GetCurrPrice(); LastSpeakTime = 0; if (InitSpeak) { string str; str = "BEGIN" + GetSymbolName(Symbol()) ; str = str + "'S PRICE IS" + DoubleToStr(LastPrice, Digits); MT_SpeechText(str, 1); } InitVars(); // if (Enabled) DoSpeech(); return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- if (InitSpeak) { string str; str = "STOP" + GetSymbolName(Symbol()) ; MT_SpeechText(str, 1); } //---- return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { //---- if (!Enabled) return (0); static int LastAlert = 0; if( LastAlert == 0 || LastAlert < iTime(NULL,time_frame,0) ) { double p = GetCurrPrice(); if (!(p >= Range1Min && p <= Range1Max) && !(p >= Range2Min && p <= Range2Max)) { return (0); } // double abs_diff = MathAbs(GetPriceChanged()); // if (abs_diff < SpeakDelta) { // return (0); // } DoSpeech(); LastAlert = iTime(NULL,time_frame,0); return(0); } //---- return(0); } //+------------------------------------------------------------------+