diary/20090925
MACDサンプルプログラム
マーフィ手法が通用しなくなったので,自分で手法を考えねばならない.まずは初心者でもすぐ思いつくMACDを使った手法をプログラムした.ドル円日足でバックテストすると,今年の1月からでは+758pipsとなる.これもたまたま偶然かもしれないので,フォワードテストを最低3ヶ月はやらないと実使用することはできない.
strategy macd_k4; input lots = 1 ; vars mas(series), mal(series), i(number); begin Bollinger_Bands_all(close, 21, 2.5, 0); MACD(); mas := sma(close, 5); mal := sma(close, 25); if crossdown (mas, mal) then exitlong(); if crossup(close, Bollinger_Bands_all.line_upper) then exitlong(); if crossup (MACD.line, MACD.line_signal) then begin exitshort(); i := back(MACD.line); if (MACD.line[i] < 0) then buy(lots); end; if crossup (mas, mal) then exitshort(); if crossdown(close, Bollinger_Bands_all.line_lower) then exitshort(); if crossdown(MACD.line, MACD.line_signal) then begin exitlong(); i := back(MACD.line); if (MACD.line[i] > 0) then sell(lots); end; end.