Deprecated: Assigning the return value of new by reference is deprecated in /home/forex/public_html/wp-settings.php on line 520

Deprecated: Assigning the return value of new by reference is deprecated in /home/forex/public_html/wp-settings.php on line 535

Deprecated: Assigning the return value of new by reference is deprecated in /home/forex/public_html/wp-settings.php on line 542

Deprecated: Assigning the return value of new by reference is deprecated in /home/forex/public_html/wp-settings.php on line 578

Deprecated: Function set_magic_quotes_runtime() is deprecated in /home/forex/public_html/wp-settings.php on line 18
forex decode

ZigZag Pointer.mq4

//+------------------------------------------------------------------+
//|                                               ZigZag Pointer.mq4 |
//|                                    zigzag modified by Dr. Gaines |
//|                                      dr_richard_gaines@yahoo.com |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "dr_richard_gaines"
#property link      "http://www.metaquotes.net/"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Lime
#property indicator_width1 1
#property indicator_color2 Red
#property indicator_width2 1
//---- indicator parameters
extern int ExtDepth=12;
extern int ExtDeviation=5;
extern int ExtBackstep=3;
//---- indicator buffers
double ExtMapBuffer[];
double ExtMapBuffer2[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   IndicatorBuffers(2);
//---- drawing settings
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexArrow(0, 233);
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexArrow(1, 234);
//---- indicator buffers mapping
   SetIndexBuffer(0,ExtMapBuffer);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexEmptyValue(0,0.0);

//---- indicator short name
   IndicatorShortName("ZigZag("+ExtDepth+","+ExtDeviation+","+ExtBackstep+")");
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
   int    shift, back,lasthighpos,lastlowpos;
   double val,res;
   double curlow,curhigh,lasthigh,lastlow;

   for(shift=Bars-ExtDepth; shift>=0; shift--)
     {
      val=Low[Lowest(NULL,0,MODE_LOW,ExtDepth,shift)];
      if(val==lastlow) val=0.0;
      else
        {
         lastlow=val;
         if((Low[shift]-val)>(ExtDeviation*Point)) val=0.0;
         else
           {
            for(back=1; back<=ExtBackstep; back++)
              {
               res=ExtMapBuffer[shift+back];
               if((res!=0)&&(res>val)) ExtMapBuffer[shift+back]=0.0;
              }
           }
        }
      ExtMapBuffer[shift]=val;
      //--- high
      val=High[Highest(NULL,0,MODE_HIGH,ExtDepth,shift)];
      if(val==lasthigh) val=0.0;
      else
        {
         lasthigh=val;
         if((val-High[shift])>(ExtDeviation*Point)) val=0.0;
         else
           {
            for(back=1; back<=ExtBackstep; back++)
              {
               res=ExtMapBuffer2[shift+back];
               if((res!=0)&&(res<val)) ExtMapBuffer2[shift+back]=0.0;
              }
           }
        }
      ExtMapBuffer2[shift]=val;
     }

   // final cutting
   lasthigh=-1; lasthighpos=-1;
   lastlow=-1;  lastlowpos=-1;

   for(shift=Bars-ExtDepth; shift>=0; shift--)
     {
      curlow=ExtMapBuffer[shift];
      curhigh=ExtMapBuffer2[shift];
      if((curlow==0)&&(curhigh==0)) continue;
      //---
      if(curhigh!=0)
        {
         if(lasthigh>0)
           {
            if(lasthigh<curhigh) ExtMapBuffer2[lasthighpos]=0;
            else ExtMapBuffer2[shift]=0;
           }
         //---
         if(lasthigh<curhigh || lasthigh<0)
           {
            lasthigh=curhigh;
            lasthighpos=shift;
           }
         lastlow=-1;
        }
      //----
      if(curlow!=0)
        {
         if(lastlow>0)
           {
            if(lastlow>curlow) ExtMapBuffer[lastlowpos]=0;
            else ExtMapBuffer[shift]=0;
           }
         //---
         if((curlow<lastlow)||(lastlow<0))
           {
            lastlow=curlow;
            lastlowpos=shift;
           }
         lasthigh=-1;
        }
     }

   for(shift=Bars-1; shift>=0; shift--)
     {
      if(shift>=Bars-ExtDepth) ExtMapBuffer[shift]=0.0;
      else
        {
         res=ExtMapBuffer2[shift];
         if(res!=0.0) ExtMapBuffer2[shift]=res;
        }
     }
  }

  //end//

[Post to Twitter] Tweet This Post  [Post to Delicious] Delicious This Post  [Post to Ping.fm] Ping This Post  [Post to StumbleUpon] Stumble This Post 

Zig_Zag_Breakout.mq4

//+------------------------------------------------------------------

//|                                           ZigZagRealBreakOut.mq4

//|
//|

//|                                        Converted by Dr. Gaines
//|                                           |
//|                                     |
//+------------------------------------------------------------------

#property copyright " Istoniz "
#property link      " http://www.kg/ "

#property indicator_chart_window
#property indicator_color1 Blue
#property indicator_buffers 2
#property indicator_color2 White
#include <stdlib.mqh>
//+------------------------------------------------------------------

//| Common External variables

//+------------------------------------------------------------------

//+------------------------------------------------------------------

//| External variables
//+------------------------------------------------------------------

extern int barn = 250;
extern double LengthInput = 6;
extern double delaymin = 60;
extern double nSymbolHi = 242;
extern double nSymbolLow = 241;

//+------------------------------------------------------------------

//| Special Convertion Functions

//+------------------------------------------------------------------

int LastTradeTime;
double ExtHistoBuffer[];
double ExtHistoBuffer2[];

void SetLoopCount(int loops)
{
}

void SetIndexValue(int shift, double value)
{
  ExtHistoBuffer[shift] = value;
}

void SetIndexValue2(int shift, double value)
{
  ExtHistoBuffer2[shift] = value;
}

bool SetObjectText(string name, string text, string font, int size,
color Acolor)
{
  return(ObjectSetText(name, text, size, font, Acolor));
}

