macd背離請益

  •   590 
  • 最後發表   小梯子  2024 十一月 05
小梯子 發文於   2024/10/28

value1 = SwingHigh(High,30,3,0,1);  //找出30期內,含今日的第1個高點價格

condition1 = value1 <> -1 and value1 > high[1] ; 

value2 = SwingHigh(High,30,3,2,1);  //找出30期內,波段前高

condition2 = value2 <> -1;

condition3 = value1 > value2;

if condition1 and condition2 and condition3 then plot3(close,"股價創新高");

variable:_dif(0),_macd(0),_osc(0);

macd(weightedClose(),12,26,9,_dif,_macd,_osc);

想要找出股價創新高, osc沒有創新高的股票

從討論區爬文 可以用SwingHigh函數,

value4 = SwingHigh(_osc,30,3,0,1);

value5 = SwingHigh(_osc,30,3,2,1);

value4 是找到30期內,含今日的第1個轉折高點,就不是背離.

想直接從股價value1及value2寫出相對應的osc1及osc2值之後,來做比較.

即 if condition1 and condition2 and condition3 and osc1 < osc2 then ret = 1 ;

苦於不知道如何表達"直接從股價value1及value2寫出相對應的osc1及osc2值的語法",懇請賜教.

 

排序方式: 標準 | 最新
虎科大許教授 發文於   2024/10/28

value1 = SwingHigh(High,30,3,0,1);

value2 = SwingHigh(High,30,3,2,1);

value11 = SwingHighBar(High,30,3,0,1);

value12 = SwingHighBar(High,30,3,2,1); 

condition1 = value11 <> -1 and value1 > high[1] ;

condition2 = value12 <> -1;

condition3 = value1 > value2;

condition4 = _osc[value11] < _osc[value12];

if condition1 and condition2 and condition3 and condition4 then ret = 1 ;

小梯子 發文於   2024/10/28

 

原來可以這樣寫,懂了.

如果寫成一個RSI背離+MACD背離腳本

RSI(close,6);

那RSI(6)如何從value11及value12寫出相對應的RSI1及RSI2值,之後來做比較.

 

虎科大許教授 發文於   2024/10/28

value31=RSI(c,6);

condition5=value31[value11]<value31[12];

小梯子 發文於   2024/10/28

又懂了一個!

value1 = SwingHigh(High,30,3,0,1);  

condition1 = value1 <> -1 and value1 > high[1] ; 

value2 = SwingHigh(High,30,3,2,1);  

condition2 = value2 <> -1;

condition3 = value1 > value2;

if condition1 and condition2 and condition3 then plot3(high,"股價創新高");

 

在日線圖是正確的,但放在周線圖 股價創新高相對應的value2是錯誤的,怎麼會這樣,要如何修改?

虎科大許教授 發文於   2024/10/28

你可能需要提供更詳細的資訊,才有辦法判斷及修改。

XS小編 發文於   2024/11/05

Hello 小梯子,

 

小編補充,您可以參考 SwingHigh 的函數說明。

SwingHigh(High,30,3,0,1) 和 SwingHigh(High,30,3,2,1) 都會是第一個轉折高點,差別在於一個的右肩需要是2筆,一個是0筆。

要找前一高點,要修改的參數應該是最後一個項目。

 

另外網站上有教學區教學影片,裡面有XS語法的基礎和應用可以閱覽。

 

感謝 虎科大許教授 的熱心回覆。

發表回覆
Close