*multicharts Bollinger Bands_交易模型範本 *


布林帶(Bollinger Bands,BBands)也稱為布林通道包寧傑帶狀保力加通道布歷加通道,是由約翰·包寧傑John Bollinger)在1980年代發明的技術分析工具。應用上結合了移動平均標準差的概念,其基本的型態是由三條軌道線組成的帶狀通道(中軌和上、下軌各一條)。中軌為股價的平均成本,上軌下軌可分別視為股價的壓力線支撐線

定義[編輯]

布林帶」是這樣定義的:

一般情況下,設定N=20和K=2,這兩個數值也是在布林帶當中使用最多的。在日線圖裡,N=20其實就是「月均線」(MA20)。依照常態分布規則,約有95%的數值會分布在距離平均值有正負2個標準差()的範圍內。
引用: https://zh.wikipedia.org/wiki/%E5%B8%83%E6%9E%97%E5%B8%A6

----------------------------------------------------------------------------------------------

//訊號範例code
//布林通道&布林通道差
//txf_50min_Bollinger Bands
//since: 20170928
// author : chun yu


inputs:Len(20),NumDevsDn(2);
vars:avg(0),upBB(0),downBB(0),mp(0);
mp=marketposition;

//Bollinger Bands通道
avg=Average(close,Len);
upBB = BollingerBand(Close,Len,NumDevsDn);
downBB = BollingerBand(Close,Len,-NumDevsDn);

//布林通道差
value1=absvalue(xAverage(c,Len)-upBB);
value2=absvalue(xAverage(c,Len)-downBB);
value3=(value1-value2);

 

//條件
condition1= close <upBB and value3>0 ;
condition2= close >-upBB and value3<0 ;


condition3= close >downBB and value3>0 ;
condition4= close <-downBB and value3<0 ;

//進場Entry
if condition1 and EntriesToday(date)<1 then buy next bar at market;
if condition2 and EntriesToday(date)<1 then buy next bar at market;


if condition3 and EntriesToday(date)<1 then sellshort next bar at market;
if condition4 and EntriesToday(date)<1 then sellshort next bar at market;


//固定停損stop
setstoploss(9999);



-------------------------------------------------------------------------------------

※ 大家寫看看吧~歡迎聯繫來信討論~
※程式碼僅供研究,不為交易依據!!


 

 

 

 

arrow
arrow

    AJun 發表在 痞客邦 留言(0) 人氣()