想請問一下自動交易 回測都有數據但是實際要用模擬單 都沒有顯示下單,然後都無法執行,請問是什麼問題???
 
        
        自動交易實單無法下單 但回側有數據
- 403
- 最後發表 will0612 2024 六月 23
再麻煩你指教了
input: exit_period(5, "收盤前N分鐘平倉");
input: profit_percent(10, "停利(%)");
input: loss_percent(4, "停損(%)");
var:bcost(0);
var: market_close_condition(false); { 是否已經進入收盤階段 }
var:short_condition(true);
short_condition = currenttime >=093600 ;
if position = 0 and filled = 0
and getField("成交金額(元)","D")[1]>10000000
and getSymbolField("otc.tw", "收盤價", "5")<getSymbolField("otc.tw", "收盤價", "D")[1]
and C<200
then
if closed(1)>0 and bcost=0
then begin
bcost=closed(1);
end;
if bcost <> 0 and date<>date[1]
then
value5+=1;
if value5=3
and short_condition
and close<closed(1)*1.08
then begin
value5=0;
bcost=0;
setposition(-1,Close+0);
end;
market_close_condition = EnterMarketCloseTime(exit_period);
if Position = -1 and Filled = -1 then begin
{ 依照成本價格設定停損/停利: 請注意當作空時, 判斷是否獲利的方向要改變 }
if profit_percent > 0 and Close <= FilledAvgPrice*(1-0.01*profit_percent) then begin
{ 停利 }
SetPosition(0);
由於你沒有提供使用的頻率是什麼,看到date<>date[1],我估計你用的是分鐘頻率。若有勾選逐筆洗價,則問題出在if bcost <> 0 and date<>date[1] 這個條件。bcost因為沒有用intrabarpersist宣告,所以在第二根K棒才會被設為前一天的收盤價,而第二根K棒的date是等於date[1],所以value5沒有機會加1,亦即一直保持0的預設值,因此不會有訊號。
宣告bcost時,加intrabarpersist就可解決問題。
先謝謝教授 原來是我宣告 沒有使用intrabarpersist
教授 我還想問一個問題
我的時間 為什麼只有放在這裡 才會觸發時間的條件呢
一般來說 我都正常放在if position = 0 and filled = 0 下面 就會觸發時間 0906的時候才進場 但是 似乎 好像用了begin end這一區塊 我的時間擺在這裡就不會觸發 變成要往下擺 這個部份我一直卡住 雖然解決了 但是我並沒有理解為什麼會這樣
short_condition = currenttime >=090600 ;
if value5=3
and short_condition
and close<closed(1)*1.08
then begin
謝謝你
請說明short_condition原來放在哪裡不行。把不行的程式碼貼上來,才能判斷問題。
教授完蛋了 我這幾天 試過 使用自動交易 一樣無法實單ㄟ 是因為value5 或是Closed的問題嗎? 因為一直交叉測試 都沒有解決 只好再上來請教您
請說明無法實單交易,是沒有訊號,還是有其他錯誤訊息?將最後的版本放上來,我幫忙看看問題在哪裡。
 
 
             
         
         
     
     分類
    分類
 
            
12 評論