Navigation´╝ÜHome > Content >

Stoch_4CHistogramAlert.mq4

Time: 2018-10-17 | Download file:Stoch_4CHistogramAlert.mq4

/*_                                                             _
 /|\___________________________________________________________/|\
 \|/                                                           \|/
  |                                      Stoch 4CHistogramAlert |
  |                                                      BLUR71 |
 /|\___________________________________________________________/|\
 \|/                                                           \|/
*/
#property copyright "BLUR71"
#property link      "[email protected]"
#property link      "www.forex-tsd.com"
#property indicator_separate_window
#property indicator_buffers 7
#property indicator_color1 LimeGreen
#property indicator_width1 4
#property indicator_color2 OrangeRed
#property indicator_width2 4
#property indicator_color3 Red
#property indicator_width3 4
#property indicator_color4 Green
#property indicator_width4 4
#property indicator_color5 Yellow
#property indicator_width5 3
#property indicator_color6 Aqua
#property indicator_width6 0
#property indicator_style6 2
#property indicator_color7 Snow
#property indicator_width7 0
#property indicator_style7 2
#property indicator_levelcolor DarkSlateGray
#property indicator_levelstyle 2
#define   indicator_minimum -50
#define   indicator_maximum  50
extern bool AlertOn=false,HistogramOn=true,ColorDescendingBars=true,FourColorBars=true,
            PlotMainLine=true,PlotSignalLine=true,PlotStoMA=true;
extern int  KPeriod=10,DPeriod=4,SPeriod=4, MAMode=0,MAPrice=0,StoMASignal=10,StoMAMode=3,
            BuyAlertLevel=-30,SellAlertLevel=30;
double UpBuffer[],UpBuffer2[],DownBuffer[],DownBuffer2[],StoMain[],StoSignal[],StoMA[];
int Positive=0, Negative=0;
//----
int init()
  {IndicatorBuffers(7);
   if(HistogramOn)     SetIndexStyle(0,2); else SetIndexStyle(0,12); SetIndexBuffer(0,UpBuffer);    SetIndexEmptyValue(0,EMPTY_VALUE);
   if(HistogramOn)     SetIndexStyle(1,2); else SetIndexStyle(1,12); SetIndexBuffer(1,UpBuffer2);   SetIndexEmptyValue(1,EMPTY_VALUE);
   if(HistogramOn)     SetIndexStyle(2,2); else SetIndexStyle(2,12); SetIndexBuffer(2,DownBuffer);  SetIndexEmptyValue(2,EMPTY_VALUE);
   if(HistogramOn)     SetIndexStyle(3,2); else SetIndexStyle(3,12); SetIndexBuffer(3,DownBuffer2); SetIndexEmptyValue(3,EMPTY_VALUE);
   if(PlotMainLine)    SetIndexStyle(4,0); else SetIndexStyle(4,12); SetIndexBuffer(4,StoMain);
   if(PlotSignalLine)  SetIndexStyle(5,0); else SetIndexStyle(5,12); SetIndexBuffer(5,StoSignal);
   if(PlotStoMA)       SetIndexStyle(6,0); else SetIndexStyle(6,12); SetIndexBuffer(6,StoMA);
   SetLevelValue(0,BuyAlertLevel); SetLevelValue(1,SellAlertLevel);
   return(0);}
//----
int deinit() {return(0);}
//----
int start()
{double prev,curr;
 int counted_bars=IndicatorCounted(),I,limit;
 IndicatorShortName("Stoch 4CHistoAlert["+KPeriod+","+DPeriod+","+SPeriod+"]["+StoMASignal+","+StoMAMode+"]");
 if (counted_bars<0) return(-1);
 if (counted_bars>0) counted_bars--;
 limit=Bars-31;
 if(counted_bars>=31) limit=Bars-counted_bars-1;
//----
   for (I=limit;I>=0;I--)
   {StoMain[I]=iStochastic(0,0,KPeriod,DPeriod,SPeriod,MAMode,MAPrice,MODE_MAIN,I)-50;
    StoSignal[I]=iStochastic(0,0,KPeriod,DPeriod,SPeriod,MAMode,MAPrice,MODE_SIGNAL,I)-50;
      if(StoMain[I]>BuyAlertLevel)
      {if (Positive==0)
       {Positive=1;Negative=0;
        if (I == 1 && AlertOn ) Alert(Symbol()," M",Period()," Stoch Histo BUY @ ",Ask);}}
      else if (StoMain[I]prev) up=true; if(curr0){UpBuffer[I]=curr;UpBuffer2[I]=0;DownBuffer[I]=0;DownBuffer2[I]=0;}
      else     {UpBuffer[I]=0;UpBuffer2[I]=curr;DownBuffer[I]=0;DownBuffer2[I]=0;}}
    else
    {if(curr<0){UpBuffer[I]=0;UpBuffer2[I]=0;DownBuffer[I]=curr;DownBuffer2[I]=0;}
      else     {UpBuffer[I]=0;UpBuffer2[I]=0;DownBuffer[I]=0;DownBuffer2[I]=curr;}}
    } 
 {if(ColorDescendingBars==true && FourColorBars==false)
    {if (StoMain[I]>StoMain[I+1])
      {UpBuffer[I]=StoMain[I];UpBuffer2[I]=0;DownBuffer[I]=0;DownBuffer2[I]=0;}
     else if(FourColorBars==false)
      {DownBuffer[I]=StoMain[I];DownBuffer2[I]=0;UpBuffer[I]=0;UpBuffer2[I]=0;}}
     else if(ColorDescendingBars==false && FourColorBars==false && StoMain[I]>=0.00)
      {UpBuffer[I]=StoMain[I];UpBuffer2[I]=0;DownBuffer[I]=0;DownBuffer2[I]=0;}
     else if(FourColorBars==false)
      {DownBuffer[I]=StoMain[I];DownBuffer2[I]=0;UpBuffer[I]=0;UpBuffer2[I]=0;}}
//----
}
  for(I=0;I        

Recommend