bool MoveObject(string name, int type, datetime Atime, double Aprice, datetime Atime2 = 0, double Aprice2 = 0, color Acolor = CLR_NONE, int Aweight = 0, int Astyle = 0)
{
    if (ObjectFind(name) != -1)
    {
      int OType = ObjectType(name);

      if ((OType == OBJ_VLINE) ||
         (OType == OBJ_HLINE) ||
         (OType == OBJ_TRENDBYANGLE) ||
         (OType == OBJ_TEXT) ||
         (OType == OBJ_ARROW) ||
         (OType == OBJ_LABEL))
      {
        return(ObjectMove(name, 0, Atime, Aprice));
      }

      if ((OType == OBJ_GANNLINE) ||
         (OType == OBJ_GANNFAN) ||
         (OType == OBJ_GANNGRID) ||
         (OType == OBJ_FIBO) ||
         (OType == OBJ_FIBOTIMES) ||
         (OType == OBJ_FIBOFAN) ||
         (OType == OBJ_FIBOARC) ||
         (OType == OBJ_RECTANGLE) ||
         (OType == OBJ_ELLIPSE) ||
         (OType == OBJ_CYCLES) ||
         (OType == OBJ_TREND) ||
         (OType == OBJ_STDDEVCHANNEL) ||
         (OType == OBJ_REGRESSION))
      {
        return(ObjectMove(name, 0, Atime, Aprice) && ObjectMove(name, 1, Atime2, Aprice2));
      }

/*
          OBJ_CHANNEL,
          OBJ_EXPANSION,
          OBJ_FIBOCHANNEL,
          OBJ_TRIANGLE,
          OBJ_PITCHFORK
*/
    }
    else
    {
      return(ObjectCreate(name, type, 0, Atime, Aprice, Atime2,Aprice2, 0, 0) && ObjectSet(name, OBJPROP_COLOR, Acolor));
    }
}

void SetArrow(datetime ArrowTime, double Price, double ArrowCode, color ArrowColor)
{
int err;
string ArrowName = DoubleToStr(ArrowTime,0);
   if (ObjectFind(ArrowName) != -1) ObjectDelete(ArrowName);
   if(!ObjectCreate(ArrowName, OBJ_ARROW, 0, ArrowTime, Price))
    {
      err=GetLastError();
      Print("error: can't create Arrow! code #",err," ",ErrorDescription(err));
      return;
    }
   else
   {
     ObjectSet(ArrowName, OBJPROP_ARROWCODE, ArrowCode);
     ObjectSet(ArrowName, OBJPROP_COLOR , ArrowColor);
     ObjectsRedraw();
   }
}

//+------------------------------------------------------------------

//| End

//+------------------------------------------------------------------

//+------------------------------------------------------------------

//| Initialization

//+------------------------------------------------------------------

int init()
{
   SetIndexStyle(0, DRAW_LINE, STYLE_SOLID);
   SetIndexBuffer(0, ExtHistoBuffer);
   SetIndexStyle(1, DRAW_LINE, STYLE_SOLID);
   SetIndexBuffer(1, ExtHistoBuffer2);
   return(0);
}
int start()
{
//+------------------------------------------------------------------

//| Local variables

//+------------------------------------------------------------------

int shift = 0;
double LL = 0;
double HH = 0;
double Swing = 0;
double Swing_n = 0;
double BH = 0;
double BL = 0;
int i = 0;
double zu = 0;
double zd = 0;
double NH = 0;
double NL = 0;
int uzl = 0;
double summ = 0;
double current = 0;
double lasttime = 0;
double file_handle = 0;
double Length = 6;
double bs = 0;
double ss = 0;
double buyprice = 0;
double sellprice = 0;
int Uzel[10000,3];

SetLoopCount(0);
// loop from first bar to current bar (with shift=0)
Swing_n=0;Swing=0;uzl=0;
BH =High[barn];BL=Low[barn];zu=barn;zd=barn;

for(shift=barn;shift>=0 ;shift--){
LL=10000000;HH=-100000000;
for(i=shift+Length;i>=shift+1 ;i--){
if( Low[i]< LL ) {LL=Low[i];}
if( High[i]>HH ) {HH=High[i];}
}

if( Low[shift]<LL && High[shift]>HH )
{
Swing=2;
if( Swing_n == 1 ) {zu=shift+1;}
if( Swing_n == -1 ) {zd=shift+1;}

}
else
{
if( Low[shift]<LL ) {Swing=-1;}
if( High[shift]>HH ) {Swing=1;}
}

if( Swing != Swing_n && Swing_n != 0 )
{
if( Swing == 2 ) {Swing=-Swing_n;BH = High[shift];BL = Low[shift]; }
uzl=uzl+1;
if( Swing == 1 ) {Uzel[uzl,1]=zd;Uzel[uzl,2]=BL;Uzel[uzl,3]=shift;}
if( Swing == - 1 ) {Uzel[uzl,1]=zu;Uzel[uzl,2]=BH;Uzel[uzl,3]=shift;}
BH = High[shift];BL = Low[shift];
}

if( Swing == 1 ) { if( High[shift] >= BH ) {BH=High[shift];zu=shift;}}
if( Swing == -1 ) { if( Low[shift]<=BL ) {BL=Low[shift]; zd=shift;}}
Swing_n=Swing;

}

for(i =1;i <=uzl ;i ++){
SetIndexValue(Uzel[i,1],Uzel[i,2]);
SetIndexValue2(Uzel[i,3],Uzel[i,2]);
if( Uzel[i,2]-Uzel[i-1,2]<0 )
      SetArrow(Time[Uzel[i,3]], MathMin(Uzel[i,2], Low[Uzel[i,3]])-10*Point,nSymbolLow, LimeGreen);
if( Uzel[i,2]-Uzel[i-1,2]>0 )
      SetArrow(Time[Uzel[i,3]], MathMax(Uzel[i,2], High[Uzel[i,3]])+20*Point, nSymbolHi, Red);

}

// eugene5 added something here
summ=0;
for(i =1;i <=uzl-1 ;i ++){
      if( Uzel[i+1,2]-Uzel[i,2]>0 )
      //it means that we must sell now (calculating profit using the previous buy
            summ=summ+Close[Uzel[i+1,3]]-Close[Uzel[i,3]];
      if( Uzel[i+1,2]-Uzel[i,2]<0 )
      //it means that we must buy now (calculating profit using the previous sell)
            summ=summ-(Close[Uzel[i+1,3]]-Close[Uzel[i,3]]);
}
//Comment(TimeToStr(Time[0]), "\n"," Swing UP/Swing DWN=",swing, "/", swing_n, "\n","BL/BH=",BL,"/",BH);

//if more than delaymin-mimutes - exit
//If CurTime < lasttime + delaymin*60 Then exit;
//lasttime = CurTime;
//FileDelete("report"+Symbol);
//file_handle = FileOpen("report"+Symbol," ");
summ=0;
for(i =1;i <=uzl-1;i ++){
      if( Uzel[i+1,2]-Uzel[i,2]>0 )
      //seems necessary to sell now (write in log using previous buy)
      {
            ss=MathRound((High[Uzel[i+1,3]]-Low[Uzel[i,3]])/Point)/2;
            sellprice=Low[Uzel[i+1,3]]-ss*Point;
            summ=summ+Close[Uzel[i+1,3]]-buyprice;
        //    Comment("Bought at ", buyprice,"  ", TimeToStr(Time[Uzel[i,3]]),"'#10'Closed at on the price of ", Close[Uzel[i+1,3]], " ",TimeToStr(Time[Uzel[i+1,3]]),"'#10'Profit on last position= ", (Open[Uzel[i+1,3]]-buyprice)/Point,"pips","'#10''#10''#10'Next Trade  ---> SELLSTOP @ ",sellprice);
      //      comment("Close at ", TimeToStr(Time[Uzel[i+1,3]]), "on the price of ", Close[Uzel[i+1,3]]);
      //      comment("Place SELLSTOP @ ", sellprice ,"\n",TimeToStr(Time[Uzel[i+1,3]]));
          MoveObject("sellprice",OBJ_HLINE,Time[0],sellprice,Time[0],sellprice,Red,1,STYLE_SOLID);
          SetObjectText("sellprice_txt","SELLHere ","Arial",7,White);
        MoveObject("sellprice_txt",OBJ_TEXT,Time[0],sellprice,Time[0],sellprice,White);
            }
      if( Uzel[i+1,2]-Uzel[i,2]<0 )
      //seems necessary to buy now (write in log using previous sell)
      {
            bs=MathRound(-(Low[Uzel[i+1,3]]-High[Uzel[i,3]])/Point)/2;
            buyprice=High[Uzel[i+1,3]]+bs*Point;
            summ=summ-(Close[Uzel[i+1,3]]-sellprice);
           // Comment("Sold at ", sellprice,"  ", TimeToStr(Time[Uzel[i,3]]),"'#10'Closed at on the price of ", Close[Uzel[i+1,3]]," ",TimeToStr(Time[Uzel[i+1,3]]),"'#10'Profit on last position= ", -(Open[Uzel[i+1,3]]-sellprice)/Point," pips","'#10''#10''#10'Next Trade  ---> BUYSTOP @ ", buyprice);
      //      comment("Close at ", TimeToStr(Time[Uzel[i+1,3]]), "on the price of ", Close[Uzel[i+1,3]]);
      //   comment("Place BUYSTOP @ ", buyprice   ,"\n",TimeToStr(Time[Uzel[i+1,3]]));
            MoveObject("buyprice",OBJ_HLINE,Time[0],buyprice,Time[0],buyprice,LimeGreen,1,STYLE_SOLID);
          SetObjectText("buyprice_txt","BUY Here ","Arial",7,White);
        MoveObject("buyprice_txt",OBJ_TEXT,Time[0],buyprice,Time[0],buyprice,White);
            //FileWrite(file_handle,"profit on this position=", -(Close[Uzel[i+1,3]]-Close[Uzel[i,3]])/Point,       "Totally inpoints=", summ/Point);
            }}}

