




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
/**///作为开始到新的一行结束,可以被嵌套到多/*嵌套的单行注释注释结束*/标识符用来给变量、函数和数据类型进行命名,长度过31一个字////NAME1namelTotal_5[DataIntegerBooleanëèòåðàëûStringFloating-pointnumberColorDatetime我们用Integer类型数据来作为DateTime和Color数据的。Integer十进制:0-9;012,12,111,-956十六进制:0-9;a-f或A-F10-15;0x0X0x0A,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和Flaseboola=true;boolboola=true;boolb=false;boolc=1;Floating-pointnumberdoublea=12.111;doubledoublea=12.111;doubleb=-956.1007;doublec=0.0001;doubled=16;2.2e-308到String字符串型是用来表示连续的ASCII码字符的使用连续的两个双引号来包括需要表示的内容如:"Character"Thisisacharacterstring""Copyrightsymbol\t\xA9""this"Thisisacharacterstring""Copyrightsymbol\t\xA9""thislinewithLFsymbol\n""A"" ""0""$"Color//symbolconstantsC'128,128,128'//grayC'0x00,0x00,0xFF'//symbolconstantsC'128,128,128'//grayC'0x00,0x00,0xFF'//blue//namedcolor//integer-valuedrepresentation0xFFFFFF//white//white0x008000//green32768//greenDatetimeD'2004.01.01D'2004.01.0100:00'//NewYearD'1980.07.1912:30:27'D'19.07.1980D'19.07.198012'//equaltoD'1980.07.1912:00:00'D'01.01.2004'//equaltoD'01.01.200400:00:00'D'12:30:27'//equaltoD'[compilationdate]12:30:27'D''//equaltoD'[compilationdate]00:00:00'[Operations&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,...,xnfunctiondoubleSL=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;}当表达式expressiondefaultcasecase3+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_nameintint{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",doubleReturnsmarginvalueofthecurrentPrint("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(intarray[]-intintnum_array[10][5];intdim_size;//dim_sizeisboolArrayGetAsSeries(objectarray[]-Print("array1isindexedasaseriesarray");Print("array1isindexednormally(fromlefttointArrayInitialize(double&array[],doublearray[]-value- doublemyarray[10];boolArrayIsSeries(object检查数组是否连续的(time,open,close,high,loworarray[]-{Print("Seriesarraycannotbeinitialized!");}int um(doublearray[],intcount=WHOLE_ARRAY,intarray[]-需要检查的数组count搜索数组中项目的个数start-搜索的开始点doubledoubleintmaxValueIdx=Array Print("Maxvalue=",num_array[maxValueIdx]);intArrayMinimum(doublearray[],intcount=WHOLE_ARRAY,intarray[]-需要检查的数组count搜索数组中项目的个数start-搜索的开始点doubledoublePrint("Minvalue=",num_array[minValueIdx]);intArrayRange(objectarray[],intarray[]-range_index-intintdoublenum_array[10,10,10];doublenum_array[10,10,10];intArrayResize(object&array[],intarray[]-new_size-doubledouble//boolArraySetAsSeries(double&array[],bool0array[]-set-是否是设置为系列数组,true或者doublemacd_buffer[300];doubledoublemacd_buffer[300];doubleinti,limit=ArraySize(macd_buffer);for(i=0;ifor(i=0;iintArraySize(objectarray[]-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(intchar_code-字符的ACSIIstringstringstr="WORL"+CharToStr(44);//44iscodefor//resultingstringwillbestringDoubleToStr(doublevalue,intvalue-digits-小数点后多少位,0-stringstring//valueis,doubleNormalizeDouble(doublevalue,intvalue-digits-小数点后多少位,0-doubledouble;//output:doubleStrToDouble(stringvalue-doubledoubleintStrToInteger(stringvalue-intintdatetimeStrToTime(stringyyyy.mm.ddvalue-datetimevar1;datetimevar1;var1=StrToTime("17:35");//returnswithcurrentdatevar1=StrToTime("2003.8.12");//returnswithmidnighttime"00:00"stringTimeToStr(datetimevalue,intvalue-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(boolExpertAdvisorhide-True或者bool{Print("Connectionisbroken!");}//Expertbodythatneedopened//boolif(IsDemo())if(IsDemo())Print("Iamworkingondemoaccount");elsePrint("Iamworkingonrealaccount");bool返回是否允许载入Dll#import#importintMessageBoxA(inthWnd,stringszText,stringszCaption,int{Print("DLLcallisnotallowed.Expertscannotrun.");}//expertbodythatcallsexternalDLLfunctionsMessageBoxA(0,"anmessage","Message",MB_OK);boolintsomefunc();{Print("Librarycallisnotallowed.Expertscannotrun.");}}//expertbodythatcallsexternalDLLfunctionsbool{if(IsStopped()==true)//longtimeprocesing//}boolif(IsTesting())if(IsTesting())Print("Iamtestingbool返回是否允许doubleMarketInfo(stringsymbol,intsymbol-type-doublevar;doublevar;intMessageBox(stringtext=NULL,stringcaption=NULL,inttext-窗口显示的文字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(stringfilename- 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(intmilliseconds-10001voidSpeechText(stringtext,int使用Speechtext-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(intcount-#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(intdigits-#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(stringname-#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,intindex-0-code-WingdingsSetIndexArrow(0,SetIndexArrow(0,boolSetIndexBuffer(intindex,doubleindex-0-7array[]-缓存的数组doubledoubleExtBufferSilver[];intinit(){SetIndexBuffer(0,ExtBufferSilver);//setbufferforfirst//}}voidSetIndexDrawBegin(intindex,intindex-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,doubleindex-0-7value-新的空值voidSetIndexLabel(intindex,stringindex-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,intindex-0-7shift-位移多少//|Alligatorinitializationfunctionint{ lineshiftswhen firstpositionsskippedwhen 3indicatorbuffers//drawing indexSetIndexLabel(0,"GatorJaws");SetIndexLabel(2,"GatorLips"); initialization}++voidSetIndexStyle(intindex,inttype,intstyle=EMPTY,intwidth=EMPTY,colorindex-0-type-style-width显得宽度(1,2,3,4,5)clr-线的颜色SetIndexStyle(3,SetIndexStyle(3,DRAW_LINE,EMPTY,2,[Date&TimedatetimeCurTime(intif(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)datetimeintreturn("firstquarter");intreturn("firsthalfofyear");intintTimeDay(datetimedate-intint//dayisintTimeDayOfWeek(datetime(0-date-intint//dayis2-intTimeDayOfYear(datetimedate-intintintTimeHour(datetimedate-intintintTimeMinute(datetimedate-intintintTimeMonth(datetimedate-intintintTimeSeconds(datetimedate-intintintTimeYear(datetimedate-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(inthandleFileOpen()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(inthandleFileOpen(){}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(4inthandle;doubleinthandle;doublevalue;{}intFileReadInteger(inthandle,int从文件中整形型数据,数字可以是1,2,4byte的长handleFileOpen()size-数字个是大小,CHAR_VALUE(1byte),SHORT_VALUE(2bytes)LONG_VALUE(4intinthandle;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,inthandleFileOpen()返回的句柄offset-设置的原点originSEEK_CURSEEK_SETSEEK_ENDintinthandle=FileOpen("filename.csv",FILE_CSV|FILE_READ,';');{FileSeek(handle,10,SEEK_SET);}intFileSize(inthandleFileOpen()intinthandle;intsize;handle=FileOpen("my_table.dat",FILE_BIN|FILE_READ);{Print("my_table.datsizeis",size,"bytes");}int l(inthandleFileOpen()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,inthandleFileOpen()返回的句柄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,inthandleFileOpen()返回的句柄value-要写入的值size-写入的格式,DOUBLE_VALUE8bytes,default)FLOAT_VALUE4intintdoublehandle=FileOpen("mydata.dat",FILE_BIN|FILE_WRITE);{Print("can'topenfileerror-",GetLastError());}FileWriteDouble(h1,var1,intFileWriteInteger(inthandle,intvalue,inthandleFileOpen()返回的句柄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,inthandleFileOpen()value-length-intintstringstr="somestring";handle=FileOpen("filename.bin",FILE_BIN|FILE_WRITE);{Print("can'topenfileerror-",GetLastError());}[GlobalVariablesboolGlobalVariableCheck(stringname-//checkvariablebeforeuse//checkvariablebeforeuseboolGlobalVariableDel(stringname-////deletingglobalvariablewithname"gvar_1"doubleGlobalVariableGet(stringname-doubledouble checkfunctioncallif(GetLastError()!=0) continuedoubleGlobalVariableGet(stringname-doubledouble checkfunctioncallif(GetLastError()!=0) continuedatetimeGlobalVariableSet(stringname,doublevaluename-value- trytosetnew continueboolGlobalVariableSetOnCondition(stringname,doublevalue,doublename-全局变量的名称value-全局变量的值check_value检查变量的值intint{ createglobal}int{ trytolockcommon{ maybevariable } resource dosome unlock}voidGlobalVariablesDeleteAll(数算函数[Math&doubleMathAbs(doublevalue-doubledoubledx=-3.141593,//calcMathAbsPrint("Theabsolutevalueof",dx,"is//Output:Theabsolutevalueof-3.141593isdoubleMathArccos(doublevalue-要处理的数字,范围-1doubledoublex=0.32696,y;Print("Arcsineof",x,"=",y);Print("Arccosineof",x,"=//Output:Arcsineof//Output:ArccosineofdoubleMathArcsin(doublex-doublex=0.32696,y;doublex=0.32696,y;Print("Arcsineof",x,"=",y);Print("Arccosineof",x,"=//Output:Arcsineof//Output:ArccosineofdoubleMathArctan(doublex-doublex=-862.42,y;doublex=-862.42,y;Print("Arctangentof",x,"is",y);//Output:Arctangentof-862.42is-doubleMathCeil(doublex-doubley;doubley;Print("Theceilof2.8is",y);Print("Theceilof-2.8isTheceilof2.8is3Theceilof-2.8is-2*/doubleMathCos(doublevalue-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-AnumberspecifyingadoubledoublePrint("MathExp(",x,")=//Output:doubleMathFloor(doublex-doubley;doubley;Print("Thefloorof2.8is",y);Print("Thefloorof-2.8isThefloorof2.8is2Thefloorof-2.8is-3*/doubleMathLog(doublex-doublex=9000.0,y;doublex=9000.0,y;Print("MathLog(",x,")=",y);//Output:doubleMathMax(doublevalue1,doublevalue1-value2-doubledoubledoubleMathMin(doublevalue1,doublevalue1-value2-doubledoubledoubleMathMod(doublevalue,doublevalue-value2-doubledoublex=-10.0,y=3.0,z;Print("Theremainderof",x,"/",y,"is//Output:Theremainderof-10/3is-doubleMathPow(doublebase,doublebase-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(doublevalue-doubley=MathRound(2.8);Print("Thedoubley=MathRound(2.8);Print("Theroundof2.8is",y);Print("Theroundof-2.4is//Output:Theroundof2.8is//Theroundof-2.4is-doubleMathSin(doublevalue-doubledoublepi=3.doublex,y;;Print("MathSin(",x,")=",y);Print("MathCos(",x,")=",y);//Output://doubleMathSqrt(doublex-doubledoublequestion=45.35,answer;Print("Error:MathSqrtreturns",answer,"answer");Print("Thesquarerootof",question,"is",//Output:Thesquarerootof45.35isvoidMathSrand(int通过Seedseed-//Dis y10numbers.for(inti=0;i<10;i++)Print("randomvalue",doubleMathTan(doublex-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(stringname-stringObjectDescription(stringname-////writingchart'sobjectlisttothefileinthandle,total;string//file {{FileWrite(handle,"Object"+obj_name+"description=}}intObjectFind(stringname-if(ObjectFind("line_object2")!=win_idx)if(ObjectFind("line_object2")!=win_idx)doubleObjectGet(stringname,intname-index-colorcoloroldColor=ObjectGet("hline12",stringObjectGetFiboDescription(stringname,intname-index-stringfor(int{ check.maybeobjects'slevelcountlessthanif(GetLastError()!=ERR_NO_ERROR)break;Print(MyObjectName,"level:",i,"description:",text);}intObjectGetShiftByValue(stringname,doublename-value-doubleObjectGetValueByShift(stringname,intname-shift-boolObjectMove(stringname,intpoint,datetimetime1,doublename-物件名称point调整的索引time1-新的时间price1-新的价格ObjectMove("MyTrend",ObjectMove("MyTrend",1,D'2005.02.2512:30',stringObjectName(intindex-stringname;for(int{Print(i,"Objectnameis"+name);}intObjectsDeleteAll(intwindow,intwindow-type-ObjectsDeleteAll(2,ObjectsDeleteAll(2,OBJ_HLINE);//removesallhorizontallineobjectsfromwindow3(indexboolObjectSet(stringname,intindex,doublename-物件的名称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,stringname-index-text- name-物件的名称text-文本font_size字体大小font-字体名称text_color- oworld!",10,"TimesNewRoman",voidObjectsRedraw(intObjectsTotal(stringname;for(int{Print(i,"Objectnameisforobject#",i,"is"+}intObjectType(stringname-Pre-defineddouble{"Myorder#2",3,D'2005.10.1012:30',Red);}intintintfor(int{}double{"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,inttext-被搜索的字符串matched_text需要搜索的字符串start-搜索开始索引位置stringstringtext="Thequickbrowndogjumpsoverthelazyfox";intindex=StringFind(text,
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 经典散文知识点测试题及答案
- 科学下册期末检测卷答案1-6年级下册
- 2025年度虚拟现实(VR)内容制作解除合同书
- 二零二五年度智能物流仓储厂房仓库租赁服务协议
- 2025年度高效节能烟道清洗与环保改造合同
- 2024年潜水作业安全适用范围政策依据
- 2025年度民宿旅游营销推广合作协议范本
- 文学与社会变迁的关系试题及答案
- 当前语文教育热点问题试题及答案
- CPSM考试常见问题试题及答案
- 第三方生态环境综合排查方案(技术标)
- 《安全操作规程培训》课件
- 2024年度二手车交易市场诚信经营自律公约
- 北京市丰台区2024届高三下学期一模考试 英语 含答案
- 新生儿科、儿科《新生儿窒息复苏》理论考试试题
- DB11T 1833-2021 建筑工程施工安全操作规程
- 信息检索课件 第2章 文献检索方法(1)-2
- 中国邮政四川分公司招聘笔试题库2024
- 肩关节损伤的护理查房课件
- 山东省潍坊市2024年中考数学试卷【附真题答案】
- 2024年安全员A证考试题库(附答案)
评论
0/150
提交评论