奇狐社區論壇
在這個頁面顯示本主題全部的 3 個文章

奇狐社區論壇 (http://www.chiefox.com.tw/bbs/index.php)
- 問題交流 (http://www.chiefox.com.tw/bbs/forumdisplay.php?forumid=28)
-- 請問如何調整(barlast) (http://www.chiefox.com.tw/bbs/showthread.php?threadid=16317)


由 aeontzeng 在 2011-12-22 15:28 發表:

請問如何調整(barlast)

是這樣的,
比方我有兩個數值a , b ; 且a 與 b 均可為正或負
之後我設定以下的 barslast 條件

甲: IF(barslast (a>0 and b<0) < barslast (a<0 and b>0) ,1,0);
乙: IF(barslast (a>0 and b<0) > barslast (a<0 and b>0),1,0);

甲的意義設定為:

1. 如果a>0 and b<0 出現的位置比 a<0 and b>0 的位置近,則執行甲;

2.另外若從初始算起, 如果 a>0 and b<0 出現 , 但 a<0 and b>0 尚未出現時,當下也該執行甲

現在第2項會有問題, 因為在 a>0 and b<0 這個條件出現時,另一個 a<0 and b>0 的條件還未出現 , 這時 barslast 就無法判斷, 導致甲跟乙均無法進行

想請較如何補第2項

謝謝


由 cgjj 在 2011-12-22 21:33 發表:

回覆: 請問如何調整(barlast)

引用:
最初由 aeontzeng 發表
是這樣的,
比方我有兩個數值a , b ; 且a 與 b 均可為正或負
之後我設定以下的 barslast 條件

甲: IF(barslast (a>0 and b<0) < barslast (a<0 and b>0) ,1,0);
乙: IF(barslast (a>0 and b<0) > barslast (a<0 and b>0),1,0);

甲的意義設定為:

1. 如果a>0 and b<0 出現的位置比 a<0 and b>0 的位置近,則執行甲;

2.另外若從初始算起, 如果 a>0 and b<0 出現 , 但 a<0 and b>0 尚未出現時,當下也該執行甲

現在第2項會有問題, 因為在 a>0 and b<0 這個條件出現時,另一個 a<0 and b>0 的條件還未出現 , 這時 barslast 就無法判斷, 導致甲跟乙均無法進行

想請較如何補第2項

謝謝



邏輯上可採這樣處理

CK:=(a>0 and b<0)-(a<0 and b>0);
CK:=ref(CK,barslast(CK<>0));

前面兩行計算結果
若 CK=1 則執行甲, 若 CK=-1 則執行乙


由 aeontzeng 在 2011-12-23 07:26 發表:

謝謝您


全部時間均為台灣時間, 現在時間為16:38
在這個頁面顯示本主題全部的 3 個文章


Powered by: vBulletin Version 2.3.0 - Copyright©2000-, Jelsoft Enterprises Limited.

簡愛洋行 製作 Copyright 2003-. All Rights Reserved.