//FileClose(file_handle);
//print(TimeToStr(Time[Uzel[i,3]]),l[Uzel[i,3]]);
  return(0);

[Post to Twitter] Tweet This Post  [Post to Delicious] Delicious This Post  [Post to Ping.fm] Ping This Post  [Post to StumbleUpon] Stumble This Post 

ZeroLagStochsSignals.mq4

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 LimeGreen
#property indicator_color2 Red
//---- input parameters
extern int a=14;
extern int alerty=0;  // 0 for alerts 1 for no alerts
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double b4zls,nowzls,nowzlsmain;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_ARROW,EMPTY);
SetIndexArrow(0,233);
SetIndexBuffer(0, ExtMapBuffer1);

SetIndexStyle(1,DRAW_ARROW,EMPTY);
SetIndexArrow(1,234);
SetIndexBuffer(1, ExtMapBuffer2);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//---- TODO: add your code here
//ObjectDelete("");
//ObjectDelete("down cross");
//ObjectDelete(0,233);
//ObjectDeleteEx(0, DRAW_ARROW,0,0,0);

//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int limit;
int counted_bars=IndicatorCounted();
//---- check for possible errors
if(counted_bars<0) return(-1);

//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=1000-counted_bars;
//---- macd counted in the 1-st buffer

 for(int i=limit; i>=0; i--)
{
   b4zls=iCustom(NULL,0,"ZeroLagStochs",0,i+1);

   nowzls=iCustom(NULL,0,"ZeroLagStochs",0,i);
   nowzlsmain=iCustom(NULL,0,"ZeroLagStochs",1,i);

 if(b4zls>nowzlsmain &&
         nowzls<nowzlsmain)

          {
            ExtMapBuffer2[i]=High[i]+7*Point;
      if (alerty==0 && i<2 ) Alert(Symbol()," ",Period()," ZeroLagStochs Cross SELL");
         }

    if(b4zls<nowzlsmain &&
         nowzls>nowzlsmain)
       {
            ExtMapBuffer1[i]=Low[i]-5*Point;
        if (alerty==0 && i<2) Alert(Symbol()," ",Period()," ZeroLagStochs Cross BUY");
       }
}
//----
return(0);
}

[Post to Twitter] Tweet This Post  [Post to Delicious] Delicious This Post  [Post to Ping.fm] Ping This Post  [Post to StumbleUpon] Stumble This Post 

Zerolagstochs_B.mq4

//+------------------------------------------------------------------+
//|                                                   PriceVSwma.mq4 |
//|                      Copyright ?2004, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright ?2004, MetaQuotes Software Corp."
#property link      "perky_z@yahoo.com"

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 White
#property indicator_color2 Red

extern int  smoothing=13;
extern int  timeframe=0;
//---- input parameters

double stok1=0,stok2=0,stok3=0,stok4=0,stok5=0,mov=0,stoksmoothed=0;
int shift=0, MAType=1, cnt=0,  prevbars=0,loopbegin=0;

