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

下載本文檔

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

文檔簡介

/**///作為開始到新的一行結(jié)束,可以被嵌套到多示例/*嵌套的單行注釋注釋結(jié)束*/標(biāo)識符用來給變量、函數(shù)和數(shù)據(jù)類型進(jìn)行命名,長度過31一個字示例////NAME1namelTotal_5[DataIntegerBoolean?èò?eà??StringFloating-pointnumberColorDatetime我們用Integer類型數(shù)據(jù)來作為DateTime和Color數(shù)據(jù)的。Integer十進(jìn)制0-9;0不能作為第一個字母12,12,111,-956十六進(jìn)制0-9;a-f或A-F10-15;0x0X作為開始。0x0A,0x0A,0x12,0X12,0x2f,0xA3,0Xa3,Integer變量的取值范圍為 l任意在單引號中的字符或十六進(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和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;得到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ù),&計算操作數(shù)的邏輯“與”;也就是說,當(dāng)且僅當(dāng)兩個操作數(shù)均為true時,其結(jié)果才為true。bb=((x&y)!=|bool類型預(yù)定義的。對于整型,|bool操作數(shù),|對操作數(shù)進(jìn)行邏輯“或”計算,也就是說,當(dāng)且僅當(dāng)兩個操作數(shù)均為false時,其結(jié)果才為false。bb=x|bool^二進(jìn)制操作數(shù)。對于整型,^bool操作數(shù),^計算操作數(shù)的邏輯“異或”;也就是說,當(dāng)且僅當(dāng)只有一個操作數(shù)為true時,其結(jié)果才為true。bb=x^注:位邏輯運(yùn)算符只作用于Integers索引。定位在數(shù)組中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格式.一個操作符可以占用一行或者多行,兩個或多個操作符可以占用的行。嵌套.執(zhí)行控制符(if,if-else,switch,whileandfor)可以進(jìn)行任意嵌套.一個復(fù)合操作符有一個(一個區(qū)段)和由一個或多個任何類型的操作符組成的的附件每個表達(dá)式使用分號作為結(jié)束(;){x=1;y=2;}Assignmentoperator.示例y=x=3;//Function_name(argument1,...,示例一個break;,其放在嵌套內(nèi)的指定位置,用來在指定情況下跳出循環(huán)操作.////0一個continue;其放在嵌套內(nèi)的指定位置,用來在指定情況下跳過接下來的運(yùn)算,直接跳入下一次的循環(huán)。////summaryofnonzeroelementsofarrayintfunc(intarray[]){intintsum=0;for(intintsum=0;for(int{if(a[i]==0)continue;}}一個return;return后面的()中。if(expression)if-elseif(expression)如果表達(dá)式為真那么執(zhí)行operator1operator2,else后還可以跟進(jìn)多個if執(zhí)行多項選擇。詳見示例。{if(y==2)}}//{}else}else{y=}}switch{caseconstant1:operators;break;caseconstant2:operators;default:operators;}當(dāng)表達(dá)式expressiondefault中的操作。casecase3+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)嵌多個用逗號(,)分割的表達(dá)式。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()在載入時調(diào)用,可以用此函數(shù)在開始自定義指標(biāo)或者自動之前做初始化操作。deinit()在卸載時調(diào)用,可以用此函數(shù)在去處自定義指標(biāo)或者自動之前做初始化操作。start()當(dāng)數(shù)據(jù)變動時觸發(fā),對于自定義指標(biāo)或者自動的編程主要依靠此函數(shù)進(jìn)行。string-字符串型int-整數(shù)型double-雙精度浮點(diǎn)數(shù)型bool布爾型stringstringMessageBox;intOrders;doubleSymbolPrice;boolbLog;datetime-時間型,使用無符號整型數(shù)字,是1970.1.10:0:0開始的秒color顏色,使用三色的整型數(shù)字編碼而成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就可以將變量定義成靜態(tài)變量{{staticint}intintGlobal_flag;intstart(){}externexterndoubleInputParameter1=1.0;intinit(){}intintmt1;integerdoubledoublep=stringstrings= intintmta[6]=外部函數(shù)#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",doubleReturnsmarginvalueofthecurrent示例Print("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ù)組可以被::輸入?yún)?shù)dest[目標(biāo)數(shù)組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個項目分別是-時間-開盤價--最高價-收盤價-量::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-標(biāo)示,當(dāng)前所需要的通貨的標(biāo)示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檢查數(shù)組是否連續(xù)的(time,open,close,high,lowor::array[]-示例{Print("Seriesarraycannotbeinitialized!");}int um(doublearray[],intcount=WHOLE_ARRAY,int::array[]-需要檢查的數(shù)組count搜索數(shù)組中項目的個數(shù)start-搜索的開始點(diǎn)示例doubledoubleintmaxValueIdx=Array Print("Maxvalue=",num_array[maxValueIdx]);intArrayMinimum(doublearray[],intcount=WHOLE_ARRAY,int::array[]-需要檢查的數(shù)組count搜索數(shù)組中項目的個數(shù)start-搜索的開始點(diǎn)示例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-是否是設(shè)置為系列數(shù)組,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[]-需要處理的數(shù)組count對多少個數(shù)組項進(jìn)行排序start-排序的開始點(diǎn)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-小數(shù)點(diǎn)后多少位,0-示例stringstring//valueis,doubleNormalizeDouble(doublevalue,int::value-digits-小數(shù)點(diǎn)后多少位,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窗口上顯示的標(biāo)題flags-窗口選項開關(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(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發(fā)送郵件到指定信箱,需要到菜單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默認(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(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[]-緩存的數(shù)組示例doubledoubleExtBufferSilver[];intinit(){SetIndexBuffer(0,ExtBufferSilver);//setbufferforfirst//}}voidSetIndexDrawBegin(intindex,int::index-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,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關(guān)閉正在已經(jīng)打開的文件示例

