時間到砍倉問題

  •   125 
  • 最後發表   NICK TZ  2021 四月 28
NICK TZ 發文於   2021/04/26

求救小助手您好 我目前有一個類似這樣的編程 但到了指定時間(131500)不會觸發賣出

 

語法上應該如何修正呢

 

 

condition301=false;

condition302=false;

condition303=false;

condition100=false;

 

 

if  Barinterval=5 and barfreq ="min" and time>094500  then Begin

 

if volume>volume[1] then begin

condition301=true;

end;

 

if close-open >100 then begin

condition302=true;

end;

 

if close>open then begin

condition303=true;

end;

 

if time>131500 then begin

     condition100=true;

end;

 

if condition301 or  condition302  or  condition303   or  condition100 then begin

ret=1;

end;

end;

排序方式: 標準 | 最新
XQ小幫手 發文於   2021/04/27

Hello NICK TZ,

 

您的 condition100 應為 time >= 131500 這樣才能夠在131500那根 bar 出場,如果是原本的 time > 131500 則是會在 132000 出場。

小幫手將您的腳本修改了一下供您參考。

if Barinterval <> 5 or barfreq <> "min" then RaiseRunTimeError("請使用5分鐘頻率");

if time>094500  then Begin

    condition301=volume>volume[1];

    condition302 = close-open >100;

    condition303 = close>open;

    condition100 = time >= 131500;

    if condition301 or  condition302  or  condition303   or  condition100 then ret=1;

    end;

  • 按讚來自於
  • tzhung
NICK TZ 發文於   2021/04/27

十分感謝小幫手

NICK TZ 發文於   2021/04/27

請問

if Barinterval <> 5 or barfreq <> "min" then RaiseRunTimeError 與我原來寫的差異在哪呢?<>這個符號內是要填寫什麼嗎?

XQ小幫手 發文於   2021/04/28

Hello NICK TZ,

 

if Barinterval <> 5 or barfreq <> "min" then RaiseRunTimeError("請使用5分鐘頻率") 與 if  Barinterval=5 and barfreq ="min" and time>094500  then Begin

的差別在於,您的寫法可以放到各種頻率的商品上,但只會在5分鐘頻率的商品時進入到判斷式裡運算。

小幫手提供的寫法則是如果商品不是5分鐘頻率的話就會報錯,警示要使用5分鐘頻率。

您可以參考 RaiseRunTimeError 的說明。

 

<>是不等於的意思,裡面不需要填任何東西。

 

  • 按讚來自於
  • tzhung
發表回覆
Close