bool first=true;
//---- buffers
double TrendBuffer[];
double LoBuffer[];
double HiBuffer[];
double PlusSdiBuffer[];
double MinusSdiBuffer[];
double TempBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- 3 additional buffers are used for counting.
   IndicatorBuffers(3);
//---- indicator buffers
   SetIndexBuffer(0,TrendBuffer);
   SetIndexBuffer(1,LoBuffer);

    SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2,White);
    SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,2,Red);
    IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("ZLS("+smoothing+")");

   SetIndexDrawBegin(0,TrendBuffer);
   SetIndexDrawBegin(1,LoBuffer);

   return(0);
  }
//+------------------------------------------------------------------+
//| Average Directional Movement Index                               |
//+------------------------------------------------------------------+
int start()
  {
  // initial checkings
// check for additional bars loading or total reloading
if (Bars < prevbars )  first = true;
if (Bars-prevbars>1) first = true;
prevbars = Bars;
if (first)
{
	// loopbegin prevent couning of counted bars exclude current
	loopbegin = Bars-1;
	if (loopbegin < 0) return(0);      // not enough bars for counting

	first = False;
   }

  loopbegin = loopbegin+1;
 // Comment( loopbegin);            // current bar is to be recounted too
  for (shift = loopbegin; shift>= 0 ;shift--)
	{

stok5 = (iStochastic(NULL,timeframe,52,12,3,MODE_LWMA,NULL,MODE_MAIN,shift))*0.00;
stok4 = (iStochastic(NULL,timeframe,34,8,3,MODE_LWMA,NULL,MODE_MAIN,shift))*0.0;
stok3 = (iStochastic(NULL,timeframe,21,5,3,MODE_LWMA,NULL,MODE_MAIN,shift))*0.10;
stok2 = (iStochastic(NULL,timeframe,12,4,3,MODE_LWMA,NULL,MODE_MAIN,shift))*0.65;
stok1 = (iStochastic(NULL,timeframe,8,3,3,MODE_LWMA,NULL,MODE_MAIN,shift))*0.25;
mov   = stok1+stok2+stok3+stok4+stok5;
stoksmoothed = mov/smoothing + LoBuffer[shift+1]*(smoothing-1)/smoothing;

	TrendBuffer[shift]=mov;
	LoBuffer[shift]=	stoksmoothed;

	loopbegin = loopbegin-1;
	}}
	return(0);
	    // prevent to previous bars recounting

[Post to Twitter] Tweet This Post  [Post to Delicious] Delicious This Post  [Post to Ping.fm] Ping This Post  [Post to StumbleUpon] Stumble This Post 

Zerolagstochs.mq4

//+------------------------------------------------------------------+
//|                                                   PriceVSwma.mq4 |
//|                      Copyright ?2004, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright ?2004, MetaQuotes Software Corp."
#property link      "perky_z@yahoo.com"

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 White
#property indicator_color2 Red

//---- input parameters

double stok1=0,stok2=0,stok3=0,stok4=0,stok5=0,mov=0,stoksmoothed=0,smoothing=15;
int shift=0, MAType=1, cnt=0,  prevbars=0,loopbegin=0;

bool first=true;
//---- buffers
double TrendBuffer[];
double LoBuffer[];
double HiBuffer[];
double PlusSdiBuffer[];
double MinusSdiBuffer[];
double TempBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- 3 additional buffers are used for counting.
   IndicatorBuffers(3);
//---- indicator buffers
   SetIndexBuffer(0,TrendBuffer);
   SetIndexBuffer(1,LoBuffer);

    SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2,White);
    SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,2,Red);
    IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("Zero Lag Stocs");

//   SetIndexDrawBegin(0,TrendBuffer);
//   SetIndexDrawBegin(1,LoBuffer);

   return(0);
  }
//+------------------------------------------------------------------+
//| Average Directional Movement Index                               |
//+------------------------------------------------------------------+
int start()
  {
  // initial checkings
// check for additional bars loading or total reloading
if (Bars < prevbars )  first = true;
if (Bars-prevbars>1) first = true;
prevbars = Bars;
if (first)
{
	// loopbegin prevent couning of counted bars exclude current
	loopbegin = Bars-1;
	if (loopbegin < 0) return(0);      // not enough bars for counting

	first = False;
   }

  loopbegin = loopbegin+1;
 // Comment( loopbegin);            // current bar is to be recounted too
  for (shift = loopbegin; shift>= 0 ;shift--)
	{

stok1 = (iStochastic(NULL,0,8,3,3,MODE_SMA,NULL,MODE_MAIN,shift))*0.05;
stok2 = (iStochastic(NULL,0,89,21,3,MODE_SMA,NULL,MODE_MAIN,shift))*0.43;
stok3 = (iStochastic(NULL,0,55,13,3,MODE_SMA,NULL,MODE_MAIN,shift))*0.26;
stok4 = (iStochastic(NULL,0,34,8,3,MODE_SMA,NULL,MODE_MAIN,shift))*0.16;
stok5 = (iStochastic(NULL,0,21,5,3,MODE_SMA,NULL,MODE_MAIN,shift))*0.10;
mov   = stok1+stok2+stok3+stok4+stok5;
stoksmoothed = mov/smoothing + LoBuffer[shift+1]*(smoothing-1)/smoothing;

	TrendBuffer[shift]=mov;
	LoBuffer[shift]=	stoksmoothed;

	loopbegin = loopbegin-1;
	}}
	return(0);
	    // prevent to previous bars recounting

[Post to Twitter] Tweet This Post  [Post to Delicious] Delicious This Post  [Post to Ping.fm] Ping This Post  [Post to StumbleUpon] Stumble This Post 

ZeroLagStoch.mq4

//+------------------------------------------------------------------+
//|                                                   PriceVSwma.mq4 |
//|                      Copyright ?2004, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright ?2004, MetaQuotes Software Corp."
#property link      "perky_z@yahoo.com"

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 White
#property indicator_color2 Red

//---- input parameters

double stok1=0,stok2=0,stok3=0,stok4=0,stok5=0,mov=0,stoksmoothed=0,smoothing=15;
int shift=0, MAType=1, cnt=0,  prevbars=0,loopbegin=0;

bool first=true;
//---- buffers
double TrendBuffer[];
double LoBuffer[];
double HiBuffer[];
double PlusSdiBuffer[];
double MinusSdiBuffer[];
double TempBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- 3 additional buffers are used for counting.
   IndicatorBuffers(3);
