標籤

二元樹 (1) 字串常數池 (1) 投資 (3) 每月損益 (37) 例外處理 (1) 泛型 (2) 股票 (15) 指標 (5) 英文 (8) 基本資料型別 (1) 期貨 (1) 程式交易 (10) 量化投資 (5) 亂亂寫 (3) 概念 (3) 資料結構 (3) 演算法 (3) 數學 (3) 轉型 (1) AMA (1) ArrayList (1) assert (1) BeautifulSoup (1) C/C++ (8) casting (1) ClassCastException (1) classpath (1) Collection (4) Comparable (1) comparTo() (1) constructor (1) database (3) Debian (1) Dropbox (2) EA (2) enum (1) equals() (2) exception (3) extends (1) ffmpeg (1) final (1) Git (1) HashMap (1) HashSet (1) hasNext() (1) HTS (3) instanceof (1) IS-A (1) Iterator (1) JAVA (43) length (1) Linux (31) List (1) Mac (6) Map (1) ML (2) MT4 (6) MySQL (2) next() (1) NullPointerException (1) Number (1) Numpy (2) OpenCart (1) OpenCV (3) OSX (1) overloading (1) overriding (3) pandas (2) PHP (8) PriorityQueue (1) Python (11) Queue (1) random() (1) reverse() (1) Samba (1) SCJP (21) sqrt() (1) synchronized (1) talib (1) ufw (1) uTorrent (1) var-args (2) VHF (1) vim (2) Yhoo知識+ (4)

2016年4月21日 星期四

LSS通道

上下通道表示支撐及壓力,所突破就做多,跌破做空,只限日內交易。
公式參考自:http://rane1220.pixnet.net/blog/post/48867946

#property indicator_chart_window
#property indicator_buffers 1
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Yellow

double buffer1[];
double buffer2[];

int init(){
int draw_begin;
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,buffer1);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,buffer2);
return 0;
}

int start(){
int limit = Bars - IndicatorCounted();

for(int i=0; i<limit; i++){
buffer1[i] = LssUp(i);
buffer2[i] = LssDown(i);
}

return 0;
}

double LssUp(int shift){
double upv, buv, dup, lssup;

shift++;
upv = iLow(NULL,0,shift) + (iHigh(NULL,0,shift) - iLow(NULL,0,shift+1) +
   iHigh(NULL,0,shift+1) - iLow(NULL,0,shift+2) +
   iHigh(NULL,0,shift+2) - iLow(NULL,0,shift+3))/3;
buv = iHigh(NULL,0,shift) + (iHigh(NULL,0,shift) - iHigh(NULL,0,shift+1) +
    iHigh(NULL,0,shift+1) - iHigh(NULL,0,shift+2) +
    iHigh(NULL,0,shift+2) - iHigh(NULL,0,shift+3))/3;
dup = iHigh(NULL,0,shift);
lssup = 2*(iHigh(NULL,0,shift) + iLow(NULL,0,shift) + iClose(NULL,0,shift))/3 - iLow(NULL,0,shift);

return (upv+buv+dup+lssup)/4;
}

double LssDown(int shift){
double downv, bdv, ddown, lssdown;

shift++;
downv = iHigh(NULL,0,shift) - (iHigh(NULL,0,shift+1) - iLow(NULL,0,shift) +
      iHigh(NULL,0,shift+2) - iLow(NULL,0,shift+1) +
      iHigh(NULL,0,shift+3) - iLow(NULL,0,shift+2))/3;
bdv = iLow(NULL,0,shift) - (iLow(NULL,0,shift+1) - iLow(NULL,0,shift) +
   iLow(NULL,0,shift+2) - iLow(NULL,0,shift+1) +
   iLow(NULL,0,shift+3) - iLow(NULL,0,shift+2))/3;
ddown = iLow(NULL,0,shift);
lssdown = 2*(iHigh(NULL,0,shift) + iLow(NULL,0,shift) + iClose(NULL,0,shift))/3 - iHigh(NULL,0,shift);

return (downv+bdv+ddown+lssdown)/4;
}

沒有留言:

張貼留言