powerlanguage教程
更新时间:2024-06-22 05:18:02 阅读量: 综合文库 文档下载
目 录 1
目 录
POWERLANGUAGE概述 .................................................................................................................... 1 第1章 ACCOUNTS AND POSITION账户与部位 ............................................................................. 11 GETACCOUNT ........................................................................................................................................ 11 GETACCOUNTID..................................................................................................................................... 11 GETNUMACCOUNTS ............................................................................................................................... 12 GETNUMPOSITIONS ............................................................................................................................... 12 GETPOSITIONAVERAGEPRICE ................................................................................................................... 12 GETPOSITIONOPENPL ............................................................................................................................ 12 GETPOSITIONQUANTITY .......................................................................................................................... 13 GETPOSITIONSYMBOL............................................................................................................................. 13 GETPOSITIONTOTALCOST ........................................................................................................................ 13 GETRTACCOUNTEQUITY .......................................................................................................................... 14 GETRTUNREALIZEDPL ............................................................................................................................ 14 第2章 ALERT警报 ......................................................................................................................... 15 ALERT .................................................................................................................................................. 16 ALERTENABLED ..................................................................................................................................... 16 CANCEL ALERT....................................................................................................................................... 17 CHECKALERT ......................................................................................................................................... 17 第3章 ARROW DRAWING画箭头 ................................................................................................. 18 ARW_DELETE ....................................................................................................................................... 18 ARW_GETACTIVE .................................................................................................................................. 18 ARW_GETCOLOR ................................................................................................................................... 18 ARW_GETDATE ..................................................................................................................................... 19 ARW_GETDIRECTION ............................................................................................................................. 19 ARW_GETFIRST ..................................................................................................................................... 19 ARW_GETNEXT..................................................................................................................................... 20 ARW_GETSIZE ...................................................................................................................................... 20 ARW_GETSTYLE .................................................................................................................................... 21 ARW_GETTEXT ..................................................................................................................................... 21 ARW_GETTEXTATTRIBUTE ....................................................................................................................... 21 ARW_GETTEXTBGCOLOR ....................................................................................................................... 22
| 目 录
1
2 目 录
ARW_GETTEXTCOLOR ............................................................................................................................ 22 ARW_GETTEXTFONTNAME ..................................................................................................................... 22 ARW_GETTEXTSIZE ............................................................................................................................... 23 ARW_GETTIME ..................................................................................................................................... 23 ARW_GETTIME_S ................................................................................................................................. 23 ARW_GETVAL ....................................................................................................................................... 24 ARW_NEW........................................................................................................................................... 24 ARW_NEW_S ....................................................................................................................................... 24 ARW_NEW_SELF ................................................................................................................................... 25 ARW_NEW_SELF_S ............................................................................................................................... 25 ARW_SETCOLOR ................................................................................................................................... 26 ARW_SETLOCATION ............................................................................................................................... 26 ARW_SETLOCATION_S ............................................................................................................................ 27 ARW_SETSIZE ....................................................................................................................................... 27 ARW_SETSTYLE ..................................................................................................................................... 27 ARW_SETTEXT ...................................................................................................................................... 28 ARW_SETTEXTATTRIBUTE........................................................................................................................ 28 ARW_SETTEXTBGCOLOR ........................................................................................................................ 29 ARW_SETTEXTCOLOR ............................................................................................................................. 29 ARW_SETTEXTFONTNAME ...................................................................................................................... 30 ARW_SETTEXTSIZE ................................................................................................................................ 30 MC_ARW_GETACTIVE ........................................................................................................................... 30 第4章 ATTRIBUTES属性设定 ........................................................................................................ 31 INTRABARORDERGENERATION ................................................................................................................. 31 LEGACYCOLORVALUE .............................................................................................................................. 32 第5章 COLORS色彩 ...................................................................................................................... 33 BLACK .................................................................................................................................................. 33 GETBVALUE .......................................................................................................................................... 34 GETGVALUE ......................................................................................................................................... 34 GETRVALUE .......................................................................................................................................... 34 GRADIENTCOLOR ................................................................................................................................... 34 LEGACYCOLORTORGB ............................................................................................................................ 35 RGB ................................................................................................................................................... 35 RGBTOLEGACYCOLOR ............................................................................................................................ 36
2
目 录
目 录 3
第6章 COMPARISON AND LOOPS比较和循环 .............................................................................. 37 SWITCH…CASE ...................................................................................................................................... 37 ONCE .................................................................................................................................................. 38 ABOVE/OVER ........................................................................................................................................ 38 AND .................................................................................................................................................... 39 BEGIN .................................................................................................................................................. 39 BELOW/UNDER ..................................................................................................................................... 40 BREAK ................................................................................................................................................. 40 CROSS/CROSSES .................................................................................................................................... 40 DOWNTO ............................................................................................................................................. 41 ELSE .................................................................................................................................................... 42 END .................................................................................................................................................... 42 FALSE .................................................................................................................................................. 43 FOR ..................................................................................................................................................... 43 IF ........................................................................................................................................................ 44 NOT .................................................................................................................................................... 45 OR ...................................................................................................................................................... 45 THEN ................................................................................................................................................... 45 TO ...................................................................................................................................................... 46 TRUE ................................................................................................................................................... 46 WHILE ................................................................................................................................................. 47 第7章 DATA INFORMATION/GENERAL数据信息/常规 ................................................................. 48 AGO .................................................................................................................................................... 48 BAR/BARS ............................................................................................................................................ 48 BARINTERVAL ........................................................................................................................................ 48 BARSTATUS ........................................................................................................................................... 49 BARTYPE/DATACOMPRESSION .................................................................................................................. 49 BARTYPE_EX ......................................................................................................................................... 49 BIGPOINTVALUE .................................................................................................................................... 50 BOXSIZE ............................................................................................................................................... 50 CLOSE/C .............................................................................................................................................. 51 CATEGORY ............................................................................................................................................ 51 CURRENTBAR ........................................................................................................................................ 52 DATE/D ............................................................................................................................................... 52 DAILYLIMIT ........................................................................................................................................... 52
| 目 录
3
4 目 录
DATA ................................................................................................................................................... 52 DAY/DAYS ............................................................................................................................................ 52 DOWNTICKS ......................................................................................................................................... 52 EXPIRATIONDATE ................................................................................................................................... 53 GETEXCHANGENAME ............................................................................................................................. 54 GETSYMBOLNAME ................................................................................................................................. 54 HIGH/H ............................................................................................................................................... 54 LOW/L ................................................................................................................................................. 54 OPEN/O .............................................................................................................................................. 54 OPENINT/I ............................................................................................................................................ 55 INTERVALTYPE ....................................................................................................................................... 55 INTERVALTYPE_EX .................................................................................................................................. 56 MINMOVE ........................................................................................................................................... 56 NEXT ................................................................................................................................................... 57 POINT/POINTS ...................................................................................................................................... 57 POINTVALUE ......................................................................................................................................... 57 PRICESCALE .......................................................................................................................................... 57 REVSIZE ............................................................................................................................................... 58 SESSIONLASTBAR ................................................................................................................................... 58 TIME/T ................................................................................................................................................ 58 TIME_S ................................................................................................................................................ 58 THIS .................................................................................................................................................... 59 TICKS ................................................................................................................................................... 59 TODAY ................................................................................................................................................. 59 UPTICKS ............................................................................................................................................... 59 VOLUME/V ........................................................................................................................................... 60 YESTERDAY ........................................................................................................................................... 61 第8章 DATE AND TIME ROUTINES日期和时间 ............................................................................. 62 COMPUTERDATETIME ............................................................................................................................. 62 CURRENTDATE ...................................................................................................................................... 62 CURRENTTIME ...................................................................................................................................... 63 CURRENTTIME_S ................................................................................................................................... 63 DATETIME2ELTIME ................................................................................................................................ 63 DATETIME2ELTIME_S ............................................................................................................................ 63 DATETIMETOSTRING .............................................................................................................................. 63
4
目 录
目 录 5
DATETOJULIAN ...................................................................................................................................... 64 DATETOSTRING ..................................................................................................................................... 64 DAYFROMDATETIME .............................................................................................................................. 64 DAYOFMONTH ...................................................................................................................................... 64 DAYOFWEEK ........................................................................................................................................ 65 DAYOFWEEKFROMDATETIME .................................................................................................................. 65 EL_DATESTR ......................................................................................................................................... 65 EL_DATETODATETIME/ELDATETODATETIME .............................................................................................. 66 EL_TIMETODATETIME/ELTIMETODATETIME .............................................................................................. 66 EL_TIMETODATETIME_S/ELTIMETODATETIME_S ....................................................................................... 66 ENCODEDATE ........................................................................................................................................ 66 ENCODETIME ........................................................................................................................................ 67 FORMATDATE ........................................................................................................................................ 67 ENCODETIME ........................................................................................................................................ 68 FRIDAY ................................................................................................................................................. 69 HOURSFROMDATETIME .......................................................................................................................... 69 INCMONTH .......................................................................................................................................... 69 JULIANTODATE ...................................................................................................................................... 69 LASTCALCJDATE..................................................................................................................................... 70 LASTCALCMMTIME ............................................................................................................................... 70 LASTCALCSSTIME .................................................................................................................................. 70 MILLISECONDSFROMDATETIME ................................................................................................................ 70 MINUTESFROMDATETIME ....................................................................................................................... 70 MONDAY .............................................................................................................................................. 71 MONTH ............................................................................................................................................... 71 MONTHFROMDATETIME ......................................................................................................................... 71 SATURDAY ............................................................................................................................................ 71 SECONDSFROMDATETIME ....................................................................................................................... 72 STRINGTODATE ..................................................................................................................................... 72 STRINGTODATETIME .............................................................................................................................. 72 STRINGTOTIME ..................................................................................................................................... 73 SUNDAY ............................................................................................................................................... 73 THURSDAY ............................................................................................................................................ 73 TIME_S2TIME ....................................................................................................................................... 74 TIME2TIME_S ....................................................................................................................................... 74 TIMETOSTRING ..................................................................................................................................... 74
| 目 录
5
6 目 录
TUESDAY .............................................................................................................................................. 74 WEDNESDAY ......................................................................................................................................... 74 YEAR ................................................................................................................................................... 75 YEARFROMDATETIME ............................................................................................................................. 75 第9章 DECLARATION声明 ............................................................................................................ 76 ARRAY/ARRAYS ...................................................................................................................................... 76 INPUT/INPUTS ....................................................................................................................................... 77 INTRABARPERSIST .................................................................................................................................. 78 NUMERIC ............................................................................................................................................. 78 NUMERICARRAY .................................................................................................................................... 79 NUMERICARRAYREF ............................................................................................................................... 79 NUMERICREF ........................................................................................................................................ 80 NUMERICSERIES .................................................................................................................................... 80 NUMERICSIMPLE ................................................................................................................................... 81 STRING ................................................................................................................................................ 81 STRINGARRAY ....................................................................................................................................... 81 STRINGARRAYREF .................................................................................................................................. 82 STRINGREF ........................................................................................................................................... 83 STRINGSERIES ....................................................................................................................................... 83 STRINGSIMPLE ...................................................................................................................................... 83 TRUEFALSE ........................................................................................................................................... 84 TRUEFALSEARRAY .................................................................................................................................. 84 TRUEFALSEARRAYREF ............................................................................................................................. 85 TRUEFALSEREF ...................................................................................................................................... 85 TRUEFALSESERIES .................................................................................................................................. 86 TRUEFALSESIMPLE ................................................................................................................................. 86 VARIABLE/VARIABLES/VAR/VARS .............................................................................................................. 86 第10章 DYNAMIC ARRAY动态数组 .............................................................................................. 88 ARRAY_COMPARE .................................................................................................................................. 88 ARRAY_COPY ........................................................................................................................................ 89 ARRAY_GETMAXINDEX ........................................................................................................................... 89 ARRAY_GETTYPE ................................................................................................................................... 89 ARRAY_SETMAXINDEX ........................................................................................................................... 90 ARRAY_SETVALRANGE ............................................................................................................................ 90 ARRAY_SORT ........................................................................................................................................ 91
6
目 录
目 录 7
ARRAY_SUM ......................................................................................................................................... 91 FILL_ARRAY .......................................................................................................................................... 92
第11章 ENVIRONMENT INFORMATION环境信息 ......................................................................... 93 BASEDATANUMBER ................................................................................................................................ 93 CURRENTDATANUMBER .......................................................................................................................... 93 EXECOFFSET ......................................................................................................................................... 93 GETAPPINFO ......................................................................................................................................... 93 GETCOUNTRY ........................................................................................................................................ 94 GETCURRENCY ...................................................................................................................................... 95 GETUSERID .......................................................................................................................................... 95 MAXBARSBACK ..................................................................................................................................... 95 MAXBARSFORWARD .............................................................................................................................. 95 第12章 EXECUTION CONTROL执行控制 ....................................................................................... 96 ABORT ................................................................................................................................................. 96
FPCEXACTACCURACY ............................................................................................................................... 96 FPCHIGHACCURACY ................................................................................................................................ 96 FPCLOWACCURACY ................................................................................................................................. 97 FPCMEDACCURACY ................................................................................................................................ 97 FPCVERYHIGHACCURACY ......................................................................................................................... 97 FPCVERYLOWACCURACY .......................................................................................................................... 98
RAISERUNTIMEERROR ............................................................................................................................ 98 RECALCLASTBARAFTER ........................................................................................................................... 98 SETFPCOMPAREACCURACY ...................................................................................................................... 98 第13章 MATH AND TRIG数学函数 ............................................................................................. 100 ABSVALUE/POS ................................................................................................................................... 100 ARCTANGENT ...................................................................................................................................... 100 AVGLIST ............................................................................................................................................. 100 CEILING .............................................................................................................................................. 100 COSINE .............................................................................................................................................. 101 COTANGENT ........................................................................................................................................ 101 EXPVALUE .......................................................................................................................................... 101 FLOOR ............................................................................................................................................... 101 FRACPORTION ..................................................................................................................................... 101 INTPORTION ....................................................................................................................................... 101
| 目 录
7
8 目 录
LOG ................................................................................................................................................... 102 MAXLIST ............................................................................................................................................ 102 MAXLIST2 .......................................................................................................................................... 102 MINLIST ............................................................................................................................................. 102 MINLIST2 ........................................................................................................................................... 102 MOD ................................................................................................................................................. 103 NEG .................................................................................................................................................. 103 NTHMAXLIST ....................................................................................................................................... 103 NTHMINLIST ....................................................................................................................................... 103 POWER .............................................................................................................................................. 103 RANDOM ........................................................................................................................................... 104 ROUND .............................................................................................................................................. 104 SIGN .................................................................................................................................................. 104 SINE .................................................................................................................................................. 104 SQUARE ............................................................................................................................................. 104 SQUAREROOT ..................................................................................................................................... 105 SUMLIST ............................................................................................................................................ 105 TANGENT ............................................................................................................................................ 105 第14章 OUTPUT输出 ................................................................................................................. 106 CLEARDEBUG ...................................................................................................................................... 106 CLEARPRINTLOG .................................................................................................................................. 106 FILE ................................................................................................................................................... 107 FILEAPPEND ........................................................................................................................................ 107 FILEDELETE ......................................................................................................................................... 107 MESSAGELOG ..................................................................................................................................... 107 PLAYSOUND ........................................................................................................................................ 108 PRINT ................................................................................................................................................ 108 第15章 PLOTTING指标画线 ....................................................................................................... 110 DEFAULT ............................................................................................................................................ 110 GETBACKGROUNDCOLOR ...................................................................................................................... 110 GETPLOTCOLOR ................................................................................................................................... 111 GETPLOTWIDTH .................................................................................................................................. 111 NOPLOT ............................................................................................................................................. 111 PLOT ................................................................................................................................................. 111 PLOTPAINTBAR/PLOTPB ....................................................................................................................... 113
8
目 录
目 录 9
SETPLOTCOLOR ................................................................................................................................... 114 SETPLOTBGCOLOR............................................................................................................................... 114
第16章 PORTFOLIO STRAGEGY PERFORMANCE投资组合策略绩效 ........................................... 115 PORTFOLIO_GROSSLOSS ....................................................................................................................... 115 PORTFOLIO_GROSSPROFIT .................................................................................................................... 116 PORTFOLIO_INVESTEDCAPITAL ............................................................................................................... 116 PORTFOLIO_MAXIDDRAWDOWN ........................................................................................................... 116 PORTFOLIO_NETPROFIT ........................................................................................................................ 116 PORTFOLIO_NUMLOSSTRADES ............................................................................................................... 117 PORTFOLIO_NUMWINTRADES ............................................................................................................... 117 PORTFOLIO_PERCENTPROFIT ................................................................................................................. 117 PORTFOLIO_STRATEGYDRAWDOWN ........................................................................................................ 117 PORTFOLIO_TOTALTRADE ...................................................................................................................... 118 第17章 PORTFOLIO STRAGEGY POSITION投资组合策略部位 .................................................... 119 PORTFOLIO_CALCMAXPOTENTIALLOSSFORENTRY ...................................................................................... 119 PORTFOLIO_CURRENTENTRIES ............................................................................................................... 119 PORTFOLIO_MAXOPENPOSITIONPOTENTIALLOSS ...................................................................................... 120 PORTFOLIO_OPENPOSITIONPROFIT ......................................................................................................... 120 PORTFOLIO_SETMAXPOTENTIALLOSSPERCONTRACT .................................................................................. 120 第18章 PORTFOLIO STRAGEGY PROPERTIES投资组合属性 ........................................................ 122 PORTFOLIO_GETMARGINPERCONTRACT .................................................................................................. 122 PORTFOLIO_GETMAXPOTENTIALLOSSPERCONTRACT ................................................................................. 122 PORTFOLIO_MAXRISKEQUITYPERPOSPERCENT ......................................................................................... 123 PORTFOLIO_TOTALMAXRISKEQUITYPERCENT ............................................................................................ 123 PORTFOLIOENTRIESPRIORITY .................................................................................................................. 123 第19章 QUOTE FIELDS报价字段 ................................................................................................ 124 CURRENTOPENINT/Q_OPENINTEREST ..................................................................................................... 124 DAILYCLOSE ........................................................................................................................................ 124 DAILYHIGH ......................................................................................................................................... 124 DAILYLOW .......................................................................................................................................... 124 DAILYOPEN ......................................................................................................................................... 124 DAILYVOLUME/Q_TOTALVOLUME ........................................................................................................... 125 DESCRIPTION ...................................................................................................................................... 125
| 目 录
9
10 目 录
EXCHLISTED/Q_EXCHANGELISTED ........................................................................................................... 125 INSIDEASK/Q_ASK ............................................................................................................................... 125 INSIDEBID/Q_BID ................................................................................................................................ 125 LAST/Q_LAST ...................................................................................................................................... 126 PREVCLOSE/Q_PREVIOUSCLOSE ............................................................................................................. 126
Q_BIGPOINTVALUE .............................................................................................................................. 126
SYMBOLNAME/SYMBOL ........................................................................................................................ 126 TRADEDATE/Q_DATE ........................................................................................................................... 126 TRADETIME/Q_TIME ............................................................................................................................ 126
Q_TIME_S .......................................................................................................................................... 126
第20章 SESSIONS交易时段 ........................................................................................................ 128 AUTOSESSION ..................................................................................................................................... 129 REGULARSESSION ................................................................................................................................ 129 SESS1ENDTIME ................................................................................................................................... 129 SESS1FIRSTBARTIME ............................................................................................................................ 129 SESS1STARTTIME ................................................................................................................................. 129 SESS2ENDTIME ................................................................................................................................... 129 SESS2FIRSTBARTIME ............................................................................................................................ 130 SESS2STARTTIME ................................................................................................................................. 130 SESSIONCOUNT ................................................................................................................................... 130 SESSIONCOUNTMS .............................................................................................................................. 130 SESSIONENDDAY .................................................................................................................................. 131 SESSIONENDDAYMS ............................................................................................................................ 131 SESSIONENDTIME ................................................................................................................................ 131 SESSIONENDTIMEMS ........................................................................................................................... 132 SESSIONSTARTDAY ............................................................................................................................... 132 SESSIONSTARTDAYMS .......................................................................................................................... 132 SESSIONSTARTTIME .............................................................................................................................. 133 SESSIONSTARTTIMEMS ......................................................................................................................... 133 第21章 SKIP WORDS跳跃字 ....................................................................................................... 134 A AN AT BASED BY DOES FROM ..................................................................................... 134 IS OF ON PLACE THAN THE WAS .................................................................................... 134 第22章 STRATEGY ORDERS策略委托 ......................................................................................... 135 ALL ................................................................................................................................................... 136
10
目 录
目 录 11
BUY .................................................................................................................................................. 137 BUYTOCOVER ..................................................................................................................................... 138 CONTRACTS/CONTRACT/SHARES/SHARE .................................................................................................. 140 COVER ............................................................................................................................................... 140 ENRTY ............................................................................................................................................... 140 HIGHER .............................................................................................................................................. 141 LIMIT ................................................................................................................................................. 141 LOWER .............................................................................................................................................. 142 MARKET............................................................................................................................................. 142 SELL .................................................................................................................................................. 142 SELLSHORT ......................................................................................................................................... 144 SETBREAKEVEN ................................................................................................................................... 146 SETDOLLARTRAILING ............................................................................................................................ 146 SETEXITONCLOSE ................................................................................................................................ 147 SETPERCENTTRAILING ........................................................................................................................... 147 SETPROFITTARGET ............................................................................................................................... 148 SETSTOPCONTRACT/SETSTOPSHARE ........................................................................................................ 149 SETSTOPLOSS ...................................................................................................................................... 149 SETSTOPPOSITION ............................................................................................................................... 150 SHORT ............................................................................................................................................... 150 STOP ................................................................................................................................................. 150 TOTAL ................................................................................................................................................ 150
第23章 STRATEGY PERFORMANCE策略绩效 .............................................................................. 152 AVGBARSEVENTRADE ........................................................................................................................... 152 AVGBARSLOSTRADE ............................................................................................................................. 152 AVGBARSWINTRADE ............................................................................................................................ 153 AVGENTRYPRICE/I_AVGENTRYPRICE ....................................................................................................... 153 AVGENTRYPRICE_AT_BROKER ................................................................................................................ 153 AVGENTRYPRICE_AT_BROKER_FOR_THE_STRATEGY .................................................................................. 153 GROSSLOSS ........................................................................................................................................ 154 GROSSPROFIT ..................................................................................................................................... 154
I_AVGENTRYPRICE_AT_BROKER ............................................................................................................. 154 I_AVGENTRYPRICE_AT_BROKER_FOR_THE_STRATEGY ............................................................................... 155 I_CLOSEDEQUITY ................................................................................................................................. 155 I_CURRENTCONTRACTS/I_CURRENTSHARES ............................................................................................. 155
| 目 录
11
12 目 录
I_MARKETPOSITION/MARKETPOSITION ................................................................................................... 155 I_OPENEQUITY .................................................................................................................................... 156
LARGESTLOSTRADE .............................................................................................................................. 156 LARGESTWINTRADE ............................................................................................................................. 156 MAXCONSECLOSERS ............................................................................................................................. 156 MAXCONSECWINNERS ......................................................................................................................... 156 MAXCONTRACTSHELD/MAXSHARESHELD ................................................................................................ 157 MAXIDDRAWDOWN ............................................................................................................................ 157 NETPROFIT ......................................................................................................................................... 157 NUMEVENTRADES ............................................................................................................................... 157 NUMLOSTRADES ................................................................................................................................. 158 NUMWINTRADES ................................................................................................................................ 158 PERCENTPROFIT .................................................................................................................................. 158 TOTALBARSEVENTRADES ....................................................................................................................... 158 TOTALBARSLOSTRADES/TOTALBARSLOSTRADE .......................................................................................... 158 TOTALBARSWINTRADES/TOTALBARSWINTRADE ........................................................................................ 159 TOTALTRADES ...................................................................................................................................... 159 第24章 STRATEGY POSITION策略部位 ....................................................................................... 160 BARSSINCEENTRY ................................................................................................................................ 160 BARSSINCEEXIT ................................................................................................................................... 160 CONTRACTPROFIT ................................................................................................................................ 161 CURRENTCONTRACTS/CURRENTSHARES ................................................................................................... 161 CURRENTENTRIES ................................................................................................................................ 161 ENTRYDATE ........................................................................................................................................ 161 ENTRYNAME ....................................................................................................................................... 162 ENTRYPRICE ........................................................................................................................................ 162 ENTRYTIME ........................................................................................................................................ 163 EXITDATE ........................................................................................................................................... 163 EXITNAME .......................................................................................................................................... 164 EXITPRICE .......................................................................................................................................... 164 EXITTIME ........................................................................................................................................... 164 MARKETPOSITION ................................................................................................................................ 164
I_MARKETPOSITION _AT_BROKER .......................................................................................................... 165
MARKETPOSITION _AT_BROKER ............................................................................................................. 165
I_ MARKETPOSITION _AT_BROKER_FOR_THE_STRATEGY ............................................................................ 165
12
目 录
目 录 13
MARKETPOSITION _AT_BROKER_FOR_THE_STRATEGY ............................................................................... 165 MAXCONTRACTPROFIT ......................................................................................................................... 166 MAXCONTRACTS/MAXSHARES ............................................................................................................... 166 MAXENTRIES ...................................................................................................................................... 166 MAXPOSITIONSAGO ............................................................................................................................. 166 MAXPOSITIONLOSS .............................................................................................................................. 167 MAXPOSITIONPROFIT ........................................................................................................................... 167 OPENPOSITIONPROFIT .......................................................................................................................... 167 POSITIONPROFIT .................................................................................................................................. 168
第25章 STRATEGY POSITION SYNCHRONIZATION策略部位同步 ................................................ 169 CHANGEMARKETPOSITION .................................................................................................................... 169 PLACEMARKETORDER ........................................................................................................................... 169 第26章 STRATEGY POSITION TRADES策略部位交易 .................................................................. 171 OPENENTRIESCOUNT............................................................................................................................ 171 OPENENTRYCOMISSION ........................................................................................................................ 171 OPENENTRYCONTRACTS ........................................................................................................................ 172 OPENENTRYDATE................................................................................................................................. 172 OPENENTRYMAXPROFIT ....................................................................................................................... 172 OPENENTRYMAXPROFITPERCONTRACT ................................................................................................... 173 OPENENTRYMINPROFIT ........................................................................................................................ 173 OPENENTRYMINPROFITPERCONTRACT .................................................................................................... 173 OPENENTRYPRICE ................................................................................................................................ 174 OPENENTRYPROFIT .............................................................................................................................. 174 OPENENTRYPROFITPERCONTRACT .......................................................................................................... 174 OPENENTRYTIME ................................................................................................................................. 175 POSTRADECOMMISSION ....................................................................................................................... 175 POSTRADECOUNT ................................................................................................................................ 175 POSTRADEENTRYBAR ........................................................................................................................... 176 POSTRADEENTRYCATEGORY ................................................................................................................... 176 POSTRADEENTRYDATETIME ................................................................................................................... 177 POSTRADEENTRYNAME ........................................................................................................................ 177 POSTRADEENTRYPRICE ......................................................................................................................... 178 POSTRADEEXITBAR .............................................................................................................................. 178 POSTRADEEXITCATEGORY ...................................................................................................................... 179 POSTRADEEXITDATETIME ...................................................................................................................... 179
| 目 录
13
14 目 录
POSTRADEEXITNAME ........................................................................................................................... 180 POSTRADEEXITPRICE ............................................................................................................................ 180 POSTRADEISLONG ............................................................................................................................... 181 POSTRADEISOPEN ............................................................................................................................... 181 POSTRADEPROFIT ................................................................................................................................ 182 POSTRADESIZE .................................................................................................................................... 182 第27章 STRATEGY PROPERTIES策略属性 ................................................................................... 183 COMMISSION ...................................................................................................................................... 183 GETSTRATEGYNAME ............................................................................................................................. 183 MARGIN ............................................................................................................................................ 183 SLIPPAGE ............................................................................................................................................ 183 第28章 TEXT DRAWING绘制文本 .............................................................................................. 184 MC_TEXT_GETACTIVE ......................................................................................................................... 184 TEXT_DELETE ...................................................................................................................................... 185 TEXT_GETACTIVE ................................................................................................................................. 185 TEXT_GETATTRIBUTE ............................................................................................................................ 185 TEXT_GETBGCOLOR ............................................................................................................................ 186 TEXT_GETBORDER ............................................................................................................................... 186 TEXT_GETCOLOR ................................................................................................................................. 187 TEXT_GETDATE ................................................................................................................................... 187 TEXT_GETFIRST ................................................................................................................................... 187 TEXT_GETFONTNAME .......................................................................................................................... 188 TEXT_GETHSTYLE ................................................................................................................................ 188 TEXT_GETNEXT ................................................................................................................................... 188 TEXT_GETSIZE .................................................................................................................................... 189 TEXT_GETSTRING ................................................................................................................................ 189 TEXT_GETTIME ................................................................................................................................... 189 TEXT_GETTIME_S................................................................................................................................ 190 TEXT_GETVALUE ................................................................................................................................. 190 TEXT_GETVSTYLE ................................................................................................................................ 190 TEXT_NEW ......................................................................................................................................... 191 TEXT_NEW_S ..................................................................................................................................... 191 TEXT_NEW_SELF ................................................................................................................................. 192 TEXT_NEW_SELF_S ............................................................................................................................. 192 TEXT_SETATTRIBUTE ............................................................................................................................ 193
14
目 录
目 录 15
TEXT_SETBGCOLOR ............................................................................................................................. 193 TEXT_SETBORDER ............................................................................................................................... 193 TEXT_SETCOLOR ................................................................................................................................. 194 TEXT_SETFONTNAME........................................................................................................................... 194 TEXT_SETLOCATION ............................................................................................................................. 195 TEXT_SETLOCATION_S .......................................................................................................................... 195 TEXT_SETSIZE ..................................................................................................................................... 195 TEXT_SETSTRING ................................................................................................................................. 196 TEXT_SETSTYLE ................................................................................................................................... 196
第29章 TEXT MANIPULATION文本操作 ..................................................................................... 197 DOUBLEQUOTE ................................................................................................................................... 197 INSTR ................................................................................................................................................ 197 LEFTSTR ............................................................................................................................................. 198 LOWERSTR ......................................................................................................................................... 198 MIDSTR ............................................................................................................................................. 198 NEWLINE ........................................................................................................................................... 198 NUMTOSTR ........................................................................................................................................ 198 RIGHTSTR ........................................................................................................................................... 199 SPACES............................................................................................................................................... 199 STRLEN .............................................................................................................................................. 199 STRTONUM ........................................................................................................................................ 199 TEXT .................................................................................................................................................. 200 UPPERSTR .......................................................................................................................................... 200 第30章 TRENDLINE DRAWING趋势画线 .................................................................................... 201 MC_TL_GETACTIVE ............................................................................................................................ 202 MC_TL_NEW .................................................................................................................................... 202 TL_DELETE ......................................................................................................................................... 202 TL_GETACTIVE .................................................................................................................................... 202 TL_GETALERT ..................................................................................................................................... 202 TL_GETBEGINDATE ............................................................................................................................. 203 TL_GETBEGINTIME.............................................................................................................................. 203 TL_GETBEGINTIME_S .......................................................................................................................... 204 TL_GETBEGINVAL ............................................................................................................................... 204 TL_GETCOLOR .................................................................................................................................... 204 TL_GETENDDATE ................................................................................................................................ 205
| 目 录
15
PowerLanguage概述 5
1300=1:00PM、130000=1:00:00PM。
在PL中的日期是以YYYMMdd格式,其中YYY表示自1900至今的年份,MM表示月,dd表示日。这种格式又叫EL格式。如2013年1月4日的EL格式为1130104。 F.变量
变量用来存储数值、字符串或逻辑值(true/false)。存在变量中的值可在整个脚本中通过变量名称来引用,并可用在任何时间有脚本改变。变量使用前需要先声明。更多信息,请看关键字Variable G.数组
数组是多元素的变量,更多信息,请看关键字Array 二、脚本如何执行
PowerLanguage公式可用在由MultiCharts创建的图表和投资组合回测(Portfolio Backtester)中。
可用的PL公式分为两个主要类型:指标(Indicators)和信号(Signals)。
一个指标是一个可视的技术分析工具,用来分析市场条件、定义和预测趋势以及市场模式。指标即是一个可视化的数学公式,包含一个或多个画线、直方图、一系列点或穿越状态、高价和低价、左右的tick或在一个图上包含以上全部的信息。指标的计算只能用价格、成交量数据。
一个信号是一个机械的技术分析工具,用来系统地根据一系列交易规则指定进场或出场点位。交易点位在图表上以文字和箭头标示。策略可以容易地由多个信号组合。由信号指定的进出场点位,可以用来发送委托单到交易商,完成全自动的交易执行。
根据它们不同的使用目的,指标和信号对于价格数据的计算有不同的方式。下面分别阐述两者。
在阐述前,需要先了解两个基本概念:完成bar和指标运算参考的最大bars数量。 A.完成bar
当一个bar已经收盘并且无法加入额外的tick时,可认为此bar是一个完成bar。
*基于时间的图表,一旦设定的bar周期的时间间隔已过,下一个时间戳的第一笔tick已接收到,那么这个bar为已收盘;或者三秒内没有再收到额外的tick,也视为这个bar已经结束。
*基于tick的图表,一旦定义的bar数量已经到来,则这个bar视为已结束。
| PowerLanguage概述
5
6 PowerLanguage概述
*基于范围的图表,一旦接收的新tick的价格超出原始的价格范围,则这个bar视为已结束。
*基于量的图表,一旦接收到的tick为当前bar所带来的成交量达到定义的合约数目,则这个bar视为已结束。
*基于变动的图表,一旦接收到的tick为当前bar所带来的的价格达到定义的价格变动数,则这个bar视为已结束。 B.指标运算参考的最大Bars数量
一个公式脚本可以参考前面bars的值来用于当前bar的计算。当在脚本中参考了前面N根bar,则公式可以从第N+1根bar开始可以看到绘图或委托行为。为了能让脚本开始执行计算, 前面预留了bars数目,叫做指标运算参考的最大Bars数量,或MaxBarsBack。MaxBarsBack的值可以选择「自动检测」或「用户指定」(可在设置指标->属性中设定)。
当选择为「自动检测」时,MaxBarsBack将会初始化为指标中引用的最大数据偏移量(即最大的N Bars Ago中的N值)。然而,脚本中引用的数据偏移如果是变量,MaxBarsBack的初始值可能会太小;在这种情形下,MaxBarsBack的值将自动增加5或乘以1.618,产生一个较高的值,在重新计算指标。
MaxBarsBack自动检测的过程可能会导致:在指标第一次应用到图表上时,某些函数在图上最开始的一些bar的计算重复。为了避免这种情况,MaxBarsBack可以设定为「用户指定」。
选择最小的MaxBarsBack来满足一个特定的指标或信号的计算,可手动设定这个值。推荐的初始值为50。 1.指标执行方式
指标的目的是在图表上绘出可视的数学公式,绘图的创建基于一个或多个价格数据系列。
当指标被插入到图表中时,第一次的计算是对于完成bar一个接着一个的计算,并从图上第一个bar开始。整个脚本对于每个完成bar都执行一次。在每个bar上,依据计算结果,指标脚本可以向外输出图形、文字、改变绘图颜色、音频警报等。如果指标脚本中含有前面bar的引用值,那么指标执行输出的第一个Bar将跟随“指标参考运算的最大Bars数量”的不同而不同。
一旦图上所有的完成bar都执行完成,一个指标将继续执行图上最后一个bar,以tick by tick的运算,不等待这根bar的形成。一个未完成bar是自上一个bar完成以来,接收到的所有tick的总和。新的一笔tick接收时,整个脚本将会在那根Bar执行,直到此bar已完
6
PowerLanguage概述
PowerLanguage概述 7
全形成并且下一个Bar已开始。指标脚本对于未完成bar的方式和已完成bar相同,并可以在基于未完成bar的计算结果上做出行动。
请注意只有最后的未完成bar在每一个新的tick收到时会重新计算,并非整个数据系列。
指标在一个bar的执行过程叫做重新计算或更新。默认指标更新是基于每笔tick资料的。但是,在某些情形下,它可能出现不良状况;
每笔tick更新大量的复杂指标需要更多实质性的系统资源。每笔tick资料都更新的操作可以在MultiCharts的设置中关闭。 2.信号执行方式
信号是策略的基本组件。信号实质上比指标更复杂,需要考虑大量的因素。信号支持回测和自动交易执行。
当信号被插入到图表中时,第一次的计算是对于完成bar一个接着一个的计算,并从图上第一个bar开始。整个脚本对于每个完成bar都执行一次。在每个bar上,依据计算结果,信号脚本可以执行一个或多个交易委托。委托单会在图上标记箭头或其他标识,可伴有弹出框或音频警报等。如果信号脚本中含有前面bar的引用值,那么信号执行输出的第一个Bar将跟随“指标参考运算的最大Bars数量”的不同而不同。
默认,一旦图上所有的完成bar都执行完成,一个信号将中断执行,直到新的完成bar已形成,然后全部脚本会在新的bar再次执行。
信号执行方式可以选择启用bar内交易来调整。当开启bar内交易执行状态为已启用时,信号对于最新的bar计算不用等到它的完成。而是,每当新的一笔tick接收到时,最新的bar就会重新计算一次,直到这根bar的完成并且下一根bar已经开始。一个未完成bar是自上一个bar完成以来,接收到的所有tick的总和。启用bar内模式,信号脚本对于未完成bar的方式和已完成bar相同,并可以在基于未完成bar的计算结果上做出行动。
请注意只有最后的未完成bar在每一个新的tick收到时会重新计算,并非整个数据系列。 A.委托单执行优先级
一个信号可以在一个bar中执行多个委托单。委托单可以由相同或不同的语句执行。
根据执行语句类型的不同,委托单的执行分为3组: 1.由 This Bar [On] Close语句执行
2.由 Next Bar [At] Market和Next Bar [At] Open语句执行
3.由Next Bar [At] Price Limit和Next Bar [At] Price Stop语句执行
| PowerLanguage概述
7
8 PowerLanguage概述
在一个委托组内,委托单执行的优先级排序是基于当前部位(持仓)的:
委托单执行优先级表 数值高者优先级高 持仓部位 无持仓(Flat) 多头(Long) 1 1 多头进场(Long Entry) 1 2 空头进场(Short Entry) - 1 多头出场(Long Exit) - - 空头出场(Short Exit) 空头(Short) 2 1 - 1 多个同方向的委托被分配的相对于彼此的优先级,是基于委托语句在信号脚本中的列表顺序而顺序执行。当多个信号组合来创建一个策略时,由不同信号执行的、同方向的委托被分配的相对于彼此的优先级,是基于委托单所在信号出现在信号标签中的顺序。先插入到图表中的信号顺序靠前。
一旦委托单被排序后,优先级最高的先执行。有一个重要注意事项:与当前持仓部位方向相反的进场委托,不是简单的只平掉当前的持仓,而是会反向开仓。比如:当持有1手空头(Short)时,1手多头(Long)的进场委托,结果将会是平掉空头持仓,并且建立1手多头持仓。
考虑到持仓部位的变化、委托单执行的结果,余下的委托单将会再排序,最高优先级的委托仍然先执行。
这个过程一直重复,直到全部的委托单都已执行,或直到剩下的委托没有可以被执行的。比如:只剩出场委托单,而当前已经没有持仓。
如果所剩的进场委托方向和当前持仓部位相同,那么在部位限制启用(打勾)的状态下,这些委托单可以被执行。部位限制的设定可最多允许N笔与目前仓位同向的进场委托单(详细见策略属性->属性->部位限定)。
剩下的不可执行的委托单会被丢弃。
B.委托单执行优先级举例:
在如下委托中:空头出场(SX)、空头进场(SE)、多头进场(LE)、多头出场(LX)、多头进场(LE),当前持仓部位为空头,则多个委托单执行状况如下:
1.委托单的顺序根据优先级以降序排列:多头进场(LE)、多头进场(LE)、空头出场(SX)、空头进场(SE)SX SE LE LX LE (不可执行委托:多头出场(LX)) 2. 多头进场(LE)执行;当前持仓为多头 SX SE √ LX LE 8
PowerLanguage概述
PowerLanguage概述 9
3.委托单的顺序根据优先级以降序排列:空头进 场(SE)、多头进场(LE)、多头出场(LX)(不可执行委 托:空头出场(SX)) 4. 空头进场(SE)执行;当前持仓为空头 5. 委托单的顺序根据优先级以降序排列:多头进场(LE)、空头出场(SX)(不可执行委托:多头出场 (LX)) 6. 多头进场(LE)执行;当前持仓为多头 7. 委托单的顺序根据优先级以降序排列:多头出场(LX)(不可执行委托:空头出场(SX)) 8.多头出场(LX)执行;当前无持仓 9.只剩一个空头出场(SX)的委托,不可执行,将被丢弃。 SX √ SX √ √ LX LE SX √ √ √ √ LX √ √ √ √ √ SX √ 以上委托单执行结果,将从一个空头持仓变成无持仓。 三、字典阅读
本书为MultiCharts软件的编程语言PowerLanguage的字典功能,提供了详细的中文说明。
章节依照公式编辑器的字典顺序而排,即按照功能和字母顺序。文字所使用的颜色代表不同类型含义。经测试的注意事项,会以红色标识;无特别指定类型的,会以灰色标识。重点事项,会以加粗标识。其他分别举例如下: 函数 Getaccount(来自第1章 Getaccount语法) 关键字 Alert(来自第2章 Alert语法) 全局变量 Value1~ Value999,Condition1~ Condition99 变量 ID(来自第2章 AlertEnable范例) 参数 Overnight(来自第6章 False范例) 数组 ArrayName1(来自第9章 Array语法) 数值 3(来自第1章 Getaccount范例) 字符串 \(来自第1章 Getaccount范例) 跳跃字 Of(来自第7章 Ago范例) 其中全局变量为PowerLanguage内置的变量,使用较为方便快捷, | PowerLanguage概述
9
10 PowerLanguage概述
无需自定义。自定义的变量,程序的可读性较强。
各字典的标题中如有单斜线“/”分开的两个或多个,它们是同等的含义。如:第7章中Close/C,都是收盘价的含义,而C是Close的简写。
10
PowerLanguage概述
第1章 Accounts and position账户与部位 11
第1章 Accounts and position账户与部位
本章函数可取到实盘账户资金信息和部位信息,范例中做了说明,若需详细的测试信息可以至“策略交易*高峰会”论坛里查看:
MC获取实时资金:
http://www.aboutels.com/forum-viewthread-tid-14892-highlight-??????.html
MC7中实时资金account和部位position测试:
http://www.aboutels.com/forum-viewthread-tid-14971-highlight-??????.html Getaccount 返回MC交易追踪器账户列表中指定位置的账户名。 如果GetNumaccounts返回的值非零,则 在 1<=AccountLoc<=GetNumaccounts的范围内,函数返回值为账户名。 在范围外的序号,函数返回值为一个空字符串(””)。 Getaccount(AccountLoc) AccountLoc——MC交易追踪器账户列表中账户的序号。 此函数可以同GetNumaccounts一起使用,用来列出可用的经纪商账户。 如果MC交易追踪器账户列表为 ”DU12345”,”DU23456”,”DU34567”,”1999_2-0000295”, 则: Getaccount(3)返回值为”DU34567” Getaccount(5)返回值是”” 说明 语法 参数 注意 范例 GetaccountID 说明 返回信号插入的图表中,自动交易设定的交易账号。 语法 GetaccountID( ) 注意 测试无输出。不建议使用。 如果信号插入的图表中,自动交易设定的交易账号范例 是”DU34567”,则:GetaccountID( )的返回值为”DU34567”。
| 第1章 Accounts and position账户与部位
11
12 第1章 Accounts and position账户与部位
GetNumaccounts 说明 返回MC交易追踪器账户列表的账号数量。 语法 GetNumaccounts 如果经纪商账账号列表为: 范例 ”DU12345”,”DU23456”,”DU34567”,” 1999_2-0000295”,则: GetNumaccounts返回值为4。 GetNumPositions 说明 语法 参数 注意 范例 返回MC交易追踪器持仓列表中指定账号持仓的商品的数量。 (非真实的经纪商持仓数量)。 GetNumPositions(Account) Account——经纪商账号名,字符串型。 如果是在同一行商品名称是类似CTP.CFFEX.IF.HOT(CTP.CFFEX.IF.201304), 则该商品相当于顺次占用列表中的两行,算2个商品名称。 如果账号”DU12345”在MC交易追踪器上的持仓商品数量是3,则:GetNumPositions(”DU12345”) 返回值是3。 GetPositionAveragePrice 说明 返回指定账户指定商品的持仓平均价格。 语法 GetPositionAveragePrice(Symbol,Account) Symbol——指定商品名称 参数 Account——指定的经纪商账号 注意 测试发现,实际输出值一直是0.00 如果指定账号指定商品的持仓平均价格为1.3456,则函数返回范例 值为1.3456。 GetPositionOpenPL 说明 返回MC交易追踪器持仓列表中指定账号和商品的浮动盈亏。 语法 GetPositionOpenPL(Symbol,Account) Symbol——指定商品名称 参数 Account——指定的经纪商账号 注意 暂时未实现该功能,函数取得值为0.00。 如果MC交易追踪器持仓列表中指定账户指定商品的浮动盈范例 亏值为15,则函数返回值为15。 12
第1章 Accounts and position账户与部位
第1章 Accounts and position账户与部位 13
GetPositionQuantity 返回指定账号指定商品的持仓的数量。 持仓方向为空时,对应负数;为多时,对应正数。 语法 GetPositionQuantity(Symbol,Account) Symbol——指定商品名称 参数 Account——指定的经纪商账号 如果账号\中的商品\的持仓数量为1000,则:范例 GetPositionQuantity(\)返回值为1000。 说明 GetPositionSymbol 说明 语法 参数 返回MC交易追踪器持仓列表中指定账户指定位置的商品名称。 GetPositionSymbol(Account, PositionLoc) Account——指定的经纪商账号 1 <= PositionLoc <= GetNumPositions ——指定账号的持仓列表行号 如果是在同一行商品名称是类似CTP.CFFEX.IF.HOT(CTP.CFFEX.IF.201304), 则该商品相当于顺次占用列表中的两行,算2个商品名称。 如果账号DU12345的持仓列表中行号为3的商品是ESZ1,则:GetPositionSymbol(\, 3) 返回值为\。 注意 范例 GetPositionTotalCost 说明 语法 参数 范例
返回MC交易追踪器的持仓列表中指定账号指定商品持仓额。 用下面的公式计算: PTC(持仓额)=AEP(持仓平均价格)*TMP(持仓数量) GetPositionTotalCost(Symbol,Account) Symbol——指定商品名称 Account——指定的经纪商账号 GetPositionTotalCost(\); 计算并返回账号DU12345中商品ESZ1的持仓总额。 | 第1章 Accounts and position账户与部位
13
14 第1章 Accounts and position账户与部位
GetRTAccountEquity 返回账户列表中指定账号的权益(对应达钱资金查询的今日余额)。 语法 GetRTAccountEquity(Account) 参数 Account——指定的经纪商账号 如果MC交易追踪器中账号DU12345的权益为$100000。则:范例 GetRTAccountEquity(\返回值为100000。 说明 GetRTUnrealizedPL 返回账户列表中指定账号的权益(对应达钱资金查询的今日余额)。 语法 GetRTAccountEquity(Account) 参数 Account——指定的经纪商账号 如果MC交易追踪器中账号DU12345的权益为$100000。则:范例 GetRTAccountEquity(\返回值为100000。 说明 14
第1章 Accounts and position账户与部位
第2章 Alert警报 15
第2章 Alert警报
在多商品或多策略同时交易时,如果有提示信息,将会更方便我们对策略的跟踪并及时作出反应。MultiCharts为用户提供了方便的Alert警报提示功能,如下图在设置指标时,可启用警报。
图2.1 Alert警报设定
分有音频、弹出框、电子邮件,警报条件根据需要可选每根bar收盘时或每笔成交资料(即依Tick计算)发出警报。在选择每笔成交资料到来发出警报时,为保证信号的计算和指标一致,实时资料下建议信号开启bar内交易(在回测状态下,另需使用精细逐笔tick)。
MC7版本只针对指标提供警报功能,后续的MC8.5版将会对信
| 第2章 Alert警报
15
16 第2章 Alert警报
号策略也提供相同的Alert功能。
Alert 弹出一个包含必要文本的警示窗口。文本可以是动态的,静态的或无文本。 语法 Alert *如果Alert中不设文本,则弹出包含来源,商品,周期,价格的警报窗口。 注意 *Alerts 只在最后一根Bar显示。 *Alerts 设定的详细信息参考设置指标》警报 弹出一个没有文本信息的警报窗口: Alert; 弹出一个包含动态文本的警报窗口并显示星期日期: Alert(Text(\, DayOfWeek(Date))); 当收盘价大于前根K线的收盘价时,弹出包含静态文本的警报窗口: 范例 If Close > Close[1] Then Alert(Text(\)); 说明 AlertEnabled 说明 语法 注意 如果启用警报则AlertEnabled返回值为True。此信息可以让程式代码运算执行更加高效。 此功能也可用来在用户忘记开启警报时发出通知。 AlertEnabled *警报只在最后一根Bar产生。 *AlertEnabled 和 CheckAlert的不同: AlertEnabled在每一个Bar都会执行,CheckAlert只会在最最后一根Bar执行。 *若启用警报,则AlertEnabled返回True。 下例说明了如何在用户忘记开启警报时发出通知: Variable: ID(-1); If AlertEnabled=False And LastBarOnChart_S=True Then ID = Text_New_S(Date, Time_S, Low, \第2章 Alert警报
范例 16
第2章 Alert警报 17
Format Study > Properties >Alerts\); Cancel Alert 说明 语法 注意 取消警报。用于脚本中警报过多时在某些条件下关闭一些警报。 Cancel Alert Alerts只在最后一根Bar产生。 下例说明了如何根据时间关闭所有警报。在10:00pm之后,警报不会显示: If Close > Close[1] Then Alert(\); If Volume > Volume[1] Then Alert(\); If Volatility(5) > Volatility(5)[1] Then Alert(\); If OpenInt > OpenInt[1] Then Alert(\); If Time >= 2200 Then Cancel Alert; 范例 CheckAlert 说明 语法 注意 如果在设置指标》警报中设置启用警报,则CheckAlert返回true。 True/false 只在最后一根Bar返回。 CheckAlert *AlertEnabled 和 CheckAlert的不同:AlertEnabled在每一个Bar都会执行,CheckAlert只会在最后一根Bar执行。 *警报只在最后一根Bar产生。 下例表示当警报未开启时,避免历史数据计算冗余。 当警报启用时,对警报条件进行计算: If CheckAlert Then Begin If Volume >= 2 * Average(Volume, 10) Then Alert (\going up\); End; 范例
| 第2章 Alert警报
17
18 第3章 Arrow drawing画箭头
第3章 Arrow drawing画箭头
对于特定的行情趋势或反转点等其他情形,我们希望能够在图上有特别的标识,方便观看和判断。那么,在MultiCharts图表窗口中,使用绘图工具可以增加向上或向下的箭,而此功能也可以用策略程序来实现,本章则详细说明了程序实现画箭头的方法。
Arw_Delete 说明 语法 参数 范例 删除图表上指定编号的箭头。删除成功返回0,如果指定编号无效则返回-2。 Arw_Delete(ObjectID) ObjectID——数值表达式,箭头物件的编号。 删除编号为3的箭头物件: Value1=Arw_Delete(3); Arw_GetActive 说明 语法 注意 返回目前选取的箭头物件的编号。返回-1为当前未选取任何箭头物件。 Arw_GetActive *箭头编号是在箭头物件被创建时Arw_New对应的返回值。 *测试此关键字,不管当前箭头是否被选中,每根Bar都会运算,print值会随新Bar的到来而改变。 将目前选取的箭头物件编号存入变量Value1: If c > c[1] then Value1=Arw_New_s(Date,Time_s,High,False); Value2=Arw_GetActive; Print(Value2,” “,time_s); 范例 Arw_GetColor 说明 语法 参数 返回 注意 18
取得箭头物件的颜色(RGB色码或传统色码)。 Arw_GetColor(ObjectID) ObjectID——数值表达式,箭头物件的编号。 数值——箭头颜色编码; -2——无效的箭头物件编号。 ObjectID是在箭头物件被创建时Arw_New对应的返回值。 第3章 Arrow drawing画箭头
第3章 Arrow drawing画箭头 19
取得编号为3的箭头物件的颜色值(RGB色码表示): Value1=Arw_GetColor(3); 取得编号为3的箭头物件的颜色值(传统色码表示): [LegacyColorValue=True]; Value1=Arw_GetColor(3); 范例 Arw_GetDate 说明 语法 参数 返回 注意 范例 取得箭头物件所在Bar的日期。 日期显示为YYYMMdd格式,YYY表示自1900至今的年份,MM表示月,dd表示日。 Arw_GetDate(ObjectID) ObjectID——数值表达式,箭头物件的编号。 数值——箭头所在日期; -2——无效的箭头物件编号。 ObjectID是在箭头物件被创建时Arw_New对应的返回值。 取得编号为3的箭头物件所在的Bar的日期: Value1=Arw_GetDate(3); Arw_GetDirection 说明 语法 参数 返回 注意 范例 取得箭头物件的方向(垂直位置)。 Arw_GetDirection(ObjectID) ObjectID——数值表达式,箭头物件的编号。 True——向下箭头; False——向上箭头或无效的物件编号。 ObjectID是在箭头物件被创建时Arw_New对应的返回值。 取得编号为3的箭头物件的方向,将返回值赋给变量DownArrow : Variable:DownArrow(False); DownArrow=Arw_GetDirection(3); Arw_GetFirst 说明 语法 参数 取得指定条件下最先新增在图表上的箭头物件编号。 Arw_GetFirst(Origin) Origin——数值表达式,指定箭头物件产生条件,范围为1~7: 1 — 目前公式所新增的箭头物件 | 第3章 Arrow drawing画箭头
19
正在阅读:
powerlanguage教程06-22
四级预测题05-13
顺丛台酒项目可行性研究报告(发改立项备案+2013年最新案例范文)详细编制方案09-16
做一名优秀的主管06-10
中考作文_《别样的校园生活》02-23
员工合规考试答案10-09
妈妈的生日作文300字06-27
改安全自控体系(1)03-08
微生物检测顶岗实习报告09-16
- 多层物业服务方案
- (审判实务)习惯法与少数民族地区民间纠纷解决问题(孙 潋)
- 人教版新课标六年级下册语文全册教案
- 词语打卡
- photoshop实习报告
- 钢结构设计原理综合测试2
- 2014年期末练习题
- 高中数学中的逆向思维解题方法探讨
- 名师原创 全国通用2014-2015学年高二寒假作业 政治(一)Word版
- 北航《建筑结构检测鉴定与加固》在线作业三
- XX县卫生监督所工程建设项目可行性研究报告
- 小学四年级观察作文经典评语
- 浅谈110KV变电站电气一次设计-程泉焱(1)
- 安全员考试题库
- 国家电网公司变电运维管理规定(试行)
- 义务教育课程标准稿征求意见提纲
- 教学秘书面试技巧
- 钢结构工程施工组织设计
- 水利工程概论论文
- 09届九年级数学第四次模拟试卷
- powerlanguage
- 教程
- 用牛顿环测平凸透镜的曲率半径
- 教师工作感悟随笔:我和孩子们的故事
- 2019年全国各地中考语文真题分类汇编课外文言部分学生版
- :毕业设计(论文)格式要求及范例
- 毕业论文 - 图文
- 2014年乐理模拟试题练习
- 最新6年高考4年模拟分类汇编:牛顿运动定律
- 仪表及自动控制设备管理制度
- 北京交通大学2008 - -2009第二学期随机数学期末试题答案48A
- 初中数学沪教版(五四学制)《七年级上册》《第十一章 图形的运
- 2014-2015年山西省太原五中高一(上)期中数学试卷及参考答案
- 优品课件之主权国家和国际组织
- 民国蒋氏将军全谱
- 副市长在县一高中新校区建设奠基仪式上的讲话(多篇范文)
- 营养师助理实习报告
- 班级文化建设
- 人教版小学语文四年级上册字帖 - 图文
- 投标商务标 总 说 明
- 2013长沙职业技术学院单独招收听障学生考试心理健康调查问卷
- 教职成厅函46号