//---- indicator buffers
   SetIndexBuffer(0,TrendBuffer);
   SetIndexBuffer(1,LoBuffer);

    SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2,White);
    SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,2,Red);
    IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("Zero Lag Stocs");

   SetIndexDrawBegin(0,TrendBuffer);
   SetIndexDrawBegin(1,LoBuffer);

   return(0);
  }
//+------------------------------------------------------------------+
//| Average Directional Movement Index                               |
//+------------------------------------------------------------------+
int start()
  {
  // initial checkings
// check for additional bars loading or total reloading
if (Bars < prevbars )  first = true;
if (Bars-prevbars>1) first = true;
prevbars = Bars;
if (first)
{
// loopbegin prevent couning of counted bars exclude current
loopbegin = Bars-1;
if (loopbegin < 0) return(0);      // not enough bars for counting

first = False;
   }

  loopbegin = loopbegin+1;
 // Comment( loopbegin);            // current bar is to be recounted too
  for (shift = loopbegin; shift>= 0 ;shift--)
{

stok1 = (iStochastic(NULL,0,8,3,3,MODE_SMA,NULL,MODE_MAIN,shift))*0.05;
stok2 = (iStochastic(NULL,0,89,21,3,MODE_SMA,NULL,MODE_MAIN,shift))*0.43;
stok3 = (iStochastic(NULL,0,55,13,3,MODE_SMA,NULL,MODE_MAIN,shift))*0.26;
stok4 = (iStochastic(NULL,0,34,8,3,MODE_SMA,NULL,MODE_MAIN,shift))*0.16;
stok5 = (iStochastic(NULL,0,21,5,3,MODE_SMA,NULL,MODE_MAIN,shift))*0.10;
mov   = stok1+stok2+stok3+stok4+stok5;
stoksmoothed = mov/smoothing + LoBuffer[shift+1]*(smoothing-1)/smoothing;

TrendBuffer[shift]=mov;
LoBuffer[shift]=stoksmoothed;

loopbegin = loopbegin-1;
}}
return(0);
    // prevent to previous bars recounting

[Post to Twitter] Tweet This Post  [Post to Delicious] Delicious This Post  [Post to Ping.fm] Ping This Post  [Post to StumbleUpon] Stumble This Post 

ZeroLag MACD.mq4

//+------------------------------------------------------------------+
//|                                                 ZeroLag MACD.mq4 |
//|                                                               RD |
//|                                                 marynarz15@wp.pl |
//+------------------------------------------------------------------+
#property copyright "RD"
#property link      "marynarz15@wp.pl"

#property indicator_separate_window
#property  indicator_buffers 2
#property indicator_color1 Magenta
#property indicator_color2 Orange
//---- input parameters
extern int       FastEMA=12;
extern int       SlowEMA=24;
extern int       SignalEMA=9;
//---- buffers
double MACDBuffer[];
double SignalBuffer[];
double FastEMABuffer[];
double SlowEMABuffer[];
double SignalEMABuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   IndicatorBuffers(5);
   SetIndexBuffer(0,MACDBuffer);
   SetIndexBuffer(1,SignalBuffer);
   SetIndexBuffer(2,FastEMABuffer);
   SetIndexBuffer(3,SlowEMABuffer);
   SetIndexBuffer(4,SignalEMABuffer);
   SetIndexStyle(0,DRAW_HISTOGRAM,EMPTY,2);
   SetIndexStyle(1,DRAW_LINE,EMPTY,2);
   SetIndexDrawBegin(0,SlowEMA);
   SetIndexDrawBegin(1,SlowEMA);
   IndicatorShortName("ZeroLag MACD("+FastEMA+","+SlowEMA+","+SignalEMA+")");
   SetIndexLabel(0,"MACD");
   SetIndexLabel(1,"Signal");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int limit;
   int counted_bars=IndicatorCounted();
   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
   double EMA,ZeroLagEMAp,ZeroLagEMAq;
   for(int i=0; i<limit; i++)
      {
         FastEMABuffer[i]=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i);
         SlowEMABuffer[i]=iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i);
      }
   for(i=0; i<limit; i++)
      {
         EMA=iMAOnArray(FastEMABuffer,Bars,FastEMA,0,MODE_EMA,i);
         ZeroLagEMAp=FastEMABuffer[i]+FastEMABuffer[i]-EMA;
         EMA=iMAOnArray(SlowEMABuffer,Bars,SlowEMA,0,MODE_EMA,i);
         ZeroLagEMAq=SlowEMABuffer[i]+SlowEMABuffer[i]-EMA;
         MACDBuffer[i]=ZeroLagEMAp - ZeroLagEMAq;
      }
   for(i=0; i<limit; i++)
         SignalEMABuffer[i]=iMAOnArray(MACDBuffer,Bars,SignalEMA,0,MODE_EMA,i);
   for(i=0; i<limit; i++)
      {
         EMA=iMAOnArray(SignalEMABuffer,Bars,SignalEMA,0,MODE_EMA,i);
         SignalBuffer[i]=SignalEMABuffer[i]+SignalEMABuffer[i]-EMA;
      }
   return(0);
  }
//+------------------------------------------------------------------+

[Post to Twitter] Tweet This Post  [Post to Delicious] Delicious This Post  [Post to Ping.fm] Ping This Post  [Post to StumbleUpon] Stumble This Post 

YANSTEST 6wait.mq4

//+------------------------------------------------------------------+
//| 5 Min RSI 12-period qual INDICATOR                               |
//+------------------------------------------------------------------+
#property copyright "Ron T"
#property link      "http://www.lightpatch.com"

#property indicator_chart_window
#property indicator_buffers 8

#property indicator_color1 Red
#property indicator_color2 Red
#property indicator_color3 Red
#property indicator_color4 Red

#property indicator_color5 White
#property indicator_color6 White
#property indicator_color7 White
#property indicator_color8 White

//---- buffers
double Buffer1[];
double Buffer2[];
double Buffer3[];
double Buffer4[];
double Buffer5[];
double Buffer6[];
double Buffer7[];
double Buffer8[];

// User Input

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//|------------------------------------------------------------------|

int init()
  {

   // 233 up arrow
   // 234 down arrow
   // 159 big dot
   // 168 open square
   // 120 box with X

   SetIndexStyle(0,DRAW_ARROW);  //RED ARROW
   SetIndexBuffer(0, Buffer1);
   SetIndexArrow(0,234);

   SetIndexStyle(1,DRAW_ARROW);
   SetIndexBuffer(1, Buffer2);
   SetIndexArrow(1,159);

   SetIndexStyle(2,DRAW_ARROW);  //RED OPEN BOX
   SetIndexBuffer(2, Buffer3);
   SetIndexArrow(2,120);

   SetIndexStyle(3,DRAW_ARROW);  //RED DOT
   SetIndexBuffer(3, Buffer4);
   SetIndexArrow(3,159);

   SetIndexStyle(4,DRAW_ARROW);  //WHITE ARROW
   SetIndexBuffer(4, Buffer5);
   SetIndexArrow(4,233);

   SetIndexStyle(5,DRAW_ARROW);
   SetIndexBuffer(5, Buffer6);
   SetIndexArrow(5,159);

   SetIndexStyle(6,DRAW_ARROW);  //WHITE X BOX
   SetIndexBuffer(6, Buffer7);
   SetIndexArrow(6,120);

   SetIndexStyle(7,DRAW_ARROW);  //RED DOT
   SetIndexBuffer(7, Buffer8);
   SetIndexArrow(7,159);

   return(0);
  }

//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
   int i;

   for( i=0; i<Bars; i++ ) Buffer1[i]=0;
   for( i=0; i<Bars; i++ ) Buffer2[i]=0;
   for( i=0; i<Bars; i++ ) Buffer3[i]=0;
   for( i=0; i<Bars; i++ ) Buffer4[i]=0;
   for( i=0; i<Bars; i++ ) Buffer5[i]=0;
   for( i=0; i<Bars; i++ ) Buffer6[i]=0;
   for( i=0; i<Bars; i++ ) Buffer7[i]=0;
   for( i=0; i<Bars; i++ ) Buffer8[i]=0;

   return(0);
  }

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int      pos=Bars-150; // leave room for moving average periods

   double   cEMA10=0, pEMA10=0;
   double   cEMA40=0, pEMA40=0;
   double   cSAR=0,   pSAR=10;

   bool      rising=false;
   bool     falling=false;

   bool       sarLO=false;
   bool       sarHI=false;

   bool      flipUP=false;
   bool      flipDN=false;

   int      dCROSS;    // how many periods since last MA cross

   int      above=0;   // how long SAR has been up
   int      below=0;   // how long SAR has been down

   double    p=Point();

   bool      Over=false;
   bool      Under=false;

   // 1 RED    DOWN ARROW
   // 2 RED
   // 3 RED    BIG OPEN BOX
   // 4 RED    BIG DOT
   // 5 WHITE  UP ARROW
   // 6 WHITE
   // 7 WHITE  BIG X BOX
   // 8 WHITE  BIG DOT

   while(pos>=0)
     {

      cEMA10=iMA(Symbol(),0,10,0,MODE_EMA,PRICE_CLOSE, pos);
      pEMA10=iMA(Symbol(),0,10,0,MODE_EMA,PRICE_CLOSE, pos+1);
      cEMA40=iMA(Symbol(),0,40,0,MODE_EMA,PRICE_CLOSE, pos);
      pEMA40=iMA(Symbol(),0,40,0,MODE_EMA,PRICE_CLOSE, pos+1);
      cSAR=iSAR(Symbol(),0,0.02,0.2,pos);
      pSAR=iSAR(Symbol(),0,0.02,0.2,pos+1);

      //
      // Set all the switches
      //

      // determine if rising or falling cross
      rising=false;
      if (pEMA10<=pEMA40 && cEMA10>=cEMA40){rising=true;}
      falling=false;
      if (pEMA10>=pEMA40 && cEMA10<=cEMA40){falling=true;}

      // which side is SAR on
      sarLO=false;
      if (cSAR<Low[pos])  sarLO=true;
      sarHI=false;
      if (cSAR>High[pos]) sarHI=true;

      // did PSAR just flip
      flipUP=false;
      if (pSAR<=Low[pos+1] && cSAR>=High[pos]){flipUP=true;}
      flipDN=false;
      if (pSAR>=High[pos+1] && cSAR<=Low[pos]){flipDN=true;}

      //
      // Show all the indicators based on switches
      //

      // rising crosses with LOW SAR ONLY
      if (rising){Buffer7[pos]=cEMA10; above=0; below=0;}  //WHITE BOX
      // falling crosses with HIGH SAR ONLY
      if (falling){Buffer3[pos]=cEMA10; above=0; below=0;} //RED BOX

      if (sarHI) above++;  // count how long SAR has been up
      if (sarLO) below++;  // count how long SAR has been down

      if (above+below>6)
        {
         //SAR crossed above EMA40
         if (pSAR<pEMA40 && cSAR>=cEMA40 && !flipUP && !flipDN){Buffer8[pos]=cSAR;} // dot
         //SAR crossed below EMA40
         if (pSAR>pEMA40 && cSAR<=cEMA40 && !flipUP && !flipDN){Buffer4[pos]=cSAR;} // dot

         if (flipUP && below<=6){Buffer1[pos]=cSAR;}  // arrow
         if (flipDN && above<=6){Buffer5[pos]=cSAR;}  // arrow
        }

 	   pos--;
     }

   return(0);
  }
//+------------------------------------------------------------------+

[Post to Twitter] Tweet This Post  [Post to Delicious] Delicious This Post  [Post to Ping.fm] Ping This Post  [Post to StumbleUpon] Stumble This Post 

YANS_IND_04.mq4

//+------------------------------------------------------------------+
//| 5 Min RSI 12-period qual INDICATOR                               |
//+------------------------------------------------------------------+
#property copyright "Ron T"
#property link      "http://www.lightpatch.com"

#property indicator_chart_window
#property indicator_buffers 8

#property indicator_color1 Red
#property indicator_color2 Red
#property indicator_color3 Red
#property indicator_color4 Red

#property indicator_color5 White
#property indicator_color6 White
#property indicator_color7 White
#property indicator_color8 White

//---- buffers
double Buffer1[];
double Buffer2[];
double Buffer3[];
double Buffer4[];
double Buffer5[];
double Buffer6[];
double Buffer7[];
double Buffer8[];

// User Input

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//|------------------------------------------------------------------|

