//+------------------------------------------------------------------+
//|                                                        IShark.mq4 |
//|                                               Written by Linuxser|   
//|                                       http://www.linuxser.com.ar |
//|                                        based on iFish by Kalenzo |                                  
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, Forex-TSD.com "
#property link      "http://www.forex-tsd.com/"
#property indicator_buffers 1
#property indicator_color1 DarkSlateGray
 
#property indicator_level1 0.5
#property indicator_level2 -0.5

extern int       CCIper=5;
extern int       CCIprice=0;
extern int       MAper=9;
extern int       MAmode=3;

double value1[];
double value2[];
double iShark[];
double red[];
double green[];

#property indicator_separate_window
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   IndicatorBuffers(3);
   
   SetIndexBuffer(0,iShark);
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,5);
  
   SetIndexBuffer(1,value1);
   SetIndexBuffer(2,value2);
   
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("iShark v1("+CCIper+","+CCIprice+","+MAper+","+MAmode+")");   
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int limit;
   int counted_bars=IndicatorCounted();
   if(counted_bars<0) counted_bars=0;
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
//---- 
   for(int i = 0 ;i <= limit ;i++) value1[i] = 0.1*(iCCI(Symbol(),0,CCIper,CCIprice,i));  
   for(int j = 0 ;j <= limit ;j++) value2[j] = iMAOnArray(value1,0,MAper,0,MAmode,j);
   for(int f = 0 ;f <= limit ;f++) iShark[f] = (MathExp(2*value2[f])-1)/(MathExp(2*value2[f])+1);
   
  
//----
   return(0);
  }
//+------------------------------------------------------------------+