基本語法(大小寫要注意) 1.IF.....Then End If 範例: IF close>high[1] then ("買") Next bar at market End If 2.Condition Variables=資料內容 範例: Condition1=close>open+(High[1]-Low[1])/2 IF Condition1 then ("買") Next bar at Market End If 3.Value N(宣告常數與變數) Value1=close>open+(High[1]-Low[1])/2 close>open+Value1 4.Variables(變數宣告) Variables:價格區間(0) Variables:成交量增減(True) 也可寫成 Variables:價格區間(0),成交量增減(True) 範例: Variables:價格區間(0),成交量增減(True) 價格區間=(High[1]-Low[1])/2 成交量增減=Volume>Volume[1]*1.03 IF close>open+價格區間 and 成交量增減 then ("買") Next bar at Market End If IF open>close then ("賣") Next bar at Market End If 5.應用函數撰寫買賣訊號 IF Average(close,9) cross over Average(close,18) then ("買") Next bar at Market End IF IF Average(close,9) cross Under Average(close,18) then ("賣") Next bar at Market End IF 6.Parameter(宣告變數名稱) Parameter:FastLen(9),SlowLen(18) IF Average(close,FastLen) cross over Average(close,SlowLen) then ("買") Next bar at Market End If IF Average(close,FastLen) cross Under Average(close,SlowLen) then ("賣") Next bar at Market End If 7.Market(市價) IF condition1 then Buy End If IF condition1 then Buy this bar at market End 8.or higher(相同於Buy....Stop及 Sell....Limit) IF condition1 then buy at open or higher End IF 9.停損信號 買進停損 Parameter:停損金額(3000) Variables:合計成本(0),OrderPrice(0) If MarketPosition=1 Then 合計成本 = 停損金額 + Commission_B OrderPrice=Entryprice(0)-(合計成本/PointValue) Exitlong("多停損") at OrdePrice Stop End If 賣出停損 Parameter:停損金額(3000) Variables:合計成本(0),OrderPrice(0) If MarketPosition=-1 Then 合計成本 = 停損金額 + Commission_S OrderPrice=Entryprice(0)+(合計成本/PointValue) Exitlong("空停損") at OrdePrice Stop End If Commission_B 買進的手續費用 Commission_S 放空的手續費用 PointValue 每一點的價值,股票為1元台指為200元 9.多筆個股策略 Condition1=close of Data1>close[1] of Data1 Condition2=low of Data2 >low[1] of Data2 and close of Data2>close[1] of Data[2] Conition3=close of Data1=1 Then MA=Summation/Length Else MA=0 End If 備註:簡單的例子假設計算12日移動平均線時,我們必須計算12日股價的加總 因此我們必須讓股價相加重複11次 counter 是 計數器變數 從0開始必須不斷重複計算12-1次 11.Draw1(high) Draw2(close,"指數名稱",Blue,Default,2) 顏色 粗細 12.Alert("警示") 出現提示視窗 IF Close>High[1] then Alert ("警示") End IF 13.AlertEnabled IF AlertEnabled Then Alert("提示") End If 融資 mpbalance 融卷 ssbalance 三大法人 corpobs 外資 qfiiobs 自營商 toaobs 投信 sitobs