::handleFileOpen()intinthandle=FileOpen("filename",FILE_CSV|FILE_READ);{//workingwithfile...}voidFileDelete(string刪除文件,如果發(fā)生錯誤可以通過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型打開模式用的分割符,默認(rèn)為分號示例inthandle;inthandle;{Print("Filemy_data.datnotfound,thelasterroris",GetLastError());}intFileOpenHistory(stringfilename,intmode,int1,可以通過GetLastError()::filename mode-FILE_BINFILE_CSVFILE_READdelimiterCSV型打開模式用的分割符,默認(rèn)為分號示例intinthandle=FileOpenHistory("USDX240.HST",FILE_BIN|FILE_WRITE);{Print("CannotcreatefileUSDX240.HST");}//workwith//...intFileReadArray(inthandle,object&array[],intstart,intcount)將二進(jìn)制文件到數(shù)組中,返回的條數(shù),可以通過GetLastError()獲取錯誤::handleFileOpen()返回的句柄array[]-寫入的數(shù)組start-在數(shù)組中的開始count-多少個對示例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ù)字個是大小,DOUBLE_VALUE(8bytes)FLOAT_VALUE(4示例inthandle;doubleinthandle;doublevalue;{}intFileReadInteger(inthandle,int從文件中整形型數(shù)據(jù),數(shù)字可以是1,2,4byte的長::handleFileOpen()size-數(shù)字個是大小,CHAR_VALUE(1byte),SHORT_VALUE(2bytes)LONG_VALUE(4示例intinthandle;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,int::handleFileOpen()返回的句柄offset-設(shè)置的原點(diǎn)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[]-要寫入的數(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,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(數(shù)算函數(shù)[Math&doubleMathAbs(double示例

::value-doubledoubledx=-3.141593,//calcMathAbsPrint("Theabsolutevalueof",dx,"is//Output:Theabsolutevalueof-3.141593isdoubleMathArccos(double::value-要處理的數(shù)字,范圍-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示例

::輸入?yún)?shù)value1第一個值value2-doubledoubledoubleMathMin(doublevalue1,double::輸入?yún)?shù)value1第一個值value2-示例doubledoubledoubleMathMod(doublevalue,double::輸入?yún)?shù)value被除數(shù)value2-除數(shù)示例doubledoublex=-10.0,y=3.0,z;Print("Theremainderof",x,"/",y,"is//Output:Theremainderof-10/3is-doubleMathPow(doublebase,double示例

::輸入?yún)?shù)base-基數(shù)exponent指數(shù)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)示例

::輸入?yún)?shù)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::輸入?yún)?shù)name物件名稱value-價格示例doubleObjectGetValueByShift(stringname,int::輸入?yún)?shù)name物件名稱shift-位移數(shù)示例boolObjectMove(stringname,intpoint,datetimetime1,double示例

::name-物件名稱point調(diào)整的索引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. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論