mt4函数和编程必备(10)

2020-04-14 06:25

void Print( ... ) 将文本打印在结果窗口内

:: 输入参数

... - 任意值,复数用逗号分割

示例:

Print(\Print(\double pi=3.141592653589793; Print(\// Output: PI number is 3.14159265 // Array printing for(int i=0;i<10;i++) Print(Close[i]);

bool RefreshRates() 返回数据是否已经被刷新过了 示例:

int ticket; while(true) { ticket=OrderSend(Symbol(),OP_BUY,1.0,Ask,3,0,0,\if(ticket<=0) { int error=GetLastError(); if(error==134) break; // not enough money if(error==135) RefreshRates(); // prices changed break; } else { OrderPrint(); break; } //---- 10 seconds wait Sleep(10000); }

void SendMail( string subject, string some_text)

发送邮件到指定信箱,需要到菜单 Tools -> Options -> Email 中将邮件打开.

:: 输入参数 subject - 邮件标题 some_text - 邮件内容

示例:

double lastclose=Close[0]; if(lastclose

string ServerAddress() 返回服务器地址

示例:

Print(\

void Sleep( int milliseconds) 设置线程暂停时间

:: 输入参数

milliseconds - 暂停时间 1000 = 1秒

示例:

Sleep(5);

void SpeechText( string text, int lang_mode=SPEECH_ENGLISH) 使用Speech进行语音输出

:: 输入参数 text - 阅读的文字

lang_mode - 语音模式 SPEECH_ENGLISH (默认的) 或 SPEECH_NATIVE

示例:

double lastclose=Close[0]; SpeechText(\

string Symbol() 返回当前当前通货的名称 示例:

int total=OrdersTotal(); for(int pos=0;posOP_SELL || OrderSymbol()!=Symbol()) continue; // do some orders processing... }

int UninitializeReason() 取得程序末初始化的理由 示例:

// this is example int deinit() { switch(UninitializeReason()) { case REASON_CHARTCLOSE: case REASON_REMOVE: CleanUp(); break; // clean up and free all expert's resources. case REASON_RECOMPILE: case REASON_CHARTCHANGE: case REASON_PARAMETERS: case REASON_ACCOUNT: StoreData(); break; // prepare to restart } //... } 自定义指标函数 [Custom Indicator Functions]

void IndicatorBuffers(int count) 设置自定义指标缓存数

:: 输入参数 count - 缓存数量

示例:

#property indicator_separate_window #property indicator_buffers 1 #property indicator_color1 Silver //---- indicator parameters extern int FastEMA=12; extern int SlowEMA=26; extern int SignalSMA=9; //---- indicator buffers double ind_buffer1[]; double ind_buffer2[]; double ind_buffer3[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- 2 additional buffers are used for counting. IndicatorBuffers(3); //---- drawing settings SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,3); SetIndexDrawBegin(0,SignalSMA); IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+2); //---- 3 indicator buffers mapping SetIndexBuffer(0,ind_buffer1); SetIndexBuffer(1,ind_buffer2); SetIndexBuffer(2,ind_buffer3); //---- name for DataWindow and indicator subwindow label IndicatorShortName(\//---- initialization done return(0); }

int IndicatorCounted() 返回缓存数量 示例:

int start() { int limit; int counted_bars=IndicatorCounted(); //---- check for possible errors if(counted_bars<0) return(-1); //---- last counted bar will be recounted if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; //---- main loop for(int i=0; i { //---- ma_shift set to 0 because SetIndexShift called abowe ExtBlueBuffer[i]=iMA(NULL,0,JawsPeriod,0,MODE_SMMA,PRICE_MEDIAN,i); ExtRedBuffer[i]=iMA(NULL,0,TeethPeriod,0,MODE_SMMA,PRICE_MEDIAN,i); ExtLimeBuffer[i]=iMA(NULL,0,LipsPeriod,0,MODE_SMMA,PRICE_MEDIAN,i); } //---- done return(0); }

void IndicatorDigits( int digits) 设置指标精确度

:: 输入参数

digits - 小数点后的小数位数

示例:

#property indicator_separate_window #property indicator_buffers 1 #property indicator_color1 Silver //---- indicator parameters extern int FastEMA=12; extern int SlowEMA=26; extern int SignalSMA=9; //---- indicator buffers double ind_buffer1[]; double ind_buffer2[]; double ind_buffer3[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- 2 additional buffers are used for counting. IndicatorBuffers(3); //---- drawing settings SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,3); SetIndexDrawBegin(0,SignalSMA); IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+2); //---- 3 indicator buffers mapping SetIndexBuffer(0,ind_buffer1); SetIndexBuffer(1,ind_buffer2); SetIndexBuffer(2,ind_buffer3); //---- name for DataWindow and indicator subwindow label IndicatorShortName(\//---- initialization done return(0); }

void IndicatorShortName( string name) 设置指标的简称

:: 输入参数 name - 新的简称

示例:

#property indicator_separate_window #property indicator_buffers 1 #property indicator_color1 Silver //---- indicator parameters extern int FastEMA=12; extern int SlowEMA=26; extern int SignalSMA=9; //---- indicator buffers double ind_buffer1[]; double ind_buffer2[]; double ind_buffer3[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- 2 additional buffers are used for counting. IndicatorBuffers(3); //---- drawing settings SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,3); SetIndexDrawBegin(0,SignalSMA); IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+2); //---- 3 indicator buffers mapping SetIndexBuffer(0,ind_buffer1); SetIndexBuffer(1,ind_buffer2); SetIndexBuffer(2,ind_buffer3); //---- name for DataWindow and indicator subwindow label IndicatorShortName(\//---- initialization done return(0); }


mt4函数和编程必备(10).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:江苏省机关第六届万人学法知识竞赛 网上答题试卷4

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: