Navigation´╝ÜHome > Content >

LVC_Detector_03.mq4

Time: 2014-10-28 | Download file:LVC_Detector_03.mq4

//+------------------------------------------------------------------+
//|                                              LVC_Detector_03.mq4 |
//|                                  Copyright 2015, Khalil Abokwaik |
//|                             http://www.forexfactory.com/abokwaik |
//+------------------------------------------------------------------+
#property copyright "Copyright 2015, Khalil Abokwaik"
#property link      "http://www.forexfactory.com/abokwaik"
#property description "Low Volume Candle Detector, with Closed LVC shown"
#property version   "3.00"
#property description "Forex Factory Thread : Low Volume Candle"
#property strict
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_plots   3
//--- plot Short_Target
#property indicator_label1  "Short Target LVC"
#property indicator_type1   DRAW_ARROW
#property indicator_color1  clrRed
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1
//--- plot Long_Target_LVC
#property indicator_label2  "Long Target LVC"
#property indicator_type2   DRAW_ARROW
#property indicator_color2  clrDodgerBlue
#property indicator_style2  STYLE_SOLID
#property indicator_width2  1
//--- plot Closed_LVC
#property indicator_label3  "Closed LVC"
#property indicator_type3   DRAW_ARROW
#property indicator_color3  clrWhite
#property indicator_style3  STYLE_SOLID
#property indicator_width3  1

//--- input parameters
input int      maxHistoryBars=1000;//History Bars
input int      loopBackBars=6; //Loop Back Bars
input int      futureBars=6;//Future Bars
//--- indicator buffers
double         Short_Target_LVC_Buffer[];
double         Long_Target_LVC_Buffer[];
double         Closed_LVC_Buffer[];
int j=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,Short_Target_LVC_Buffer);
   SetIndexBuffer(1,Long_Target_LVC_Buffer);
   SetIndexBuffer(2,Closed_LVC_Buffer);
//--- setting a code from the Wingdings charset as the property of PLOT_ARROW
   SetIndexArrow(0,233);
   SetIndexArrow(1,234);
   SetIndexArrow(2,251); //108
//---
   for(int i=maxHistoryBars-loopBackBars;i>=futureBars;i--)
   {
      int lvc=iLowest(Symbol(),0,MODE_VOLUME,loopBackBars,i);
      if(Close[lvc]>Open[lvc])
      {
         int lowest=iLowest(Symbol(),0,MODE_LOW,futureBars,lvc-futureBars);
         if(Low[lowest]>Open[lvc]) 
         {  Short_Target_LVC_Buffer[lvc]=Low[lvc]-(High[lvc]-Low[lvc])/2;
            if(Low[iLowest(Symbol(),0,MODE_LOW,lvc-1,0)] Open[lvc]) Closed_LVC_Buffer[lvc]=Long_Target_LVC_Buffer[lvc];
         }
      }
            
   }
//----------
   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[])
  {
//---
   for(int i=loopBackBars+futureBars;i>=futureBars;i--)
   {
      int lvc=iLowest(Symbol(),0,MODE_VOLUME,loopBackBars,i);
      if(Close[lvc]>Open[lvc])
      {
         int lowest=iLowest(Symbol(),0,MODE_LOW,futureBars,lvc-futureBars);
         if(Low[lowest]>Open[lvc]) 
         {  Short_Target_LVC_Buffer[lvc]=Low[lvc]-(High[lvc]-Low[lvc])/2;
            if(Low[iLowest(Symbol(),0,MODE_LOW,lvc-1,0)] Open[lvc]) Closed_LVC_Buffer[lvc]=Long_Target_LVC_Buffer[lvc];
         }
      }
            
   }
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
void deinit()
{
   ObjectsDeleteAll(0,0,OBJPROP_ARROWCODE);
}

Recommend