Inputs: Price( Close ), Length( 9 ), Displace( 0 ); Variables: Avg( 0 ) ; Avg = AverageFC( Price, Length ) ; if Displace >= 0 or CurrentBar > AbsValue( Displace ) then begin Plot1[Displace]( Avg, "Avg" ) ; { alert criteria } if AlertEnabled and Displace <= 0 then begin if Price crosses over Avg then Alert("Price crossing over average" ) else if Price crosses under Avg then Alert( "Price crossing under average" ) ; end ; end ; 用户在声明变量时,Var、Vars、Variable、 Variables都是可行的,效果是一样的 EL不区分大小写 非执行单词: the of at //注释1 {注释2} " " 双引号,定义字符串、文本、标签 { } 大括号,多行注释,大括号中间的语句不执行 数值型:int整型 float单精度浮点型 double双精度型 Var: double NetChange(0); NetChange = Close[0]; 布尔型:True False Var: UpBar (false); UpBar = Close > Close[1]; 字符型:string (“内容 ”) :Var: string text(“1234”); text = "申购价格不得为0." 数学运算符: + 加 Entryprice + 0.5 (开仓价+0.5) - 减 Entryprice + 0.5 (开仓价-0.5) * 乘 Entryprice+PriceScale*2 / 除法 Entryprice+(H+L)/2 Mod(n,d) 取余 n mod d Power(a,b) 乘方 a^b *的运算速度高于/ ,在不损失运算精度的情况下,除法最好转换成乘法 关系运算符:=(等于) <>(不等于) > (大于) <(小于) >=(大于等于) <=(小于等于) Cross Over = Crosses Over= Cross Above = Crosses Above Cross Under = Crosses Under = Cross Below = Crosses Below Input:输入值名称(默认值); 例: Input:Facetor(1.005); Var: double NetChange(0); //变量声明语句 NetChange = Close – Close[0]; //变量赋值语句 Once条件语句(满足条件后只执行一次) Once True/False(逻辑表达式) Begin Action to be taken(执行的动作); Action to be taken(执行的动作); … End; 例: Var: Counter(0); once ( CurrentBar = 1 ) and ( Counter = 0 ) begin Counter = 1000; end; IF条件语句 1.If…Then… If average(close,5) cross over average(close,20) and marketposition<>1 then buy next bar at market; 2.If…Then…Else… if Close > Average(Close, 20) then SetPlotColor(1, Red) //動作A後面沒有分號”;” Else //Else後面沒有分號”;” SetPlotColor(1, Green); //動作B後面有分號”;”作為語法結尾 3.If…Then Begin…End(如果符合條件就去執行A、B、C…等動作) if Close > Average(Close, 20) then begin SetPlotColor(1, Red); //動作A後面有分號”;” Alert; //動作B後面有分號”;” End; //End後面有分號”;” 4.If…Then Begin…End Else Begin…End if Close > Average(Close, 20) then begin SetPlotColor(1, Red); Alert("Close Above Average"); End //沒有分號”;” Else begin //沒有分號”;” SetPlotColor(1, Green); Alert(“Close Below Average”); end; For循环语句 For value = value1 to value2 Begin Action to be taken(执行的动作); Action to be taken(执行的动作); … End 例: Var: int loop(0),int sum(0); For loop = 0 to 10 Begin sum = sum + loop; End; While循环语句 While 逻辑表达式 Begin Action to be taken(执行的动作); Action to be taken(执行的动作); … End; 例: Var:int sum(0),int loop(1); While loop <= 10 Begin sum = sum + loop ; loop= loop + 1; End; Plot绘图语句 PlotN(数据表达式, " 图形名称" );其中,N=1,2,…,99 例:Plot1(Open, " 开盘价" ); Plot1[3](Value1); 将它绘制在图表的之前(左) 3 条柱状线上。使用负数在当前柱状线之后(右) 3 条的柱状线上绘制 想要指定绘图颜色和宽度,不能省略绘图名称, 例如:Plot1(Volume, "V", Black); Alert预警语句 发出音频或电子通知 例:If Close > Highest(High,10) then Alert ("NewHigh"); Print语句 格式:Print(“标签”, 数值, “标签”, 数值,…); 例:Print(“Time”,time:4:0,“Value1”,Value1); 注:time:4:0表示输出时间的数值,小数点前4位,小数点后0位。 Commentary语句 注释语句,适用于图形分析、雷达屏 格式: Commentary (“标签”, 数值, “标签”, 数值,…); 例:Commentary(“Date”,Date,“Value1”,Value1); |