XS 語法 詢問

  •   166 
  • 最後發表   AndyJian  2023 六月 15
AndyJian 發文於   2023/06/13

想請教
當我使用 close_D = GetSymbolField("Future*1", "收盤價", "D");這個函式
condition16 = sma_20_D > sma_20_D[1] and sma_20_D[1] > sma_20_D[2] and sma_20_D[2] > sma_20_D[3];

設定好日線條件後,來到策略下單的地方

{進場條件1}

if condition16 then begin

if Position= 0 and condition1  and condition2  and condition4 and condition5 and condition7 and condition8 and condition9 and condition13  then begin

SetPosition(2,market);

end;

end else if Position= 0 and condition1  and condition2 and condition3 and condition4 and condition5 and condition7 and condition8 and condition9  then begin

SetPosition(1,market);

 

end;

{進場條件2}

if condition15 then begin

if Position= 0 and condition1 and condition4 and condition9 and condition12 and condition13  then begin

SetPosition(2,market);

end;

end;

有以下兩個問題:


1.像最近 很明顯的小台日20MA 應該都是上斜的,不過判斷式卻還是會下到一口單的地方。
想請教是哪裡語法有誤嗎?

2.另外還有 明明權益數是夠下兩口單綽綽有餘的,但有時候卻只會成交一口,另一口顯示資金不足,是因為什麼呢?

排序方式: 標準 | 最新
XQ小幫手 發文於   2023/06/14

 Hello AndyJian,

 

1.小幫手不知道您的其他條件是如何寫的,所以無法確定。

建議您可以將其他 condition 印出確認看是哪個條件達成。

可能是condition13不符合導致執行到條件1第二個 setposition。

若還是有問題的話,麻煩提供 自動交易匯出檔勾選(包含)交易腳本,並告知問題發生的日期時間。

 

2.要麻煩您提供 XQ Log 來檢驗。

Log資料夾(預設路徑:C:\SysJust\XQLite\LOG)直接壓縮後提供即可。

您可以直接將檔案上傳,如果檔案過大的話也可以保存至雲端空間並提供連結Mail至客服信箱 XQservice@XQ.com.tw 且務必附上 討論文章連結網址(小幫手才能盡早處理)。

感謝。

AndyJian 發文於   2023/06/14

小幫手你好

關於1的部分 


不是應該是
condition16 = True 的話 會執行到下面SetPosition(2,market);
如果condition16 = False 就會變成SetPosition(1,market);
然後就end結束掉了。

現在有點不懂的是下面的{進場條件2}不符合的話 怎麼會去影響到條件1的第二個呢。
不符合的話,應該是從條件一重頭(
if condition16)判斷吧?

還是我哪裡理解有誤,還請指教。


非常感謝~


2.好的~

XQ小幫手 發文於   2023/06/15

Hello AndyJian,

 

小幫手幫您簡單縮排整理一下:

if condition16 then begin

    if Position= 0 and condition1  and condition2  and condition4 and condition5 and condition7 and condition8 and condition9 and condition13  then begin

        SetPosition(2,market);

        end;

end else if Position= 0 and condition1  and condition2 and condition3 and condition4 and condition5 and condition7 and condition8 and condition9  then begin

    SetPosition(1,market);

    end;

 

condition16 為 True 的話只是會讓腳本執行 if Position= 0 and condition1  and condition2  and condition4 and condition5 and condition7 and condition8 and condition9 and condition13 的判斷。

若裡面的條件不符合的話就會進入 else if 的條件判斷中。

故就算 condition16 符合,但condition13不符的話,還是會進到後半段的部分。

進場條件二裡面為setposition(2, market),所以應該和您提到的下單問題沒有關聯。

 

Log 部分小幫手請相關人員確認,但您提供的Log只到 5/18 號。

麻煩您提供最新壓縮的Log,並告知問題發生的日期時間。

感謝。

發表回覆
Close