Parameter: UpColor(Red), DnColor(Green), CompBars(6) Variables: haClose(0), haOpen(0), haHigh(0), haLow(0), color(0), sendSignal(0),Position(""),PriceType(""),Price("") If BarNumber = 1 then haOpen = open haClose = (Open + High + Low + Close) / 4 haHigh = MaxList( high, haOpen, haClose) haLow = MinList( low, haOpen, haClose) End If if BarNumber > 1 then haClose = (Open + High + Low + Close) / 4 haOpen = (haOpen [1] + haClose [1]) / 2 haHigh = MaxList(High, haOpen, haClose) haLow = MinList(Low, haOpen, haClose) if haClose > haOpen then color = UpColor else color = DnColor End If for value1 = 1 to CompBars if haOpen <= MaxList(haOpen[value1], haClose[value1]) and haOpen >= MinList(haOpen[value1], haClose[value1]) and haClose <= MaxList(haOpen[value1], haClose[value1]) and haClose >= MinList(haOpen[value1], haClose[value1]) then color = color[value1] End If End For sendSignal = 0 If Color = UpColor And CurrentContracts <= 0 Then Buy ("BUY") THIS BAR AT MARKET sendSignal = 1 End If If Color = DnColor And CurrentContracts >= 0 Then Sell ("SELL") THIS BAR AT MARKET sendSignal = 1 End If If sendSignal = 1 Then Position=NunToStr(CurrentContracts,0) {註解:定義Position控制策略的「倉位」變化} PriceType="0" {註解:定義PriceType控制策略訊號的「價格種類」(0代表限價單)} Price=NunToStr(Close,0) {註解:定義Price控制訊號委託的「價格」} FileDelete("C:\signalTXT.txt") {註解:當交易訊號出現時,刪除上一個訊號產生的檔案;C:\signalTXT.txt表示文字訊號檔的「儲存位置」及「檔案名稱」} FileAppend("檔案路徑\訊息文字檔案名稱.txt",(cdate(date) +" "+ ctime(time)+" "+Position+' '+PriceType+' '+Price; {註解:將交易訊號轉換成StarBridge可讀取的文字格式 依照證券商品文字格式:日期 時間 倉位 價格種類 價格}