int init()
  {

   // 233 up arrow
   // 234 down arrow
   // 159 big dot
   // 168 open square
   // 120 box with X

   SetIndexStyle(0,DRAW_ARROW);  //RED ARROW
   SetIndexBuffer(0, Buffer1);
   SetIndexArrow(0,234);

   SetIndexStyle(1,DRAW_ARROW);
   SetIndexBuffer(1, Buffer2);
   SetIndexArrow(1,159);

   SetIndexStyle(2,DRAW_ARROW);  //RED OPEN BOX
   SetIndexBuffer(2, Buffer3);
   SetIndexArrow(2,120);

   SetIndexStyle(3,DRAW_ARROW);  //RED DOT
   SetIndexBuffer(3, Buffer4);
   SetIndexArrow(3,159);

   SetIndexStyle(4,DRAW_ARROW);  //WHITE ARROW
   SetIndexBuffer(4, Buffer5);
   SetIndexArrow(4,233);

   SetIndexStyle(5,DRAW_ARROW);
   SetIndexBuffer(5, Buffer6);
   SetIndexArrow(5,159);

   SetIndexStyle(6,DRAW_ARROW);  //WHITE X BOX
   SetIndexBuffer(6, Buffer7);
   SetIndexArrow(6,120);

   SetIndexStyle(7,DRAW_ARROW);  //RED DOT
   SetIndexBuffer(7, Buffer8);
   SetIndexArrow(7,159);

   return(0);
  }

//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
   int i;

   for( i=0; i<Bars; i++ ) Buffer1[i]=0;
   for( i=0; i<Bars; i++ ) Buffer2[i]=0;
   for( i=0; i<Bars; i++ ) Buffer3[i]=0;
   for( i=0; i<Bars; i++ ) Buffer4[i]=0;
   for( i=0; i<Bars; i++ ) Buffer5[i]=0;
   for( i=0; i<Bars; i++ ) Buffer6[i]=0;
   for( i=0; i<Bars; i++ ) Buffer7[i]=0;
   for( i=0; i<Bars; i++ ) Buffer8[i]=0;

   return(0);
  }

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int      pos=350; // leave room for moving average periods

   double   cEMA10=0, pEMA10=0;
   double   cEMA40=0, pEMA40=0;
   double   cSAR=0,   pSAR=10;

   bool      rising=false;
   bool     falling=false;

   bool       sarLO=false;
   bool       sarHI=false;

   bool      flipUP=false;
   bool      flipDN=false;

   int      dCROSS;    // how many periods since last MA cross

   int      above=0;   // how long SAR has been up
   int      below=0;   // how long SAR has been down

   double    p=Point();

   bool      Over=false;
   bool      Under=false;

   // 1 RED    DOWN ARROW
   // 2 RED
   // 3 RED    BIG OPEN BOX
   // 4 RED    BIG DOT
   // 5 WHITE  UP ARROW
   // 6 WHITE
   // 7 WHITE  BIG X BOX
   // 8 WHITE  BIG DOT

   while(pos>=0)
     {

      cEMA10=iMA(Symbol(),0,10,0,MODE_EMA,PRICE_CLOSE, pos);
      pEMA10=iMA(Symbol(),0,10,0,MODE_EMA,PRICE_CLOSE, pos+1);
      cEMA40=iMA(Symbol(),0,40,0,MODE_EMA,PRICE_CLOSE, pos);
      pEMA40=iMA(Symbol(),0,40,0,MODE_EMA,PRICE_CLOSE, pos+1);
      cSAR=iSAR(Symbol(),0,0.02,0.2,pos);
      pSAR=iSAR(Symbol(),0,0.02,0.2,pos+1);

      //
      // Set all the switches
      //

      // determine if rising or falling cross
      rising=false;
      if (pEMA10<=pEMA40 && cEMA10>=cEMA40){rising=true;}
      falling=false;
      if (pEMA10>=pEMA40 && cEMA10<=cEMA40){falling=true;}

      // which side is SAR on
      sarLO=false;
      if (cSAR<Low[pos])  sarLO=true;
      sarHI=false;
      if (cSAR>High[pos]) sarHI=true;

      // did PSAR just flip
      flipUP=false;
      if (pSAR<=Low[pos+1] && cSAR>=High[pos]){flipUP=true;}
      flipDN=false;
      if (pSAR>=High[pos+1] && cSAR<=Low[pos]){flipDN=true;}

      //
      // Show all the indicators based on switches
      //

      // rising crosses with LOW SAR ONLY
      if (rising){Buffer7[pos]=cEMA10; above=0; below=0;}  //WHITE BOX
      // falling crosses with HIGH SAR ONLY
      if (falling){Buffer3[pos]=cEMA10; above=0; below=0;} //RED BOX

      //SAR crossed above EMA40
      if (pSAR<pEMA40 && cSAR>=cEMA40 && !flipUP && !flipDN){Buffer8[pos]=cSAR;}
      //SAR crossed below EMA40
      if (pSAR>pEMA40 && cSAR<=cEMA40 && !flipUP && !flipDN){Buffer4[pos]=cSAR;}

      if (sarHI) above++;  // count how long SAR has been up
      if (sarLO) below++;  // count how long SAR has been down

      if (flipUP && below<=6){Buffer1[pos]=cSAR;}
      if (flipDN && above<=6){Buffer5[pos]=cSAR;}

 	   pos--;
     }

   return(0);
  }
//+------------------------------------------------------------------+

[Post to Twitter] Tweet This Post  [Post to Delicious] Delicious This Post  [Post to Ping.fm] Ping This Post  [Post to StumbleUpon] Stumble This Post 

YANS_IND2_01.mq4

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Ron T"
#property link      "http://www.lightpatch.com"

#property indicator_chart_window
#property indicator_buffers 8

#property indicator_color1 Red
#property indicator_color2 Red
#property indicator_color3 Red
#property indicator_color4 Red

#property indicator_color5 White
#property indicator_color6 White
#property indicator_color7 White
#property indicator_color8 White

//---- buffers
double Buffer1[];
double Buffer2[];
double Buffer3[];
double Buffer4[];
double Buffer5[];
double Buffer6[];
double Buffer7[];
double Buffer8[];

// User Input

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//|------------------------------------------------------------------|

