編程學(xué)習(xí)mt4參考空格建Tab鍵換行和換頁可以成為代碼排版的分隔符你_第1頁
編程學(xué)習(xí)mt4參考空格建Tab鍵換行和換頁可以成為代碼排版的分隔符你_第2頁
編程學(xué)習(xí)mt4參考空格建Tab鍵換行和換頁可以成為代碼排版的分隔符你_第3頁
編程學(xué)習(xí)mt4參考空格建Tab鍵換行和換頁可以成為代碼排版的分隔符你_第4頁
編程學(xué)習(xí)mt4參考空格建Tab鍵換行和換頁可以成為代碼排版的分隔符你_第5頁
已閱讀5頁,還剩89頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

/**///作為開始到新的一行結(jié)束,可以被嵌套到多/*嵌套的單行注釋注釋結(jié)束*/標(biāo)識(shí)符用來給變量、函數(shù)和數(shù)據(jù)類型進(jìn)行命名,長度過31一個(gè)字////NAME1namelTotal_5[DataIntegerBoolean?èò?eà??StringFloating-pointnumberColorDatetime我們用Integer類型數(shù)據(jù)來作為DateTime和Color數(shù)據(jù)的。Integer十進(jìn)制:0-9;012,12,111,-956十六進(jìn)制:0-9;a-f或A-F10-15;0x0X0x0A,0x0A,0x12,0X12,0x2f,0xA3,0Xa3,Integer變量的取值范圍為 l任意在單引號(hào)中的字符或十六進(jìn)制的任意ASCII碼例如'\x10'linefeedNL(LF)\nhorizontaltabHT\tcarriagelinefeedNL(LF)\nhorizontaltabHT\tcarriagereturnCR\rreverseslash\\\singlequote'\'doublequote"\"hexadecimalASCII-codehhintinta=intb=intc='?';//codeintd='\xAE';//symbolcodeBooleanBoolean,10進(jìn)行表示。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字符串型是用來表示連續(xù)的ASCII碼字符的使用連續(xù)的兩個(gè)雙引號(hào)來包括需要表示的內(nèi)容如:"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;得到y(tǒng)x倍的值y*=x;得到y(tǒng)x的值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類型預(yù)定義了二進(jìn)制&運(yùn)算符。對于整型,&bool操作數(shù),&計(jì)算操作數(shù)的邏輯“與”;也就是說,當(dāng)且僅當(dāng)兩個(gè)操作數(shù)均為true時(shí),其結(jié)果才為true。bb=((x&y)!=|bool類型預(yù)定義的。對于整型,|bool操作數(shù),|對操作數(shù)進(jìn)行邏輯“或”計(jì)算,也就是說,當(dāng)且僅當(dāng)兩個(gè)操作數(shù)均為false時(shí),其結(jié)果才為false。bb=x|bool^二進(jìn)制操作數(shù)。對于整型,^bool操作數(shù),^計(jì)算操作數(shù)的邏輯“異或”;也就是說,當(dāng)且僅當(dāng)只有一個(gè)操作數(shù)為true時(shí),其結(jié)果才為true。bb=x^注:位邏輯運(yùn)算符只作用于Integers索引。定位在數(shù)組中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格式.一個(gè)操作符可以占用一行或者多行,兩個(gè)或多個(gè)操作符可以占用的行。嵌套.執(zhí)行控制符(if,if-else,switch,whileandfor)可以進(jìn)行任意嵌套.一個(gè)復(fù)合操作符有一個(gè)(一個(gè)區(qū)段)和由一個(gè)或多個(gè)任何類型的操作符組成的的附件{}.每個(gè)表達(dá)式使用分號(hào)作為結(jié)束{x=1;y=2;}Assignmentoperator.y=x=3;//Function_name(argument1,...,一個(gè)break;,其放在嵌套內(nèi)的指定位置,用來在指定情況下跳出循環(huán)操作////0一個(gè)continue;其放在嵌套內(nèi)的指定位置,用來在指定情況下跳過接下來的運(yùn)算,直接跳入下一次的循環(huán)////summaryofnonzeroelementsofarrayintfunc(intarray[]){intintsum=0;for(intintsum=0;for(int{if(a[i]==0)continue;}}一個(gè)return;return后面的()if(expression)if-elseif(expression)如果表達(dá)式為真那么執(zhí)行operator1operator2,else后還可以跟進(jìn)多個(gè)if{if(y==2)}}//{}else}else{y=}}switch{caseconstant1:operators;break;caseconstant2:operators;default:operators;}當(dāng)表達(dá)式expressiondefaultcasecase3+4正確的caseX+Y{case'A':Print("CASEA\n");casecasePrint("CASEBorC\n");Print("NOTA,BorC\n");}循環(huán)操作符whilewhile(expression)只要表達(dá)式expression為真就執(zhí)行操作{}for(expression1;expression2;expression3)3(expression3)while{使用for(;;)while(true)一樣13都可以內(nèi)嵌多個(gè)用逗號(hào)(,)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()在載入時(shí)調(diào)用,可以用此函數(shù)在開始自定義指標(biāo)或者自動(dòng)之前做初始化操作。deinit()在卸載時(shí)調(diào)用,可以用此函數(shù)在去處自定義指標(biāo)或者自動(dòng)之前做初始化操作。start()當(dāng)數(shù)據(jù)變動(dòng)時(shí)觸發(fā),對于自定義指標(biāo)或者自動(dòng)的編程主要依靠此函數(shù)進(jìn)行。string-字符串型int-整數(shù)型double-雙精度浮點(diǎn)數(shù)型bool-stringstringMessageBox;intOrders;doubleSymbolPrice;boolbLog;datetime-時(shí)間型,使用無符號(hào)整型數(shù)字,是1970.1.10:0:0開始的秒color-顏色,externexterndatetimetBegin_Data=D'2004.01.0100:00';externcolorcModify_Color=C'0x44,0xB9,0xE6';內(nèi)部變量顧名思義是在的,可以理解為在當(dāng)前嵌套內(nèi)所使用的變量。voidvoidfunc(intx,doubley,bool{}func(123,func(123,voidvoidfunc(int&x,double&y,double&{}在數(shù)據(jù)類型前加上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以下是所有的參數(shù)名稱 設(shè)置一 到公 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此函數(shù)不能用在字符型或連續(xù)數(shù)字的數(shù)組上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[]這些類型的數(shù)組可以被dest[]-source[]-start_dest-0start_source-從源數(shù)組的第幾位開始,默認(rèn)為0count-多少位的數(shù)組doublearray1[][6];doubledoublearray1[][6];doublearray2[10][6];//fillarraywithsomedata//nowarray2hasfirst10barsintheintArrayCopyRates(double&dest_array[],stringsymbol=NULL,int6個(gè)項(xiàng)目分別是-時(shí)間-開盤價(jià)--最高價(jià)-收盤價(jià)-量dest_array[]-symbol-timeframe-doublearray1[][6];doublearray1[][6];intArrayCopySeries(double&array[],intseries_index,stringsymbol=NULL,int注:如果series_indexMODE_TIME,dest_array[]-series_index想要取的系列的名稱或編號(hào),0-5symbol-標(biāo)示,當(dāng)前所需要的通貨的標(biāo)示timeframe-圖表的時(shí)間線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檢查數(shù)組是否連續(xù)的(time,open,close,high,loworarray[]-{Print("Seriesarraycannotbeinitialized!");}int um(doublearray[],intcount=WHOLE_ARRAY,intarray[]-需要檢查的數(shù)組count搜索數(shù)組中項(xiàng)目的個(gè)數(shù)start-搜索的開始點(diǎn)doubledoubleintmaxValueIdx=Array Print("Maxvalue=",num_array[maxValueIdx]);intArrayMinimum(doublearray[],intcount=WHOLE_ARRAY,intarray[]-需要檢查的數(shù)組count搜索數(shù)組中項(xiàng)目的個(gè)數(shù)start-搜索的開始點(diǎn)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-是否是設(shè)置為系列數(shù)組,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[]-需要處理的數(shù)組count對多少個(gè)數(shù)組項(xiàng)進(jìn)行排序start-排序的開始點(diǎn)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-小數(shù)點(diǎn)后多少位,0-stringstring//valueis,doubleNormalizeDouble(doublevalue,intvalue-digits-小數(shù)點(diǎn)后多少位,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(-任意值,多個(gè)可用逗號(hào)分Alert("Closepricecoming",stringPrint("TerminalPrint("Terminalnameis string nameis voidComment(-任意值,多個(gè)可用逗號(hào)分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窗口上顯示的標(biāo)題flags-窗口選項(xiàng)開關(guān)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發(fā)送郵件到指定信箱,需要到菜單Tools->Options->中將郵件打開subject-some_text-doubledoublelastclose=Close[0];SendMail("fromyourexpert","PricedroppeddowntostringPrint("ServerPrint("Serveraddressis",voidSleep(intmilliseconds-10001voidSpeechText(stringtext,int使用Speechtext-lang_mode-SPEECH_ENGLISH默認(rèn)的)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[]-緩存的數(shù)組doubledoubleExtBufferSilver[];intinit(){SetIndexBuffer(0,ExtBufferSilver);//setbufferforfirst//}}voidSetIndexDrawBegin(intindex,intindex-0-7begin-劃線的開始點(diǎn)#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關(guān)閉正在已經(jīng)打開的文件handleFileOpen()intinthandle=FileOpen("filename",FILE_CSV|FILE_READ);{//workingwithfile...}voidFileDelete(string刪除文件,如果發(fā)生錯(cuò)誤可以通過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()獲取錯(cuò)誤注:只能操作terminal_dir\experts\files filename mode-FILE_BINFILE_CSVFILE_READdelimiterCSV型打開模式用的分割符,默認(rèn)為分號(hào)inthandle;inthandle;{Print("Filemy_data.datnotfound,thelasterroris",GetLastError());}intFileOpenHistory(stringfilename,intmode,int1,可以通過GetLastError()filename mode-FILE_BINFILE_CSVFILE_READdelimiterCSV型打開模式用的分割符,默認(rèn)為分號(hào)intinthandle=FileOpenHistory("USDX240.HST",FILE_BIN|FILE_WRITE);{Print("CannotcreatefileUSDX240.HST");}//workwith//...intFileReadArray(inthandle,object&array[],intstart,intcount)將二進(jìn)制文件到數(shù)組中,返回的條數(shù),可以通過GetLastError()獲取錯(cuò)誤handleFileOpen()返回的句柄array[]-寫入的數(shù)組start-在數(shù)組中的開始count-多少個(gè)對intintdoublehandle=FileOpen("filename.dat",FILE_BIN|FILE_READ);{FileReadArray(handle,varray,0,10);}doubleFileReadDouble(inthandle,int從文件中浮點(diǎn)型數(shù)據(jù),數(shù)字可以是8byte的double型或者是4byte的float型handleFileOpen()size-數(shù)字個(gè)是大小,DOUBLE_VALUE(8bytes)FLOAT_VALUE(4inthandle;doubleinthandle;doublevalue;{}intFileReadInteger(inthandle,int從文件中整形型數(shù)據(jù),數(shù)字可以是1,2,4byte的長handleFileOpen()size-數(shù)字個(gè)是大小,CHAR_VALUE(1byte),SHORT_VALUE(2bytes)LONG_VALUE(4intinthandle;intvalue;handle=FileOpen("mydata.dat",FILE_BIN|FILE_READ);{}doubleFileReadNumber(int從文件中數(shù)字,只能在CSV里使handleFileOpen()intinthandle;intvalue;{}stringFileReadString(inthandle,int從文件中字符handleFileOpen()返回的句柄length-字符串長度intinthandle;stringstr;handle=FileOpen("filename.csv",FILE_CSV|FILE_READ);{}boolFileSeek(inthandle,intoffset,inthandleFileOpen()返回的句柄offset-設(shè)置的原點(diǎn)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[]-要寫入的數(shù)組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(數(shù)算函數(shù)[Math&doubleMathAbs(doublevalue-doubledoubledx=-3.141593,//calcMathAbsPrint("Theabsolutevalueof",dx,"is//Output:Theabsolutevalueof-3.141593isdoubleMathArccos(doublevalue-要處理的數(shù)字,范圍-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調(diào)整的索引time1-新的時(shí)間price1-新的價(jià)格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. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論