版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
/**///作为开始到新的一行结束,可以被嵌套到多示例/*嵌套的单行注释注释结束*/标识符用来给变量、函数和数据类型进行命名,长度过31一个字示例////NAME1namelTotal_5[DataIntegerBooleanëèòåðàëûStringFloating-pointnumberColorDatetime我们用Integer类型数据来作为DateTime和Color数据的。Integer十进制0-9;0不能作为第一个字母12,12,111,-956十六进制0-9;a-f或A-F10-15;0x0X作为开始。0x0A,0x0A,0x12,0X12,0x2f,0xA3,0Xa3,Integer变量的取值范围为 l任意在单引号中的字符或十六进制的任意ASCII码例如'\x10'linefeedNL(LF)\nhorizontaltabHT\tcarriagelinefeedNL(LF)\nhorizontaltabHT\tcarriagereturnCR\rreverseslash\\\singlequote'\'doublequote"\"hexadecimalASCII-codehhintinta=intb=intc='©';//codeintd='\xAE';//symbolcodeBooleanBoolean,10进行表示。True和Flase可以忽略大小写。boola=true;boolboola=true;boolb=false;boolc=1;a++;a++;b=10;x=Sumofvaluesi=j+2;DifferenceSumofvaluesi=j+2;Differenceofvaluesi=j-3;Changingtheoperationsignx=-x;Productofvaluesz=3*x;Divisionquotienti=j/Divisionremainderminutes=time%60;Adding1tothevariablevaluei++;Subtracting1fromthevariablevaluek--;1intinta++;//intb=(a++)*3;//将将x的值赋值给yy=将xyyx;在yx的值y-=x;得到yx倍的值y*=x;得到yx的值y/=x;取yxyx;y向右位移x位y>>=x;y向左位移x位y<<=x;得到逻辑ANDy&=x;OR的值y|=x;得到逻辑非OR的值y^=aaba==b;abab;aba<b;aba>a是否小于等于bab;a是否大于等于ba>=////如果aPrint("not'a'");Print("outofif(p!=xif(p!=x&&p>y)~bb=>>x=xx=x>><<x=xx=x<<一元&为整型和bool类型预定义了二进制&运算符。对于整型,&bool操作数,&计算操作数的逻辑“与”;也就是说,当且仅当两个操作数均为true时,其结果才为true。bb=((x&y)!=|bool类型预定义的。对于整型,|bool操作数,|对操作数进行逻辑“或”计算,也就是说,当且仅当两个操作数均为false时,其结果才为false。bb=x|bool^二进制操作数。对于整型,^bool操作数,^计算操作数的逻辑“异或”;也就是说,当且仅当只有一个操作数为true时,其结果才为true。bb=x^注:位逻辑运算符只作用于Integers索引。定位在数组中iarray[i]array[i]=x1,x2,...,xnfunction示例doubleSL=Ask-25*Point;doubledoubleSL=Ask-25*Point;double"Mycomment",123,0,Red);()FunctioncallFromlefttoright[]Arrayelementselection!NegationFromleftto~Bitwise-Signchanging*MultiplicationFromleftto/%Module+AdditionFromleftto-<<LeftshiftFromleftto>>Right<LessthanFromleftto<=Lessthanor>Greater>=Greaterthanor==EqualsFromleftto!=Not&BitwiseANDoperationFromleftto^BitwiseexclusiveORFromleftto|BitwiseORoperationFromlefttoright&&LogicalANDFromlefttoright||LogicalORFromleftto=AssignmentFromrightto+=Assignment-=Assignment*=Assignment/=Assignment%=Assignment>>=Assignmentright<<=Assignmentleftshift&=AssignmentbitwiseAND|=Assignmentbitwise^=Assignmentexclusive,CommaFromleftto格式.一个操作符可以占用一行或者多行,两个或多个操作符可以占用的行。嵌套.执行控制符(if,if-else,switch,whileandfor)可以进行任意嵌套.一个复合操作符有一个(一个区段)和由一个或多个任何类型的操作符组成的的附件每个表达式使用分号作为结束(;){x=1;y=2;}Assignmentoperator.示例y=x=3;//Function_name(argument1,...,示例一个break;,其放在嵌套内的指定位置,用来在指定情况下跳出循环操作.////0一个continue;其放在嵌套内的指定位置,用来在指定情况下跳过接下来的运算,直接跳入下一次的循环。////summaryofnonzeroelementsofarrayintfunc(intarray[]){intintsum=0;for(intintsum=0;for(int{if(a[i]==0)continue;}}一个return;return后面的()中。if(expression)if-elseif(expression)如果表达式为真那么执行operator1operator2,else后还可以跟进多个if执行多项选择。详见示例。{if(y==2)}}//{}else}else{y=}}switch{caseconstant1:operators;break;caseconstant2:operators;default:operators;}当表达式expressiondefault中的操作。casecase3+4正确的caseX+Y{case'A':Print("CASEA\n");casecasePrint("CASEBorC\n");Print("NOTA,BorC\n");}循环操作符whilewhile(expression)只要表达式expression为真就执行操作示例{}for(expression1;expression2;expression3)3(expression3)while{示例使用for(;;)while(true)一样13都可以内嵌多个用逗号(,)分割的表达式。doubledouble//linfunc(doublex,doublea,doubleb)//{//return(a*xb);//}示例voidvoiderrmesg(string{Print("error:}function_name示例intint{doublea=linfunc(0.3,10.5,}doublelinfunc(doublex,doublea,double{return(a*x+}init()、deinit()init()在载入时调用,可以用此函数在开始自定义指标或者自动之前做初始化操作。deinit()在卸载时调用,可以用此函数在去处自定义指标或者自动之前做初始化操作。start()当数据变动时触发,对于自定义指标或者自动的编程主要依靠此函数进行。string-字符串型int-整数型double-双精度浮点数型bool布尔型stringstringMessageBox;intOrders;doubleSymbolPrice;boolbLog;datetime-时间型,使用无符号整型数字,是1970.1.10:0:0开始的秒color颜色,使用三色的整型数字编码而成externexterndatetimetBegin_Data=D'2004.01.0100:00';externcolorcModify_Color=C'0x44,0xB9,0xE6';内部变量顾名思义是在的,可以理解为在当前嵌套内所使用的变量voidvoidfunc(intx,doubley,bool{}func(123,func(123,示例voidvoidfunc(int&x,double&y,double&{}在数据类型前加上static就可以将变量定义成静态变量{{staticint}intintGlobal_flag;intstart(){}externexterndoubleInputParameter1=1.0;intinit(){}intintmt1;integerdoubledoublep=stringstrings= intintmta[6]=外部函数#import#importintMessageBoxA(inthWnd,stringszText,stringszCaption,intnType);intSendMessageA(inthWnd,intMsg,int #import"lib.ex4"doubleround(doublevalue);#define#define#defineABC#definePI _NAME"MetaQuotesSoftware#property示例#property#propertylink"#propertycopyright"MetaQuotesSoftware#propertystacksize以下是所有的参数名称 设置一 到公 indicator_separate_window 第N8doublepredefinedlevelNforseparatewindowcustom beforescriptrunitspropertysheetappears;disables#include示例#include#include#include示例#include#include#import"file_name"#import#importintMessageBoxA(inthWnd,stringlpText,stringlpCaption,intuType);intMessageBoxExA(inthWnd,stringlpText,stringlpCaption,intuType,intwLanguageId);#import#import"gdi32.dll"int#import"gdi32.dll"intGetDC(inthWnd);intReleaseDC(inthWnd,inthDC);[AccountdoublePrint("AccountPrint("Accountbalance=doublePrint("AccountPrint("Accountnumber", name stringPrint("accountPrint("accountcurrencyis",doublePrint("AccountPrint("Accountequity=double 示例marginvalueofthecurrent margin= intPrint("AccountPrint("Account#",AccountNumber(),"leverageis",doubleReturnsmarginvalueofthecurrent示例Print("AccountPrint("Accountmargin",stringPrint("AccountPrint("Accountname",intPrint("accountPrint("accountnumber",doublePrint("AccountPrint("Accountprofit",[ArrayintArrayBsearch(doublearray[],doublevalue,intcount=WHOLE_ARRAY,intstart=0,int此函数不能用在字符型或连续数字的数组上示例
::array[]-value-count-start-direction-搜索的方向,MODE_ASCENDMODE_DESCENDdatetimedatetimedaytimes[];int//AlltheTime[]timeseriesaresortedindescendantmodeif(Time[shift]>>=daytimes[0])dayshift=0;{}Print(TimeToStr(Time[shift]),"correspondsto",dayshift,"daybaropenedat",intArrayCopy(object&dest[],objectsource[],intstart_dest=0,intstart_source=0,int只有double[],int[],datetime[],color[],和bool[]这些类型的数组可以被::输入参数dest[目标数组source[]-start_dest-0start_source-从源数组的第几位开始,默认为0count-多少位的数组示例doublearray1[][6];doubledoublearray1[][6];doublearray2[10][6];//fillarraywithsomedata//nowarray2hasfirst10barsintheintArrayCopyRates(double&dest_array[],stringsymbol=NULL,int6个项目分别是-时间-开盘价--最高价-收盘价-量::dest_array[]-symbol-timeframe-示例doublearray1[][6];doublearray1[][6];intArrayCopySeries(double&array[],intseries_index,stringsymbol=NULL,int注:如果series_indexMODE_TIME,::dest_array[]-series_index想要取的系列的名称或编号,0-5symbol-标示,当前所需要的通货的标示timeframe-图表的时间线示例datetimedatetimedaytimes[];int//AlltheTime[]timeseriesaresortedindescendantmodeif(Time[shift]>=daytimes[0])dayshift=0;{} intArrayDimension(int::array[]-示例intintnum_array[10][5];intdim_size;//dim_sizeisboolArrayGetAsSeries(object::array[]-示例Print("array1isindexedasaseriesarray");Print("array1isindexednormally(fromlefttointArrayInitialize(double&array[],double::array[]-value-示例 doublemyarray[10];boolArrayIsSeries(object检查数组是否连续的(time,open,close,high,lowor::array[]-示例{Print("Seriesarraycannotbeinitialized!");}int um(doublearray[],intcount=WHOLE_ARRAY,int::array[]-需要检查的数组count搜索数组中项目的个数start-搜索的开始点示例doubledoubleintmaxValueIdx=Array Print("Maxvalue=",num_array[maxValueIdx]);intArrayMinimum(doublearray[],intcount=WHOLE_ARRAY,int::array[]-需要检查的数组count搜索数组中项目的个数start-搜索的开始点示例doubledoublePrint("Minvalue=",num_array[minValueIdx]);intArrayRange(objectarray[],int::array[]-range_index-示例intintdoublenum_array[10,10,10];doublenum_array[10,10,10];intArrayResize(object&array[],int::array[]-new_size-示例doubledouble//boolArraySetAsSeries(double&array[],bool0::array[]-set-是否是设置为系列数组,true或者示例doublemacd_buffer[300];doubledoublemacd_buffer[300];doubleinti,limit=ArraySize(macd_buffer);for(i=0;ifor(i=0;iintArraySize(object::array[]-示例for(inti=0;i{//dosome}示例
::array[]-需要处理的数组count对多少个数组项进行排序start-排序的开始点sort_dir-排序方式,MODE_ASCENDMODE_DESCENDdoubledouble//nowarraycontainsvalues4,1,6,3,9//nowarrayissorted1,3,4,6,9//nowarrayissorted[ConversionstringCharToStr(int示例
::char_code-字符的ACSIIstringstringstr="WORL"+CharToStr(44);//44iscodefor//resultingstringwillbestringDoubleToStr(doublevalue,int::value-digits-小数点后多少位,0-示例stringstring//valueis,doubleNormalizeDouble(doublevalue,int::value-digits-小数点后多少位,0-示例doubledouble;//output:doubleStrToDouble(string::value-示例doubledoubleintStrToInteger(string::value-示例intintdatetimeStrToTime(stringyyyy.mm.dd::value-示例datetimevar1;datetimevar1;var1=StrToTime("17:35");//returnswithcurrentdatevar1=StrToTime("2003.8.12");//returnswithmidnighttime"00:00"stringTimeToStr(datetimevalue,int::value-1970.1.10:0:0mode-返回字符串的格式示例strignstrign[CommonvoidAlert(...示例
::...-任意值,多个可用逗号分Alert("Closepricecoming",stringPrint("TerminalPrint("Terminalnameis string nameis voidComment(...::...-任意值,多个可用逗号分示例marginis ,2),"\n","Currenttimeisintintintinthandle=FileOpen("somefile.dat",FILE_READ|FILE_BIN);{}intintint//dosomehardPrint("Calculationtimeis",GetTickCount()-start,"voidHideTestIndicators(boolExpertAdvisor::hide-True或者示例lIsCon()返回客户端是否已连接示例:{Print("Connectionisbroken!");}//Expertbodythatneedopened//boolIsDemo()if(IsDemo())if(IsDemo())Print("Iamworkingondemoaccount");elsePrint("Iamworkingonrealaccount");boolIsDllsAllowed()返回是否允许载入Dll文件#import#importintMessageBoxA(inthWnd,stringszText,stringszCaption,int{Print("DLLcallisnotallowed.Expertscannotrun.");}//expertbodythatcallsexternalDLLfunctionsMessageBoxA(0,"anmessage","Message",MB_OK);boolintsomefunc();{Print("Librarycallisnotallowed.Expertscannotrun.");}}//expertbodythatcallsexternalDLLfunctionsboolIsStopped(){if(IsStopped()==true)//longtimeprocesing//}boolIsTesting()if(IsTesting())if(IsTesting())Print("Iamtestingbool返回是否允许doubleMarketInfo(stringsymbol,int::symbol-type-示例doublevar;doublevar;intMessageBox(stringtext=NULL,stringcaption=NULL,int::text-窗口显示的文字caption窗口上显示的标题flags-窗口选项开关示例if(ObjectCreate("text_object",if(ObjectCreate("text_object",OBJ_TEXT,0,D'2004.02.2012:30',{intret=MessageBox("ObjectCreate()failswithcode"+GetLastError()+"\nContinue?","Question",if(ret==IDNO)}//intPrint("PeriodPrint("Periodis",voidySound(string::filename-示例 voidPrint(...::...-示例marginis", Print("Currenttimeis",TimeToStr(CurTime()));doublepi=3.141592653589793;Print("PInumberis",//Output:PInumberis//Arrayprintingfor(inti=0;i<10;i++)boolintticket;intticket;{{intintif(error==134)break;//notenoughmoneyif(error==135)RefreshRates();//priceschanged}else{OrderPrint();break; 10seconds}voidSendMail(stringsubject,string发送邮件到指定信箱,需要到菜单Tools->Options->中将邮件打开::subject-some_text-示例doubledoublelastclose=Close[0];SendMail("fromyourexpert","PricedroppeddowntostringPrint("ServerPrint("Serveraddressis",voidSleep(int::milliseconds-10001示例voidSpeechText(stringtext,int使用Speech::text-lang_mode-SPEECH_ENGLISH默认的)示例doubledoubleSpeechText("Pricedroppeddowntostringintintfor(int{//checkselectionresultbecouseordermaybeclosedordeletedatthistime!if(OrderSelect(pos,SELECT_BY_POS)==false)continue;if(OrderType()>OP_SELL||OrderSymbol()!=Symbol())continue;//dosomeorders}int////thisisexampleintdeinit(){{casecaseREASON_REMOVE:CleanUp();break;//cleanupallexpert's casecasecaseREASON_ACCOUNT:StoreData();break;//prepareto}}[CustomIndicatorvoidIndicatorBuffers(int示例
::count-#property#propertyindicator_separate_window#propertyindicator_buffers1#propertyindicator_color1Silver indicatorexternintFastEMA=12;externintSlowEMA=26;externint//indicatordoubleind_buffer1[];doubleind_buffer2[];double//|Customindicatorinitializationfunctionint{ 2additionalbuffersareusedfor drawing 3indicatorbuffers//nameforDataWindowandindicatorsubwindow++ initialization}intintint{intint checkforpossibleif(counted_bars<0)return(- lastcountedbarwillbeif(counted_bars>0)counted_bars--; mainfor(inti=0;{ ma_shiftsetto0becauseSetIndexShiftcalled} }voidIndicatorDigits(int示例
::digits-#property#propertyindicator_separate_window#propertyindicator_buffers1#propertyindicator_color1Silver indicatorexternintFastEMA=12;externintSlowEMA=26;externint indicatordoubleind_buffer1[];doubleind_buffer2[];double//|Customindicatorinitializationfunctionint{ 2additionalbuffersareusedfor drawing 3indicatorbuffers//nameforDataWindowandindicatorsubwindow++ initialization}voidIndicatorShortName(string::name-示例#property#propertyindicator_separate_window#propertyindicator_buffers1#propertyindicator_color1Silver indicatorexternintFastEMA=12;externintSlowEMA=26;externexternint//indicatordoubleind_buffer1[];doubleind_buffer2[];double//|Customindicatorinitializationfunctionint{ 2additionalbuffersareusedfor drawing 3indicatorbuffers//nameforDataWindowandindicatorsubwindow++ initialization}voidSetIndexArrow(intindex,int::index-0-code-Wingdings示例SetIndexArrow(0,SetIndexArrow(0,boolSetIndexBuffer(intindex,double::index-0-7array[]-缓存的数组示例doubledoubleExtBufferSilver[];intinit(){SetIndexBuffer(0,ExtBufferSilver);//setbufferforfirst//}}voidSetIndexDrawBegin(intindex,int::index-0-7begin-划线的开始点示例#property#propertyindicator_separate_window#propertyindicator_buffers1#propertyindicator_color1Silver indicatorexternintFastEMA=12;externintSlowEMA=26;externint indicatordoubleind_buffer1[];doubleind_buffer2[];double//|Customindicatorinitializationfunctionint{ 2additionalbuffersareusedfor drawing 3indicatorbuffers//nameforDataWindowandindicatorsubwindow++ initialization}voidSetIndexEmptyValue(intindex,double::index-0-7value-新的空值示例voidSetIndexLabel(intindex,string::index-0-text-线的名称,Null示例 //|IchimokuKinkoHyoinitializationfunction int{SetIndexLabel(0,"TenkanSen");SetIndexLabel(1,"KijunSen");a_begin=Kijun;if(a_beginSetIndexStyle(2,DRAW_HISTOGRAM,STYLE_DOT); UpKumoboundinglinedoesnotshowintheSetIndexLabel(5,"SenkouSpanA"); DownKumoboundinglinedoesnotshowintheSetIndexLabel(6,"SenkouSetIndexLabel(6,"SenkouSpanSetIndexLabel(4,"ChinkouSpan");}voidSetIndexShift(intindex,int::index-0-7shift-位移多少示例//|Alligatorinitializationfunctionint{ lineshiftswhen firstpositionsskippedwhen 3indicatorbuffers//drawing indexSetIndexLabel(0,"GatorJaws");SetIndexLabel(2,"GatorLips"); initialization}++voidSetIndexStyle(intindex,inttype,intstyle=EMPTY,intwidth=EMPTY,color示例
::index-0-type-style-width显得宽度(1,2,3,4,5)clr-线的颜色SetIndexStyle(3,SetIndexStyle(3,DRAW_LINE,EMPTY,2,[Date&TimedatetimeCurTime(intDay()if(Day()<5)if(Day()<5)intDayOfWeek(0-星期天示例////donotworkonif(DayOfWeek()==0||DayOfWeek()==6)intDayOfYear(int0-示例boolis_siesta=false;if(Hour()>=12boolis_siesta=false;if(Hour()>=12||Hour()<17)datetimeintMinute()return("firstquarter");intMonth()return("firsthalfofyear");intintTimeDay(datetime::date-示例intint//dayisintTimeDayOfWeek(datetime(0-::date-示例intint//dayis2-intTimeDayOfYear(datetime::date-示例intintintTimeHour(datetime::date-示例intintintTimeMinute(datetime::date-示例intintintTimeMonth(datetime::date-示例intintintTimeSeconds(datetime::date-示例intintintTimeYear(datetime::date-示例intintintTimeYear(datetime////returnifdatebefore1May2002if(Year()==2002&&Month()<5)[FilevoidFileClose(int关闭正在已经打开的文件示例
::handleFileOpen()intinthandle=FileOpen("filename",FILE_CSV|FILE_READ);{//workingwithfile...}voidFileDelete(string删除文件,如果发生错误可以通过GetLastError()来查询 下的文::filename 示例////filemy_table.csvwillbedeletedfromterminal_dir\experts\filesdirectoryintlastError;{Print("Anerrorocurredwhile(",lastError,")deletingfilemy_table.csv");}voidFileFlush(int::handleFileOpen()示例intintinthandle=FileOpen("mydat.csv",FILE_CSV|FILE_WRITE);{{FileWrite(handle,for(intFileWrite(handle,i+1,Open[i],Close[i],High[i],Low[i]);for(intFileWrite(handle,i+1,Open[i],Close[i],High[i],Low[i]);}boolFileIsEnding(int检查是否到了文件尾::handleFileOpen()示例{}boolFileIsLineEnding(int::handleFileOpen()示例{}intFileOpen(stringfilename,intmode,intdelimiter=';')打开文件,如果失败返回值小于1,可以通过GetLastError()获取错误注:只能操作terminal_dir\experts\files ::filename mode-FILE_BINFILE_CSVFILE_READdelimiterCSV型打开模式用的分割符,默认为分号示例inthandle;inthandle;{Print("Filemy_data.datnotfound,thelasterroris",GetLastError());}intFileOpenHistory(stringfilename,intmode,int1,可以通过GetLastError()::filename mode-FILE_BINFILE_CSVFILE_READdelimiterCSV型打开模式用的分割符,默认为分号示例intinthandle=FileOpenHistory("USDX240.HST",FILE_BIN|FILE_WRITE);{Print("CannotcreatefileUSDX240.HST");}//workwith//...intFileReadArray(inthandle,object&array[],intstart,intcount)将二进制文件到数组中,返回的条数,可以通过GetLastError()获取错误::handleFileOpen()返回的句柄array[]-写入的数组start-在数组中的开始count-多少个对示例intintdoublehandle=FileOpen("filename.dat",FILE_BIN|FILE_READ);{FileReadArray(handle,varray,0,10);}doubleFileReadDouble(inthandle,int从文件中浮点型数据,数字可以是8byte的double型或者是4byte的float型::handleFileOpen()size-数字个是大小,DOUBLE_VALUE(8bytes)FLOAT_VALUE(4示例inthandle;doubleinthandle;doublevalue;{}intFileReadInteger(inthandle,int从文件中整形型数据,数字可以是1,2,4byte的长::handleFileOpen()size-数字个是大小,CHAR_VALUE(1byte),SHORT_VALUE(2bytes)LONG_VALUE(4示例intinthandle;intvalue;handle=FileOpen("mydata.dat",FILE_BIN|FILE_READ);{}doubleFileReadNumber(int从文件中数字,只能在CSV里使::handleFileOpen()示例intinthandle;intvalue;{}stringFileReadString(inthandle,int从文件中字符::示例
handleFileOpen()返回的句柄length-字符串长度intinthandle;stringstr;handle=FileOpen("filename.csv",FILE_CSV|FILE_READ);{}boolFileSeek(inthandle,intoffset,int::handleFileOpen()返回的句柄offset-设置的原点originSEEK_CURSEEK_SETSEEK_END示例intinthandle=FileOpen("filename.csv",FILE_CSV|FILE_READ,';');{FileSeek(handle,10,SEEK_SET);}intFileSize(int::handleFileOpen()示例intinthandle;intsize;handle=FileOpen("my_table.dat",FILE_BIN|FILE_READ);{Print("my_table.datsizeis",size,"bytes");}int l(int::handleFileOpen()示例intinthandle;intpos;handle=FileOpen("my_table.dat",//readingsomedata Print("currentpositionis",intFileWrite(inthandle,...::handleFileOpen()...-示例intintdatetimeorderOpen=OrderOpenTime();handle=FileOpen("filename",FILE_CSV|FILE_WRITE,';');{FileWrite(handle,Close[0],Open[0],High[0],Low[0],TimeToStr(orderOpen));}intFileWriteArray(inthandle,objectarray[],intstart,int::handleFileOpen()返回的句柄array[]-要写入的数组start-count-示例intintdouble//copyfirsttenbarstothearrayfor(inti=0;i<10;i++)//writingarraytothefilehandle=FileOpen("mydata.dat",FILE_BIN|FILE_WRITE);{FileWriteArray(handle,BarOpenValues,3,7);//writinglast7}intFileWriteDouble(inthandle,doublevalue,int::handleFileOpen()返回的句柄value-要写入的值size-写入的格式,DOUBLE_VALUE8bytes,default)FLOAT_VALUE4示例intintdoublehandle=FileOpen("mydata.dat",FILE_BIN|FILE_WRITE);{Print("can'topenfileerror-",GetLastError());}FileWriteDouble(h1,var1,intFileWriteInteger(inthandle,intvalue,int::handleFileOpen()返回的句柄value-要写入的值size-写入的格式,CHAR_VALUE1byte),SHORT_VALUE2bytes),LONG_VALUE4bytes,示例inthandle;intinthandle;intvalue=10;handle=FileOpen("filename.dat",FILE_BIN|FILE_WRITE);{Print("can'topenfileerror-",GetLastError());}FileWriteInteger(handle,value,intFileWriteString(inthandle,stringvalue,int::handleFileOpen()示例
value-length-intintstringstr="somestring";handle=FileOpen("filename.bin",FILE_BIN|FILE_WRITE);{Print("can'topenfileerror-",GetLastError());}[GlobalVariablesboolGlobalVariableCheck(string示例
::name-//checkvariablebeforeuse//checkvariablebeforeuseboolGlobalVariableDel(string::name-示例////deletingglobalvariablewithname"gvar_1"doubleGlobalVariableGet(string::name-示例doubledouble checkfunctioncallif(GetLastError()!=0) continuedoubleGlobalVariableGet(string::name-示例doubledouble checkfunctioncallif(GetLastError()!=0) continuedatetimeGlobalVariableSet(stringname,doublevalue::name-value-示例 trytosetnew continueboolGlobalVariableSetOnCondition(stringname,doublevalue,double::name-全局变量的名称value-全局变量的值check_value检查变量的值示例intint{ createglobal}int{ trytolockcommon{ maybevariable } resource dosome unlock}voidGlobalVariablesDeleteAll(数算函数[Math&doubleMathAbs(double示例
::value-doubledoubledx=-3.141593,//calcMathAbsPrint("Theabsolutevalueof",dx,"is//Output:Theabsolutevalueof-3.141593isdoubleMathArccos(double::value-要处理的数字,范围-1示例doubledoublex=0.32696,y;Print("Arcsineof",x,"=",y);Print("Arccosineof",x,"=//Output:Arcsineof//Output:ArccosineofdoubleMathArcsin(double::x-示例doublex=0.32696,y;doublex=0.32696,y;Print("Arcsineof",x,"=",y);Print("Arccosineof",x,"=//Output:Arcsineof//Output:ArccosineofdoubleMathArctan(double::x-示例doublex=-862.42,y;doublex=-862.42,y;Print("Arctangentof",x,"is",y);//Output:Arctangentof-862.42is-doubleMathCeil(double::x-示例doubley;doubley;Print("Theceilof2.8is",y);Print("Theceilof-2.8isTheceilof2.8is3Theceilof-2.8is-2*/doubleMathCos(double::value-示例doubledoublepi=3.doublex,y;;Print("MathSin(",x,")=",y);Print("MathSin(",x,")=",y);Print("MathCos(",x,")=",y);//Output://doubleMathExp(doubleReturnsvaluethenumbereraisedtothepowerd.Onoverflow,thefunctionreturnsINF(infinite)andonunderflow,MathExpreturns0.::d-Anumberspecifyinga示例doubledoublePrint("MathExp(",x,")=//Output:doubleMathFloor(double::x-示例doubley;doubley;Print("Thefloorof2.8is",y);Print("Thefloorof-2.8isThefloorof2.8is2Thefloorof-2.8is-3*/doubleMathLog(double示例
::x-doublex=9000.0,y;doublex=9000.0,y;Print("MathLog(",x,")=",y);//Output:doubleMathMax(doublevalue1,double示例
::输入参数value1第一个值value2-doubledoubledoubleMathMin(doublevalue1,double::输入参数value1第一个值value2-示例doubledoubledoubleMathMod(doublevalue,double::输入参数value被除数value2-除数示例doubledoublex=-10.0,y=3.0,z;Print("Theremainderof",x,"/",y,"is//Output:Theremainderof-10/3is-doubleMathPow(doublebase,double示例
::输入参数base-基数exponent指数doubledoublex=2.0,y=3.0,z;Printf(x,"tothepowerof",y,"is",//Output:2tothepowerof3isintMathRand(// y10for(inti=0;i<10;i++)for(inti=0;i<10;i++)Print("randomvalue",MathRand());doubleMathRound(double::value-示例doubley=MathRound(2.8);Print("Thedoubley=MathRound(2.8);Print("Theroundof2.8is",y);Print("Theroundof-2.4is//Output:Theroundof2.8is//Theroundof-2.4is-doubleMathSin(double::value-示例doubledoublepi=3.doublex,y;;Print("MathSin(",x,")=",y);Print("MathCos(",x,")=",y);//Output://doubleMathSqrt(double::x-示例doubledoublequestion=45.35,answer;Print("Error:MathSqrtreturns",answer,"answer");Print("Thesquarerootof",question,"is",//Output:Thesquarerootof45.35isvoidMathSrand(int通过Seed::seed-示例//Dis y10numbers.for(inti=0;i<10;i++)Print("randomvalue",doubleMathTan(double::x-示例doubledoublepi=3.doublex,y;;Print("MathTan(",pi/4,"=//Output:[ObjectboolObjectCreate(stringname,inttype,intwindow,datetimetime1,doubleprice1,datetimetime2=0,doubleprice2=0,datetimetime3=0,doubleprice3=0)示例
::输入参数name物件名称type-物件类型window-time1-1price11time2-2price22time3-3price3-////newtextif(!ObjectCreate("text_object",OBJ_TEXT,0,D'2004.02.2012:30',{Print("error:can'tcreatetext_object!code#",GetLastError());}//newlabelif(!ObjectCreate("label_object",OBJ_LABEL,0,0,{{Print("error:can'tcreatelabel_object!code#",GetLastError());}boolObjectDelete(string示例
::name-stringObjectDescription(string::name-示例////writingchart'sobjectlisttothefileinthandle,total;string//file {{FileWrite(handle,"Object"+obj_name+"description=}}intObjectFind(string::name-示例if(ObjectFind("line_object2")!=win_idx)if(ObjectFind("line_object2")!=win_idx)doubleObjectGet(stringname,int::name-index-示例colorcoloroldColor=ObjectGet("hline12",stringObjectGetFiboDescription(stringname,int::name-index-示例stringfor(int{ check.maybeobjects'slevelcountlessthanif(GetLastError()!=ERR_NO_ERROR)break;Print(MyObjectName,"level:",i,"description:",text);}intObjectGetShiftByValue(stringname,double::输入参数name物件名称value-价格示例doubleObjectGetValueByShift(stringname,int::输入参数name物件名称shift-位移数示例boolObjectMove(stringname,intpoint,datetimetime1,double示例
::name-物件名称point调整的索引time1-新的时间price1-新的价格ObjectMove("MyTrend",ObjectMove("MyTrend",1,D'2005.02.2512:30',stringObjectName(int::index-示例stringname;for(int{Print(i,"Objectnameis"+name);}intObjectsDeleteAll(intwindow,int::window-type-示例ObjectsDeleteAll(2,ObjectsDeleteAll(2,OBJ_HLINE);//removesallhorizontallineobjectsfromwindow3(indexboolObjectSet(stringname,intindex,double::name-物件的名称index物件属性的索引值value-新的属性值示例//movingfirstcoordtolastbartimeObjectSet("MyTrend",//movingfirstcoordtolastbartimeObjectSet("MyTrend",OBJPROP_TIME1,Time[0]);//settingsecondfiboObjectSet("MyFibo",OBJPROP_FIRSTLEVEL+1,//settingobjectvisibility.objectwillbeshownonlyon15minuteand1hourchartsObjectSet("MyObject",//settingobjectvisibility.objectwillbeshownonlyon15minuteand1hourchartsObjectSet("MyObject",OBJPROP_TIMEFRAMES,OBJ_PERIOD_M15|OBJ_PERIOD_H1);boolObjectSetFiboDescription(stringname,intindex,string::name-index-text-示例 ::name-物件的名称text-文本font_size字体大小font-字体名称text_color-示例 oworld!",10,"TimesNewRoman",voidObjectsRedraw(intObjectsTotal(stringname;for(int{Print(i,"Objectnameisforobject#",i,"is"+}intObjectType(string::name-示例Pre-defineddoubleAsk{"Myorder#2",3,D'2005.10.1012:30',Red);}intintintfor(int{}doubleBid{"Myorder#2",3,D'2005.10.1012:30',Red);}doubleinthandle,bars=Bars;inthandle,bars=Bars;{//writetablecolumnsFileWrite(handle,////writedatafor(inti=0;FileWrite(handle,Time[i],Open[i],High[i],Low[i],Close[i],Volume[i]);}intdoubleintinthandle,handle=FileOpen("file.csv",FILE_CSV|FILE_WRITE,';');{//writetablecolumnsFileWrite(handle,//writedatafor(inti=0;FileWrite(handle,Time[i],Open[i],High[i],Low[i],Close[i],Volume[i]);}double返回指定索引位置的格intinthandle,handle=FileOpen("file.csv",FILE_CSV|FILE_WRITE,";");{//writetablecolumnsFileWrite(handle,//writedatafor(inti=0;FileWrite(handle,Time[i],Open[i],High[i],Low[i],Close[i],Volume[i]);}doubleintinthandle,handle=FileOpen("file.csv",handle=FileOpen("file.csv",FILE_CSV|FILE_WRITE,';');{//writetablecolumnsFileWrite(handle,//writedatafor(inti=0;FileWrite(handle,Time[i],Open[i],High[i],Low[i],Close[i],Volume[i]);}doubledatetimeintinthandle,handle=FileOpen("file.csv",FILE_CSV|FILE_WRITE,';');{//writetablecolumnsFileWrite(handle,//writedatafor(inti=0;FileWrite(handle,Time[i],Open[i],High[i],Low[i],Close[i],Volume[i]);}double返回指定索引位置的量intinthandle,handle=FileOpen("file.csv",FILE_CSV|FILE_WRITE,';');{//writetablecolumnsFileWrite(handle,//eritedatafor(inti=0;FileWrite(handle,Time[i],Open[i],High[i],Low[i],Close[i],Volume[i]);)[StringstringStringConcatenate(...示例
::...-stringstringmarginis", Margin(),"Currenttimeis//slowtext="Accountmarginis"+Margin()+"Currenttimeis"intStringFind(stringtext,stringmatched_text,int::text-被搜索的字符串matched_text需要搜索的字符串start-搜索开始索引位置示例stringstringtext="Thequickbrowndogjumpsoverthelazyfox";intindex=StringFind(
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 公司工作总结
- 人际交往的距离
- 伤寒患者的护理
- 高尿酸人群科学管理方案总结2026
- 蔬果第三方检测合作规范
- 2026届黑龙江省哈尔滨市高考考前提分历史仿真卷含解析
- 2025-2026学年安康市高考适应性考试历史试卷含解析
- 2025年电力系统智能电网行业研究报告
- 循证康复实践中的康复-拓展创新
- 2026年零售智能货架管理系统创新报告
- GB 17840-1999防弹玻璃
- GA/T 1163-2014人类DNA荧光标记STR分型结果的分析及应用
- 广通股校学员专用技术文字讲义
- 第六课-我是跟旅游团一起来的课件
- 氮气驱提高采收率机理与应用-课件
- 边坡巡检记录表
- 《武汉理工大学学报》论文格式要求
- B737NG中文培训手册:34-46-近地警告系统GPWS
- 地灾评估专家
- DB6101∕T 3094-2020 城市生产建设项目水土保持技术规范
- 螺栓连接实验-2015.11.20
评论
0/150
提交评论