
為什麼XQ用愈久,問題愈多? 都沒有人遇過? XQ收費是不是有該打折?
有些時候可能是程式的問題。我常常講,不要什麼錯都怪XQ。先試著從程式的邏輯去找問題。若需要協助,可貼到論壇來,我可以提供協助。
你在一開盤去抓資料,也許有些資料還沒有準備好而造成執行錯誤。先看看,你程式裡面抓的資料有沒有可能一開盤時還沒有提供。
你可以在可能出現問題的地方用print顯示訊息,這樣會比較容易發現問題出在哪個環節。
許教授護航,護的有點誇張,從來都是先檢討客戶,而不是檢討XQ。"在一開盤去抓資料,也許有些資料還沒有準備好而造成執行錯誤。",請問XQ的文件有說明幾時資料幾時會準備好? 使用者只能Try&Error? 我測試了許久,根據經驗值,要延後1秒等資料準備好,我有測試了,但是XQ的文件說明呢?
此外,這個問題應該是XQ的問題! 因為同時段XQ的看盤軟體也有問題,我在"XQ使用問題"那邊有貼出來,同時間也有人反映遇到一樣的問題! XQ應該要去找出問題,要使用者提供LOG,那絕對沒問題,而不是,我後來看沒問題,那就沒問題了! 相信許教授一定知道,很多bug是隨機發生的,不見得每次都會發生,那麼XQ該怎麼辦?
如果XQ是免費軟體,我不會去要求,但是XQ是付費軟體,那麼XQ就應該要有軟體商該有的態度與精神!
附上程式,請許教授debug
Input: TX_Symbol("FITXN*1.TF","對應商品代碼");
Input: Volume_Threshold(400,"大台放量口數門檻");
Input: VSize(1,"操作口數");
Input: Rate(1.9,"賺賠比");
var: TX_Vol(0);
var: intraBarPersist LongTriggerPrice(0), intraBarPersist ShortTriggerPrice(0);
var: intraBarPersist StopLossPrice1(0), intraBarPersist TakeProfitPrice1(0);
var: intraBarPersist StopLossPrice2(0), intraBarPersist TakeProfitPrice2(0);
var: intraBarPersist IsPendingLong(false), intraBarPersist IsPendingShort(false);
var: intrabarpersist bFirstTime(True);
var: intrabarpersist LastBarTime(0);
//if getInfo("isRealTime")=0 then return;
if ((time>132500 and time<134600) or (time>045000 and time<050100)) and filled=0 then begin
IsPendingLong=False;
IsPendingShort=False;
return; //13:25 or 04:50 後不操作
end;
if time>=134200 and time<134600 then begin
if Position<>0 then setposition(0,Market); // 13:42強制平倉
return;
end;
If time <> LastBarTime then begin
LastBarTime = time;
bFirstTime=True;
//Print(time);
end;
// 監控價格是否突破或跌破訊號K棒的高低點
If IsPendingLong and close>LongTriggerPrice and Filled<=0 then begin
SetPosition(VSize,Label:="突破黑K高點做多");
IsPendingLong = false; // 觸發後關閉等待狀態
end;
if IsPendingShort and close<ShortTriggerPrice and Filled>=0 then begin
SetPosition(-VSize,Label:="跌破紅K低點做空");
IsPendingShort = false; // 觸發後關閉等待狀態
end;
TX_Vol=GetSymbolField(TX_Symbol, "成交量");
value99=getField("時間","Tick");
Value1=Second(value99); //不可以用Time,因為Time沒有秒數
//if isFirstCall("Bar") then begin
if Value1>0 and bFirstTime then begin //不能用isFirstCall,因為資料還沒Ready
bFirstTime=False;
//TX_Vol=GetSymbolField(TX_Symbol, "成交量"); //不知為什麼,擺在這裡抓不到資料
Print(TX_Vol[1],High[1],Low[1]);
if TX_Vol[1]>Volume_Threshold then begin
//根據K棒顏色,設定突破/跌破的觸發條件
If close[1] < Open[1] then begin
// 1分K收黑:開啟「突破高點做多」訊號
IsPendingLong = true;
//IsPendingShort = false;
LongTriggerPrice = High[1];
StopLossPrice1 = Low[1];
TakeProfitPrice1 = High[1] + Rate * (High[1] - Low[1]);
Print("**多",LongTriggerPrice,StopLossPrice1,TakeProfitPrice1);
end
else if close[1] > Open[1] then begin
// 1分K收紅:開啟「跌破低點做空」訊號
IsPendingShort = true;
//IsPendingLong = false;
ShortTriggerPrice = Low[1];
StopLossPrice2 = High[1];
TakeProfitPrice2 = Low[1] - Rate * (High[1] - Low[1]);
Print("**空",ShortTriggerPrice,StopLossPrice2,TakeProfitPrice2);
end
else begin
// 如果是十字線(收開盤同價),則不啟動任何方向
IsPendingLong = false;
IsPendingShort = false;
end;
end;
end;
// 有多單部位時:監控是否碰觸停損或停利
If Filled>0 and Filled=Position then begin
If close <= StopLossPrice1 then begin
if Position<>0 then begin
SetPosition(0,Label:="多單停損出場");
IsPendingLong = false;
end;
end
else if close >= TakeProfitPrice1 then begin
if Position<>0 then begin
SetPosition(0,Label:="多單停利出場");
IsPendingLong = false;
end;
end;
end;
// 有空單部位時:監控是否碰觸停損或停利
If Filled<0 and Filled=Position then begin
If close >= StopLossPrice2 then begin
SetPosition(0,Label:="空單停損出場");
IsPendingShort = false;
end
else if close <= TakeProfitPrice2 then begin
SetPosition(0,Label:="空單停利出場");
IsPendingShort = false;
end;
end;
補充說明,這個問題不是每次都會發生,是偶而發生!
再來,錯誤訊息是"K線取得資料異常",然後程式停止。如果是資料沒有Ready,那只是抓錯資料,造成運算錯誤,而不會造成整個程式停止,許教授,您說是不是?
這裡請教許教授一個問題,GetSymbolField為什麼放在49行讀不到正確數值? 要移到43行才能讀到正確數值?
4 評論