int init()
  {

   // 233 up arrow
   // 234 down arrow
   // 159 big dot
   // 168 open square
   // 120 box with X

   SetIndexStyle(0,DRAW_ARROW);  //RED ARROW
   SetIndexBuffer(0, Buffer1);
   SetIndexArrow(0,234);

   SetIndexStyle(1,DRAW_ARROW);
   SetIndexBuffer(1, Buffer2);
   SetIndexArrow(1,159);

   SetIndexStyle(2,DRAW_ARROW);  //RED OPEN BOX
   SetIndexBuffer(2, Buffer3);
   SetIndexArrow(2,120);

   SetIndexStyle(3,DRAW_ARROW);  //RED DOT
   SetIndexBuffer(3, Buffer4);
   SetIndexArrow(3,159);

   SetIndexStyle(4,DRAW_ARROW);  //WHITE ARROW
   SetIndexBuffer(4, Buffer5);
   SetIndexArrow(4,233);

   SetIndexStyle(5,DRAW_ARROW);
   SetIndexBuffer(5, Buffer6);
   SetIndexArrow(5,159);

   SetIndexStyle(6,DRAW_ARROW);  //WHITE X BOX
   SetIndexBuffer(6, Buffer7);
   SetIndexArrow(6,120);

   SetIndexStyle(7,DRAW_ARROW);  //RED DOT
   SetIndexBuffer(7, Buffer8);
   SetIndexArrow(7,159);

   return(0);
  }

//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
   int i;

   for( i=0; i<Bars; i++ ) Buffer1[i]=0;
   for( i=0; i<Bars; i++ ) Buffer2[i]=0;
   for( i=0; i<Bars; i++ ) Buffer3[i]=0;
   for( i=0; i<Bars; i++ ) Buffer4[i]=0;
   for( i=0; i<Bars; i++ ) Buffer5[i]=0;
   for( i=0; i<Bars; i++ ) Buffer6[i]=0;
   for( i=0; i<Bars; i++ ) Buffer7[i]=0;
   for( i=0; i<Bars; i++ ) Buffer8[i]=0;

   return(0);
  }

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int      pos=Bars-100; // leave room for moving average periods

   double   cEMA10=0, pEMA10=0;
   double   cEMA40=0, pEMA40=0;
   double   cSAR=0,   pSAR=10;

   int      lastcross=0;
   double   lastlevel=0;

   bool      rising=false;
   bool     falling=false;

   bool       sarLO=false;
   bool       sarHI=false;

   bool      flipUP=false;
   bool      flipDN=false;

   int      dCROSS;    // how many periods since last MA cross

   int      above=0;   // how long SAR has been up
   int      below=0;   // how long SAR has been down

   double    p=Point();

   bool      Over=false;
   bool      Under=false;

   bool      onecross=false;

   // 1 RED    DOWN ARROW
   // 2 RED
   // 3 RED    BIG OPEN BOX
   // 4 RED    BIG DOT
   // 5 WHITE  UP ARROW
   // 6 WHITE
   // 7 WHITE  BIG X BOX
   // 8 WHITE  BIG DOT

   while(pos>=0)
     {

      cEMA10=iMA(Symbol(),0,10,0,MODE_EMA,PRICE_CLOSE, pos);
      pEMA10=iMA(Symbol(),0,10,0,MODE_EMA,PRICE_CLOSE, pos+1);
      cEMA40=iMA(Symbol(),0,40,0,MODE_EMA,PRICE_CLOSE, pos);
      pEMA40=iMA(Symbol(),0,40,0,MODE_EMA,PRICE_CLOSE, pos+1);
      cSAR=iSAR(Symbol(),0,0.02,0.2,pos);
      pSAR=iSAR(Symbol(),0,0.02,0.2,pos+1);

      //
      // Set all the switches
      //

      // determine if rising or falling cross
      rising=false;
      if (pEMA10<=pEMA40 && cEMA10>=cEMA40){rising=true; onecross=false;}
      falling=false;
      if (pEMA10>=pEMA40 && cEMA10<=cEMA40){falling=true; onecross=false;}

      // which side is SAR on
      sarLO=false;
      if (cSAR<Low[pos])  sarLO=true;
      sarHI=false;
      if (cSAR>High[pos]) sarHI=true;

      // did PSAR just flip
      flipUP=false;
      if (pSAR<=Low[pos+1] && cSAR>=High[pos]){flipUP=true;}
      flipDN=false;
      if (pSAR>=High[pos+1] && cSAR<=Low[pos]){flipDN=true;}

      //
      // Show all the indicators based on switches
      //

      // rising crosses with LOW SAR ONLY
      //Buffer7[pos]=cEMA10;
      if (rising){lastcross=pos; lastlevel=cEMA10; above=0; below=0; dCROSS=0;}  //WHITE BOX
      // falling crosses with HIGH SAR ONLY
      //Buffer3[pos]=cEMA10;
      if (falling){lastcross=pos; lastlevel=cEMA10; above=0; below=0; dCROSS=0;} //RED BOX

      //SAR crossed above EMA40
      if (pSAR<pEMA40 && cSAR>=cEMA40 && !flipUP && !flipDN)
         {
          if (!onecross && dCROSS>=6) {Buffer7[lastcross]=lastlevel; Buffer5[pos]=cSAR; onecross=true;}
         }
      //SAR crossed below EMA40
      if (pSAR>pEMA40 && cSAR<=cEMA40 && !flipUP && !flipDN)
         {
          if (!onecross && dCROSS>=6) {Buffer3[lastcross]=lastlevel; Buffer1[pos]=cSAR; onecross=true;}
         }

      if  (rising && !onecross) {Buffer7[lastcross]=0; lastcross=pos;}
      if (falling && !onecross) {Buffer3[lastcross]=0; lastcross=pos;}

      //if (sarHI) above++;  // count how long SAR has been up
      //if (sarLO) below++;  // count how long SAR has been down

      //if (flipUP && below<=6){Buffer1[pos]=cSAR;}
      //if (flipDN && above<=6){Buffer5[pos]=cSAR;}

      dCROSS++;
 	   pos--;
     }

   return(0);
  }
//+------------------------------------------------------------------+

[Post to Twitter] Tweet This Post  [Post to Delicious] Delicious This Post  [Post to Ping.fm] Ping This Post  [Post to StumbleUpon] Stumble This Post 

 Page 2 of 100 « 1  2  3  4  5 » ...  Last » 

Tweet This Post links powered by Tweet This v1.3.9, a WordPress plugin for Twitter.