//+------------------------------------------------------------------+ //| MAKairi.mq4 | //| Copyright (C) 2007, ZERO. | //| http://zerodrive.jugem.jp/ | //+------------------------------------------------------------------+ #property copyright "Copyright (C) 2007, ZERO." #property link "http://zerodrive.jugem.jp/" #property indicator_separate_window #property indicator_buffers 1 #property indicator_color1 Red #property indicator_level1 1 #property indicator_level2 0.5 #property indicator_level3 -0.5 #property indicator_level4 -1 //---- input parameters extern int MAMode = 1; //0=SMA,1=EMA,2=SMMA,3=LWMA extern int MAPeriod = 21; //---- double MAKairi[]; //CloseRate<=>FastMA //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexStyle(0, DRAW_LINE); //---- SetIndexLabel(0, "MAKairi"); //---- SetIndexBuffer(0, MAKairi); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int counted_bars = IndicatorCounted(); int limit, i; double ma; //---- check for possible errors if (counted_bars < 0) return(-1); //---- last counted bar will be recounted if (counted_bars > 0) counted_bars--; limit = Bars - counted_bars; for (i = 0; i <= limit - 1; i++) { //---- MA ma = iMA(NULL, 0, MAPeriod, 0, MAMode, PRICE_CLOSE, i); //---- MA separate if (ma != 0) { MAKairi[i] = (Close[i + 1] - ma) / ma * 100; } } //---- return(0); }