//-------------------------------------------------------------------- // kiri_hk100126_Ind.mq4 // // Copyright(C)2009, FurainoKirin // http://kirin1182.seesaa.net/ // ono.kirin@hotmail.co.jp // Rev.000 //-------------------------------------------------------------------- #property copyright "Copyright(C)2009, ForexTradingLaboratory" #property link "http://www.ftlabo.com/index.php" #property indicator_chart_window #property indicator_buffers 8 #property indicator_color1 Magenta #property indicator_color2 Red // 指標バッファ double Buf0[]; double Buf1[]; // 外部パラメータ extern string Copyright = "Copyright(C)2009, FurainoKirin"; extern string URL = "http://www.ftlabo.com/index.php"; extern string EMail = "ono@ftlabo.com"; extern string explanation1 = "単純移動平均線を使うか?"; extern bool SMA = true; extern string explanation2 = "単純移動平均線区間"; extern int SMAPeriod = 10; extern string explanation3 = "線形加重移動平均線を使うか?"; extern int LWMA = true; extern string explanation4 = "線形加重移動線区間"; extern int LWMAPeriod = 10; extern string explanation5 = "鳴らす音のファイルの場所"; extern string AlertSound = "alert.wav"; double a = 0; double b = 0; int init() { // 指標バッファの割り当て SetIndexBuffer(0, Buf0); SetIndexBuffer(1, Buf1); b = Close[0]; return(0); } int start() { int limit = Bars-IndicatorCounted(); for(int i=limit-1; i>=0; i--) { Buf0[i] = iMA(NULL, 0, SMAPeriod, 0, MODE_SMA, PRICE_CLOSE, i); Buf1[i] = iMA(NULL, 0, LWMAPeriod, 0, MODE_LWMA, PRICE_CLOSE, i); } double a = Close[0]; if(SMA == true) { if(Buf0[0] > b && Buf0[0] < a) { PlaySound(AlertSound); ObjectDelete("BuySignal"); ObjectCreate("BuySignal",OBJ_ARROW,0 ,Time[0] ,Close[0]); ObjectSet("BuySignal",OBJPROP_ARROWCODE, 221); ObjectSet("BuySignal",OBJPROP_COLOR, Blue); } else if(Buf0[0] < b && Buf0[0] > a) { PlaySound(AlertSound); ObjectDelete("SellSignal"); ObjectCreate("SellSignal",OBJ_ARROW,0 ,Time[0] ,Close[0]); ObjectSet("SellSignal",OBJPROP_ARROWCODE, 222); ObjectSet("SellSignal",OBJPROP_COLOR, Red); } } if(LWMA == true) { if(Buf1[0] > b && Buf1[0] < a) { PlaySound(AlertSound); ObjectDelete("BuySignal"); ObjectCreate("BuySignal",OBJ_ARROW,0 ,Time[0] ,Close[0]); ObjectSet("BuySignal",OBJPROP_ARROWCODE, 221); ObjectSet("BuySignal",OBJPROP_COLOR, Blue); } else if(Buf1[0] < b && Buf1[0] > a) { PlaySound(AlertSound); ObjectDelete("SellSignal"); ObjectCreate("SellSignal",OBJ_ARROW,0 ,Time[0] ,Close[0]); ObjectSet("SellSignal",OBJPROP_ARROWCODE, 222); ObjectSet("SellSignal",OBJPROP_COLOR, Red); } } Print("a"+a); Print("b"+b); Print("b0"+Buf0[0]); Print("b1"+Buf0[1]); double b = a; return(0); }