Damiani_volatmeter2.i





//+------------------------------------------------------------------+
//|                                           Damiani_volatmeter.mq4 |
//|                         Copyright © 2006, Luis Guilherme Damiani |
//|                                      http://www.damianifx.com.br |
//+------------------------------------------------------------------+
//When the green line is BELOW the gray line - DON'T trade
#property copyright "Copyright © 2006, Luis Guilherme Damiani"
#property link      "http://www.damianifx.com.br"

#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Silver
#property indicator_color2 Red
#property indicator_color3 Lime
//---- input parameters
extern int       Viscosity=10;
extern int       Sedimentation=60;
extern double    Threshold_level=1.4;
extern bool      lag_supressor=true;
double    lag_s_K=0.5;
extern bool      InfoOnly=false;

//---- buffers
double thresholdBuffer[];
double vol_m[];
double vol_t[];
double ind_c[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   IndicatorBuffers(4);
   if(InfoOnly)double draw=DRAW_NONE; else draw=DRAW_LINE;
   
   SetIndexStyle(0,draw);
   SetIndexBuffer(0,thresholdBuffer);
   SetIndexStyle(1,DRAW_LINE,0,4);
   SetIndexBuffer(1,vol_m);
   SetIndexStyle(2,draw);
   SetIndexBuffer(2,vol_t);
      SetIndexLabel(0,"DVolt");
      SetIndexLabel(1,"DVolt DO NOT Trade");
      SetIndexLabel(2,"DVolt");
   SetIndexBuffer(3,ind_c);
                    

   ArrayResize(ind_c,Bars);
   ArrayInitialize(ind_c,0.0);
   
//---info hozza
    // now we will crate a text mark.
   // for this use the function ObjectCreate.
   // do not indicate coordinates
   ObjectCreate("signal",OBJ_LABEL,0,0,0,0,0);
 
   // change the x-coordinate
   ObjectSet("signal",OBJPROP_XDISTANCE,830);
 
   // change the y-coordinate
   ObjectSet("signal",OBJPROP_YDISTANCE,5);
 
   // to indicate the mark text, use the following function
   ObjectSetText("signal","Baj van",14,"Tahoma",Gold);
     
   // "signal" - object name
   // "lambada" - text
   // 14 - font size
   // Gold - color


//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 
   ObjectsDeleteAll();

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   double vol=0;
   int    changed_bars=IndicatorCounted();
   //Comment("ATR ratio= "+short_atr+" / "+long_atr);
   if(changed_bars < 0) return(-1);
   if(changed_bars > 0) changed_bars--;
   int limit=Bars-changed_bars;
//   limit=MathMax(limit,Sedimentation);

//   if (limit>Sedimentation+5)limit=limit-Sedimentation;
   for(int i=limit;i>=0;i--)
   {
      double sa=iATR(NULL,0,Viscosity,i);
      double s1=ind_c[i+1];
      double s3=ind_c[i+3];
      double atr=NormalizeDouble(sa,Digits);
      double atrsd= iATR(NULL,0,Sedimentation,i);
         if (atrsd!=0)
         {
      if(lag_supressor)
         vol= sa/atrsd+lag_s_K*(s1-s3);   
      else
         vol= sa/atrsd; 
         }  
      //vol_m[i]=vol;
      double anti_thres1=iStdDev(NULL,0,Viscosity,0,MODE_LWMA,PRICE_TYPICAL,i);
      double stdsed = iStdDev(NULL,0,Sedimentation,0,MODE_LWMA,PRICE_TYPICAL,i);
      if (stdsed!=0)
      
      double  anti_thres=anti_thres1/stdsed;           
                        
      double t=Threshold_level;
      t=t-anti_thres;
      
      if (vol>t){vol_t[i]=vol;vol_m[i]=EMPTY_VALUE;//=vol;
                  IndicatorShortName(" HAJRÁ FIÚK!  /  ATR= "+DoubleToStr(atr,Digits)+"    values:");
                  ObjectSetText("signal","TRADE!!",14,"Tahoma",Lime);
                  }
      else {vol_t[i]=vol;vol_m[i]=0.0;
               IndicatorShortName(" DO NOT  /  ATR= "+DoubleToStr(atr,Digits)+"    values:");
               ObjectSetText("signal","DO NOT TRADE!",14,"Tahoma",Red);}   
      ind_c[i]=vol;
      thresholdBuffer[i]=t;   
   }
//---- 
   
//----
   return(0);
  }
//+------------------------------------------------------------------+



Sample





Analysis



Market Information Used:



Indicator Curves created:

Implements a curve of type draw

Implements a curve of type DRAW_LINE

Indicators Used:

Indicator of the average true range
Standard Deviation indicator


Custom Indicators Used:

Order Management characteristics:

Other Features: