//+------------------------------------------------------------------+ //| Parabolic_A.mq4 | //| Rondo | //| http://fx-dollaryen.seesaa.net | //+------------------------------------------------------------------+ #property copyright "Rondo" #property link "http://fx-dollaryen.seesaa.net" #property version "1.0" #property strict #property indicator_chart_window #property indicator_buffers 3 #property indicator_color1 clrLime #property indicator_color2 clrBlue #property indicator_color3 clrRed #property indicator_width2 2 #property indicator_width3 2 input int span = 10; //矢印の位置(ローソク足からの離れ具合) input bool boolParabolic = true; //パラボリックを表示 input double step = 0.02; //ステップ input double maximum = 0.2; //上限 double Parabolic[], UP[], DOWN[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping IndicatorBuffers(2); SetIndexStyle(0, DRAW_ARROW); SetIndexStyle(1, DRAW_ARROW); SetIndexStyle(2, DRAW_ARROW); SetIndexBuffer(0, Parabolic, INDICATOR_DATA); SetIndexBuffer(1, UP, INDICATOR_DATA); SetIndexBuffer(2, DOWN, INDICATOR_DATA); SetIndexArrow(0, 159); SetIndexArrow(1, SYMBOL_ARROWUP); SetIndexArrow(2, SYMBOL_ARROWDOWN); ArraySetAsSeries(Parabolic, true); ArraySetAsSeries(UP, true); ArraySetAsSeries(DOWN, true); ArrayInitialize(Parabolic, EMPTY_VALUE); ArrayInitialize(UP, EMPTY_VALUE); ArrayInitialize(DOWN, EMPTY_VALUE); SetIndexLabel(0, "Parabolic_A"); SetIndexLabel(1, "BUY"); SetIndexLabel(2, "SELL"); //---- indicator short name IndicatorShortName("Parabolic_A"); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]){ //--- int limit = rates_total - prev_calculated; if(limit>0) limit = rates_total -3; double ParaStop = 0.0; int ParaState = 0; for(int i=limit; i>=0; i--){ double sar = iSAR(NULL, 0, step, maximum, i); double sar1 = iSAR(NULL, 0, step, maximum, i+1); double sar2 = iSAR(NULL, 0, step, maximum, i+2); Parabolic[i] = EMPTY_VALUE; UP[i] = EMPTY_VALUE; DOWN[i] = EMPTY_VALUE; if(boolParabolic) Parabolic[i] = sar; if((sar2 > high[i+2] && sar2 <= high[i+1]) || (sar2 < low[i+2] && sar2 >= low[i+1])){ ParaState = 0; ParaStop = 0.0; } if(ParaState == 0){ if(sar1 <= close[i+1] && close[i+2] > close[i+1]){ ParaStop = close[i+2]; ParaState = 1; } if(sar1 >= close[i+1] && close[i+2] < close[i+1]){ ParaStop = close[i+2]; ParaState = -1; } } if(ParaState == 1 && ParaStop > 0 && ParaStop <= high[i]){ UP[i] = low[i] - span * _Point; ParaStop = 0.0; } if(ParaState == -1 && ParaStop > 0 && ParaStop >= low[i]){ DOWN[i] = high[i] + span * _Point; ParaStop = 0.0; } } //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+