Indicators with alerts/signal - page 1584

 

This is not indicator (it is the EA), and this EA is sending push notifications on translation.

----------------

In Out Notification - expert for MetaTrader 5

Advisor "In Out Notification" sends a Push message if:

  • transaction type BUY or SELL
  • direction type DEAL_ENTRY_IN, DEAL_ENTRY_INOUT, DEAL_ENTRY_OUT or DEAL_ENTRY_OUT_BY

The message may look something like this (deal - exit the market)-

2020.01.08 10:47:07 | EURUSD | SELL | OUT | Volume 0.01 | Price 1.11344 | Profit -0.09

 
#property indicator_chart_window
#property indicator_buffers 8
#property indicator_color1 Lime
#property indicator_color2 Red
#property indicator_color3 LightSeaGreen
#property indicator_color4 LightSeaGreen
#property indicator_color5 Gold
#property indicator_color6 Gold
#property indicator_color7 Lime
#property indicator_color8 Red

//--------------------------------------------------------------------
extern int     AllBars=0;
extern int     Otstup=20; //--30
extern int  Per=9;
extern int Shift = 1;
extern bool Show_TriggerChannel = true;
extern bool Show_HiLoChannel = false;
extern bool Show_AllDots = true;
//--------------------------------------------------------------------

//---- constants
#define  SH_BUY   1
#define  SH_SELL  -1

//---- variables
int      SH,NB,i,UD, lastUD;
double   R,SHMax,SHMin;
double   BufD[], BufU[];
double   UpperBuf[], LowerBuf[];
double   Highs[], Lows[];
string   sWindows;
datetime thisTime, oldTime;
double   BufDall[], BufUall[];

//--------------------------------------------------------------------

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   int Ots = Get_DefaultOtstup();
   if(Ots > 0)
      Otstup = Ots;

   UD = 0;
   lastUD = 0;

   if(Bars<AllBars+Per || AllBars==0)
      NB=Bars-Per;
   else
      NB=AllBars;
   sWindows = "Damon smSilverTrend_v2";
   IndicatorShortName(sWindows);
   string st = "  (Per=" + DoubleToStr(Per,0);
   st = st + ",  Otstup=" + Otstup + ")";
   Comment(sWindows + st);

   SetIndexBuffer(0,BufU);
   SetIndexStyle(0,DRAW_ARROW,0,3);
   SetIndexArrow(0,159);
   SetIndexLabel(0,"SilverTrend LongSig");
   SetIndexBuffer(1,BufD);
   SetIndexStyle(1,DRAW_ARROW,0,3);
   SetIndexArrow(1,159);
   SetIndexLabel(1,"SilverTrend ShortSig");

   SetIndexDrawBegin(0,Bars-NB);
   SetIndexDrawBegin(1,Bars-NB);
   ArrayInitialize(BufD,0.0);
   ArrayInitialize(BufU,0.0);

   if(Show_TriggerChannel)
     {
      SetIndexBuffer(2,UpperBuf);
      SetIndexStyle(2,DRAW_LINE,STYLE_SOLID,1);
      SetIndexLabel(2,"TriggerChannel Short");
      SetIndexBuffer(3,LowerBuf);
      SetIndexStyle(3,DRAW_LINE,STYLE_SOLID,1);
      SetIndexLabel(3,"TriggerChannel Long");
     }
   else
     {
      SetIndexBuffer(2,UpperBuf);
      SetIndexStyle(2,DRAW_NONE);
      SetIndexLabel(2,NULL);
      SetIndexBuffer(3,LowerBuf);
      SetIndexStyle(3,DRAW_NONE);
      SetIndexLabel(3,NULL);
     }

   if(Show_HiLoChannel)
     {
      SetIndexBuffer(4,Highs);
      SetIndexStyle(4,DRAW_LINE,STYLE_SOLID,1);
      SetIndexLabel(4,"Channel Highs");
      SetIndexBuffer(5,Lows);
      SetIndexStyle(5,DRAW_LINE,STYLE_SOLID,1);
      SetIndexLabel(5,"Channel Lows");
     }
   else
     {
      SetIndexBuffer(4,Highs);
      SetIndexStyle(4,DRAW_NONE);
      SetIndexLabel(4,NULL);
      SetIndexBuffer(5,Lows);
      SetIndexStyle(5,DRAW_NONE);
      SetIndexLabel(5,NULL);
     }

   if(Show_AllDots)
     {
      SetIndexBuffer(6,BufUall);
      SetIndexStyle(6,DRAW_ARROW,0,0);
      SetIndexArrow(6,159);
      SetIndexLabel(6,"Possible Long");
      SetIndexBuffer(7,BufDall);
      SetIndexStyle(7,DRAW_ARROW,0,0);
      SetIndexArrow(7,159);
      SetIndexLabel(7,"Possible Short");
     }
   else
     {
      SetIndexBuffer(6,BufUall);
      SetIndexStyle(6,DRAW_NONE);
      SetIndexLabel(6,NULL);
      SetIndexBuffer(7,BufDall);
      SetIndexStyle(7,DRAW_NONE);
      SetIndexLabel(7,NULL);
     }

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

//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
   Comment("");
   return(0);
  }


//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int CB=IndicatorCounted();
   if(CB<0)
      return(-1);
   else
      if(NB>Bars-CB)
         NB=Bars-CB;


//-- start every minute, no repaint...
   thisTime = Time[0];
//if (thisTime == oldTime) return(0);
//oldTime = thisTime;
//~~   if (NB < 3) NB = 3;
//-- Draw channels
   for(SH=0; SH<NB; SH++)
     {
      SHMax = High[Highest(Symbol(),0,MODE_HIGH,Per,SH)];
      SHMin = Low[Lowest(Symbol(),0,MODE_LOW,Per,SH)];

      //-- HiLo channel
      Highs[SH] = SHMax;
      Lows[SH]  = SHMin;
      //-- trigger channel
      UpperBuf[SH] = SHMax-(SHMax-SHMin)*Otstup/100.0;
      LowerBuf[SH] = SHMin+(SHMax-SHMin)*Otstup/100.0;
     }

// 4.
//-- start every minute, no repaint...
   thisTime = Time[0];
   if(thisTime == oldTime)
      return(0);
   oldTime = thisTime;
   if(NB < 3)
      NB = 3;

   for(SH=1; SH<NB; SH++)
     {
      for(R=0,i=SH; i<SH+10; i++)
        {
         R+=(10+SH-i)*(High[i]-Low[i]);
        }
      R/=55; // BarRange
      double offset = R*0.3;

      SHMax = High[Highest(Symbol(),0,MODE_HIGH,Per,SH)];
      SHMin = Low[Lowest(Symbol(),0,MODE_LOW,Per,SH)];

      //-- Long signal
      if(Close[SH]<=SHMin+(SHMax-SHMin)*Otstup/100.0)
        {
         BufUall[SH]=Low[SH]-offset;
         if(UD!=SH_SELL)
           {
            BufU[SH]=Low[SH]-offset;
            BufD[SH]=EMPTY_VALUE;
            UD=SH_SELL;
            if(SH==1)
              {
               if(lastUD == SH_BUY || lastUD == 0)
                 {
                  lastUD = SH_SELL;
                 }
              }
           }
         else
           {
            BufU[SH]=EMPTY_VALUE;
           }
        }

      //-- short signal
      if(Close[SH]>=SHMax-(SHMax-SHMin)*Otstup/100.0)
        {
         BufDall[SH]=High[SH]+offset;
         if(UD!=SH_BUY)
           {
            BufU[SH]=EMPTY_VALUE;
            BufD[SH]=High[SH]+offset;
            UD=SH_BUY;
            if(SH==1)
              {
               if(lastUD == SH_SELL || lastUD == 0)
                 {
                  lastUD = SH_BUY;
                 }
              }
           }
         else
           {
            BufD[SH]=EMPTY_VALUE;
           }
        }

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

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int Get_DefaultOtstup()
  {
   if(Symbol() == "AUDUSD")
      return(15);
   if(Symbol() == "EURUSD")
      return(15);
   if(Symbol() == "GBPUSD")
      return(20);
   if(Symbol() == "USDCAD")
      return(10);
   if(Symbol() == "USDCHF")
      return(15);
   if(Symbol() == "USDJPY")
      return(15);
   if(Symbol() == "GBPJPY")
      return(15);
   if(Symbol() == "GBPCHF")
      return(20);
   if(Symbol() == "EURGBP")
      return(15);
   if(Symbol() == "NZDUSD")
      return(10);
   if(Symbol() == "EURJPY")
      return(15);
   if(Symbol() == "EURCHF")
      return(20);
   if(Symbol() == "EURAUD")
      return(30);
   if(Symbol() == "EURCAD")
      return(20);
   return(-1);
  }
//+------------------------------------------------------------------+

Signals are disappearing, please fix the  BUG

 
William Snyder:

Lobito, added alerts to this version.

cci_woodie_alerts.mq4

I tried searching for this indicator by name to find my question but didn't see anything


Can anyone add an alert to this indicator that will fire an alert when the yellow trend histo bar closes?


Thanks in advance if anyone can make this change.

 

Can any one help an amatuer coder make the arrow appear 45s before all conditions are met? Or maybe help me drop the lines of code.

Thanks in advance 

PS: THIS IS NOT MY CODE


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

//|                                             Indicator Arrows.mq5 |

//|                        Copyright 2015, MetaQuotes Software Corp. |

//|                                             https://www.mql5.com |

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

#property copyright "Copyright 2015, MetaQuotes Software Corp."

#property link      "https://www.mql5.com"

#property version   "1.00"

#property description "Indicator Arrows by pipPod"

#property indicator_chart_window

#property indicator_buffers 2

#property indicator_plots   2

//--- plot Arrows

#property indicator_label1  "BuyArrow"

#property indicator_type1   DRAW_ARROW

#property indicator_color1  clrLimeGreen

#property indicator_width1  1

#property indicator_label2  "SellArrow"

#property indicator_type2   DRAW_ARROW

#property indicator_color2  clrFireBrick

#property indicator_width2  1

//---

enum indicators

  {

   INDICATOR_MA,           //Moving Average

   INDICATOR_MACD,         //Moving Average Convergence/Divergence

   INDICATOR_OSMA,         //Oscillator of Moving Averages

   INDICATOR_STOCHASTIC,   //Stochastic Oscillator

   INDICATOR_RSI,          //Relative Strength Index

   INDICATOR_CCI,          //Commodity Channel Index

   INDICATOR_RVI,          //Relative Vigor Index

   INDICATOR_ADX,          //Average Directional Movement Index

   INDICATOR_TRIX,         //Triple Exponential Average

   INDICATOR_BANDS,        //Bollinger Bands

   INDICATOR_NONE          //No Indicator

  };

//---

input indicators Indicator1=INDICATOR_MACD;

input ENUM_TIMEFRAMES TimeFrame1=0;

input indicators Indicator2=INDICATOR_MA;

input ENUM_TIMEFRAMES TimeFrame2=0;

//---Range

input string Range;

input int RangePeriod=14;

//---Moving Average

input string MovingAverage;

input int MAPeriod=5;

input ENUM_MA_METHOD MAMethod=MODE_EMA;

input ENUM_APPLIED_PRICE MAPrice=PRICE_CLOSE;

//---MACD

input string MACD;

input int FastMACD=12;

input int SlowMACD=26;

input int SignalMACD=9;

input ENUM_APPLIED_PRICE MACDPrice=PRICE_CLOSE;

//---OsMA

input string OsMA;

input int FastOsMA=12;

input int SlowOsMA=26;

input int SignalOsMA=9;

input ENUM_APPLIED_PRICE OsMAPrice=PRICE_CLOSE;

input int OsMASignal=9;

//---Stoch

input string Stochastic;

input int Kperiod=8;

input int Dperiod=3;

input int Slowing=3;

input ENUM_MA_METHOD StochMAMethod=MODE_SMA;

input ENUM_STO_PRICE PriceField=STO_LOWHIGH;

//---RSI

input string RSI;

input int RSIPeriod=8;

input int RSISignal=5;

input ENUM_APPLIED_PRICE RSIPrice=PRICE_CLOSE;

//---CCI

input string CCI;

input int CCIPeriod=14;

input ENUM_APPLIED_PRICE CCIPrice=PRICE_CLOSE;

//---RVI

input string RVI;

input int RVIPeriod=10;

//---ADX

input string ADX;

input int ADXPeriod=14;

input ENUM_APPLIED_PRICE ADXPrice=PRICE_CLOSE;

//---TriX

input string TriX;

input int TriXPeriod=14;

input int TrixSignal=9;

input ENUM_APPLIED_PRICE TriXPrice=PRICE_CLOSE;

//---Bands

input string Bands;

input int BBPeriod=20;  //Bands Period

input double BBDev=2.0; //Bands Deviation

input ENUM_APPLIED_PRICE BBPrice=PRICE_CLOSE;   //Bands Price

input string _;//---

//---Alerts

input bool  AlertsOn      = true,

            AlertsMessage = true,

            AlertsEmail   = true,

            AlertsSound   = true;

//---

int indicator1,

    indicator2;

//---

double Buy[];

double Sell[];

//---

long chartID = ChartID();

#define LabelBox "LabelBox"

#define Label1 "Label1"

#define Label2 "Label2"

#define Label3 "Label3"

#define Label4 "Label4"

string label1 = "Spread ",

       label2 = "Range";

//---

int doubleToPip;

double pipToDouble;

//---

int rangeHandle,

    indHandle1,

    indHandle2;

//---

MqlTick tick;

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

//| Custom indicator initialization function                         |

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

int OnInit()

  {

   IndicatorSetString(INDICATOR_SHORTNAME,"Indicator Arrows");

//--- set points & digits

   IndicatorSetInteger(INDICATOR_DIGITS,_Digits);   

   if(_Digits==2 || _Digits==3)  

      doubleToPip = 100;

   else                          

      doubleToPip = 10000;

   

   if(_Digits==2 || _Digits==4) 

      pipToDouble = _Point;

   else                       

      pipToDouble = _Point*10;

//---create label rectangle and labels

   string label3,

          label4;

   int xStart=7;

   int yStart=80;

   int yIncrement=14;

   int ySize=40;

   int ySizeInc=15;

   ObjectCreate(chartID,LabelBox,OBJ_RECTANGLE_LABEL,0,0,0);

   ObjectSetInteger(chartID,LabelBox,OBJPROP_XDISTANCE,3);

   ObjectSetInteger(chartID,LabelBox,OBJPROP_YDISTANCE,75);

   ObjectSetInteger(chartID,LabelBox,OBJPROP_XSIZE,135);

   ObjectSetInteger(chartID,LabelBox,OBJPROP_YSIZE,ySize);

   ObjectSetInteger(chartID,LabelBox,OBJPROP_BGCOLOR,clrBlack);

   ObjectSetInteger(chartID,LabelBox,OBJPROP_BORDER_TYPE,BORDER_FLAT);


   ObjectCreate(chartID,Label1,OBJ_LABEL,0,0,0);

   ObjectSetInteger(chartID,Label1,OBJPROP_XDISTANCE,xStart);

   ObjectSetInteger(chartID,Label1,OBJPROP_YDISTANCE,yStart);

   ObjectSetString(chartID,Label1,OBJPROP_FONT,"Arial Bold");

   ObjectSetInteger(chartID,Label1,OBJPROP_FONTSIZE,10);

   ObjectSetInteger(chartID,Label1,OBJPROP_COLOR,clrFireBrick);

   

   ObjectCreate(chartID,Label2,OBJ_LABEL,0,0,0);

   ObjectSetInteger(chartID,Label2,OBJPROP_XDISTANCE,xStart);

   ObjectSetInteger(chartID,Label2,OBJPROP_YDISTANCE,yStart+=yIncrement);

   ObjectSetString(chartID,Label2,OBJPROP_FONT,"Arial Bold");

   ObjectSetInteger(chartID,Label2,OBJPROP_FONTSIZE,10);

   ObjectSetInteger(chartID,Label2,OBJPROP_COLOR,clrYellow);

//---

   string timeFrame1 = StringSubstr(EnumToString(TimeFrame1),7)+" ";

   string timeFrame2 = StringSubstr(EnumToString(TimeFrame2),7)+" ";

   if(timeFrame1=="CURRENT ")

      timeFrame1 = "";

   if(timeFrame2=="CURRENT ")

      timeFrame2 = "";

//---

   rangeHandle = iATR(NULL,0,RangePeriod);

   if(rangeHandle==INVALID_HANDLE)

      return(INIT_FAILED);

   indHandle1 = INVALID_HANDLE;

   indHandle2 = INVALID_HANDLE;

   if(Indicator1==INDICATOR_NONE)

      Alert("Indicator1 can't be 'No Indicator'");

   switch(Indicator1)

     {

      case INDICATOR_MA:

         label3 = StringFormat("iMA %s %s (%d)",timeFrame1,

                  StringSubstr(EnumToString(MAMethod),5),MAPeriod);

         indHandle1 = iMA(_Symbol,TimeFrame1,MAPeriod,0,MAMethod,MAPrice);

         break;

      case INDICATOR_MACD:

         label3 = StringFormat("iMACD %s (%d,%d,%d)",timeFrame1,

                  FastMACD,SlowMACD,SignalMACD);

         indHandle1 = iMACD(_Symbol,TimeFrame1,FastMACD,SlowMACD,SignalMACD,MACDPrice);

         break;

      case INDICATOR_OSMA:

         label3 = StringFormat("iOsMA %s (%d,%d,%d)",timeFrame1,

                  FastOsMA,SlowOsMA,SignalOsMA);

         indHandle1 = iOsMA(_Symbol,TimeFrame1,FastOsMA,SlowOsMA,SignalOsMA,OsMAPrice);

         break;

      case INDICATOR_STOCHASTIC:

         label3 = StringFormat("iStoch %s (%d,%d,%d) %s",timeFrame1,

                  Kperiod,Dperiod,Slowing,

                  StringSubstr(EnumToString(StochMAMethod),5));

         indHandle1 = iStochastic(_Symbol,TimeFrame1,Kperiod,Dperiod,Slowing,StochMAMethod,PriceField);

         break;

      case INDICATOR_RSI:

         label3 = StringFormat("iRSI %s (%d,%d)",timeFrame1,

                  RSIPeriod,RSISignal);

         indHandle1 = iRSI(_Symbol,TimeFrame1,RSIPeriod,RSIPrice);

         break;

      case INDICATOR_CCI:

         label3 = StringFormat("iCCI %s (%d)",timeFrame1,

                  CCIPeriod);

         indHandle1 = iCCI(_Symbol,TimeFrame1,CCIPeriod,CCIPrice);

         break;

      case INDICATOR_RVI:

         label3 = StringFormat("iRVI %s (%d)",timeFrame1,

                  RVIPeriod);

         indHandle1 = iRVI(_Symbol,TimeFrame1,RVIPeriod);

         break;

      case INDICATOR_ADX:

         label3 = StringFormat("iADX %s (%d)",timeFrame1,

                  ADXPeriod);

         indHandle1 = iADX(_Symbol,TimeFrame1,ADXPeriod);

         break;

      case INDICATOR_TRIX:

         label3 = StringFormat("iTriX %s (%d)",timeFrame1,

                  TriXPeriod);

         indHandle1 = iTriX(_Symbol,TimeFrame1,TriXPeriod,TriXPrice);

         break;

      case INDICATOR_BANDS:

         label3 = StringFormat("iBands %s (%d,%2.1f)",timeFrame1,

                  BBPeriod,BBDev);

         indHandle1 = iBands(_Symbol,TimeFrame1,BBPeriod,0,BBDev,BBPrice);

     }

   if(indHandle1==INVALID_HANDLE)

      return(INIT_FAILED);

   ObjectSetInteger(chartID,LabelBox,OBJPROP_YSIZE,ySize+=ySizeInc);

   ObjectCreate(chartID,Label3, OBJ_LABEL,0,0,0);

   ObjectSetInteger(chartID,Label3,OBJPROP_CORNER,0);

   ObjectSetInteger(chartID,Label3,OBJPROP_XDISTANCE,xStart);

   ObjectSetInteger(chartID,Label3,OBJPROP_YDISTANCE,yStart+=yIncrement);

   ObjectSetString(chartID,Label3,OBJPROP_TEXT,label3);

   ObjectSetString(chartID,Label3,OBJPROP_FONT,"Arial Bold");

   ObjectSetInteger(chartID,Label3,OBJPROP_FONTSIZE,10);

   ObjectSetInteger(chartID,Label3,OBJPROP_COLOR,clrLimeGreen);

//---

   if(Indicator2!=INDICATOR_NONE)

     {

      switch(Indicator2)

        {

         case INDICATOR_MA:

            label4 = StringFormat("iMA %s %s (%d)",timeFrame2,

                     StringSubstr(EnumToString(MAMethod),5),MAPeriod);

            indHandle2 = iMA(_Symbol,TimeFrame2,MAPeriod,0,MAMethod,MAPrice);

            break;

         case INDICATOR_MACD:

            label4 = StringFormat("iMACD %s (%d,%d,%d)",timeFrame2,

                     FastMACD,SlowMACD,SignalMACD);

            indHandle2 = iMACD(_Symbol,TimeFrame2,FastMACD,SlowMACD,SignalMACD,MACDPrice);

            break;

         case INDICATOR_OSMA:

            label4 = StringFormat("iOsMA %s (%d,%d,%d)",timeFrame2,

                     FastOsMA,SlowOsMA,SignalOsMA);

            indHandle2 = iOsMA(_Symbol,TimeFrame2,FastOsMA,SlowOsMA,SignalOsMA,OsMAPrice);

            break;

         case INDICATOR_STOCHASTIC:

            label4 = StringFormat("iStoch %s (%d,%d,%d) %s",timeFrame2,

                     Kperiod,Dperiod,Slowing,

                     StringSubstr(EnumToString(StochMAMethod),5));

            indHandle2 = iStochastic(_Symbol,TimeFrame2,Kperiod,Dperiod,Slowing,StochMAMethod,PriceField);

            break;

         case INDICATOR_RSI:

            label4 = StringFormat("iRSI %s (%d,%d)",timeFrame2,

                     RSIPeriod,RSISignal);

            indHandle2 = iRSI(_Symbol,TimeFrame2,RSIPeriod,RSIPrice);

            break;

         case INDICATOR_CCI:

            label4 = StringFormat("iCCI %s (%d)",timeFrame2,

                     CCIPeriod);

            indHandle2 = iCCI(_Symbol,TimeFrame2,CCIPeriod,CCIPrice);

            break;

         case INDICATOR_RVI:

            label4 = StringFormat("iRVI %s (%d)",timeFrame2,

                     RVIPeriod);

            indHandle2 = iRVI(_Symbol,TimeFrame2,RVIPeriod);

            break;

         case INDICATOR_ADX:

            label4 = StringFormat("iADX %s (%d)",timeFrame2,

                     ADXPeriod);

            indHandle2 = iADX(_Symbol,TimeFrame2,ADXPeriod);

            break;

         case INDICATOR_TRIX:

            label4 = StringFormat("iTriX %s (%d)",timeFrame2,

                     TriXPeriod);

            indHandle2 = iTriX(_Symbol,TimeFrame2,TriXPeriod,TriXPrice);

            break;

         case INDICATOR_BANDS:

            label4 = StringFormat("iBands %s (%d,%2.1f)",timeFrame2,

                     BBPeriod,BBDev);

            indHandle2 = iBands(_Symbol,TimeFrame2,BBPeriod,0,BBDev,BBPrice);

        }      

      if(indHandle2==INVALID_HANDLE)

         return(INIT_FAILED);

      ObjectSetInteger(chartID,LabelBox,OBJPROP_YSIZE,ySize+=ySizeInc);

      ObjectCreate(chartID,Label4,OBJ_LABEL,0,0,0);

      ObjectSetInteger(chartID,Label4,OBJPROP_CORNER, 0);

      ObjectSetInteger(chartID,Label4,OBJPROP_XDISTANCE,xStart);

      ObjectSetInteger(chartID,Label4,OBJPROP_YDISTANCE,yStart+=yIncrement);

      ObjectSetString(chartID,Label4,OBJPROP_TEXT,label4);

      ObjectSetString(chartID,Label4,OBJPROP_FONT,"Arial Bold");

      ObjectSetInteger(chartID,Label4,OBJPROP_FONTSIZE,10);

      ObjectSetInteger(chartID,Label4,OBJPROP_COLOR,clrLimeGreen);

     }

//--- indicator buffers mapping

   SetIndexBuffer(0,Buy,INDICATOR_DATA);

   ArraySetAsSeries(Buy,true);

   PlotIndexSetString(0,PLOT_LABEL,"BuyArrow");   

   PlotIndexSetInteger(0,PLOT_ARROW,233);

   PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0);

   SetIndexBuffer(1,Sell,INDICATOR_DATA);

   ArraySetAsSeries(Sell,true);

   PlotIndexSetString(1,PLOT_LABEL,"SellArrow");   

   PlotIndexSetInteger(1,PLOT_ARROW,234);

   PlotIndexSetDouble(1,PLOT_EMPTY_VALUE,0);

//---

   return(INIT_SUCCEEDED);

  }

//---

enum ENUM_SIGNAL

  {

   SIGNAL_NONE,

   SIGNAL_BUY,

   SIGNAL_SELL

  };

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

//| 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[])

  {

//---

   if(rates_total<100)  

      return(0);

//---

   ArraySetAsSeries(time,true);

   ArraySetAsSeries(high,true);

   ArraySetAsSeries(low,true);

//---

   if(SymbolInfoTick(_Symbol,tick))

      ObjectSetString(chartID,Label1,OBJPROP_TEXT,label1 + 

                      DoubleToString((tick.ask-tick.bid)*doubleToPip,1));

   static datetime prevTime;

   if(prev_calculated>0 && time[0]!=prevTime)

     {

      prevTime = time[0];

      ObjectSetString(chartID,Label2,OBJPROP_TEXT,label2 + 

                      StringFormat("(%d) %4.1f",RangePeriod,Range(0)*doubleToPip));

     }

   int i,limit;

//---

   limit = rates_total - prev_calculated;

   if(prev_calculated==0)

     { 

      limit = (int)ChartGetInteger(chartID,CHART_VISIBLE_BARS)+100;

      PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,rates_total-limit);

      PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,rates_total-limit);

     }

//---

   for(i=limit;i>=0 && !IsStopped();i--)

     {

      static datetime Time[1];

      if(CopyTime(_Symbol,TimeFrame1,time[i],1,Time)!=1)

         return(0);

      const datetime time1 = Time[0];

      switch(Indicator1)

        {

         case INDICATOR_MA:

           { 

            static double MoAv[1];

            static double High[1];

            static double Low[1];

            static double Close[1];

            if(CopyBuffer(indHandle1,0,time1,1,MoAv)!=1)

               return(0);

            if(CopyHigh(_Symbol,TimeFrame1,time1,1,High)!=1)

               return(0);

            if(CopyLow(_Symbol,TimeFrame1,time1,1,Low)!=1)

               return(0);

            if(CopyClose(_Symbol,TimeFrame1,time1,1,Close)!=1)

               return(0);

            indicator1 = iMA(MoAv,High,Low,Close);

            break;

           }

         case INDICATOR_MACD:

           { 

            static double Macd[2];

            static double Sign[2];

            if(CopyBuffer(indHandle1,0,time1,2,Macd)!=2)

               return(0);

            if(CopyBuffer(indHandle1,1,time1,2,Sign)!=2)

               return(0);

            indicator1 = iMACD(Macd,Sign);

            break;

           }

         case INDICATOR_OSMA:

           { 

            static double OsMa[];

            if(ArraySize(OsMa)!=OsMASignal+1)

               ArrayResize(OsMa,OsMASignal+1);

            if(CopyBuffer(indHandle1,0,time1,OsMASignal+1,OsMa)!=OsMASignal+1)

               return(0);

            indicator1 = iOsMA(OsMa);

            break;

           }

         case INDICATOR_STOCHASTIC:

           { 

            static double Stoc[2];

            static double Sign[2];

            if(CopyBuffer(indHandle1,0,time1,2,Stoc)!=2)

               return(0);

            if(CopyBuffer(indHandle1,1,time1,2,Sign)!=2)

               return(0);

            indicator1 = iStochastic(Stoc,Sign);

            break;

           }

         case INDICATOR_RSI:

           { 

            static double Rsi[];

            if(ArraySize(Rsi)!=RSISignal+1)

               ArrayResize(Rsi,RSISignal+1);

            if(CopyBuffer(indHandle1,0,time1,RSISignal+1,Rsi)!=RSISignal+1)

               return(0);

            indicator1 = iRSI(Rsi);

            break;

           }

         case INDICATOR_CCI:

           { 

            static double Cci[2];

            if(CopyBuffer(indHandle1,0,time1,2,Cci)!=2)

               return(0);

            indicator1 = iCCI(Cci);

            break;

           }

         case INDICATOR_RVI:

           { 

            static double Rvi[2];

            static double Sig[2];

            if(CopyBuffer(indHandle1,0,time1,2,Rvi)!=2)

               return(0);

            if(CopyBuffer(indHandle1,1,time1,2,Sig)!=2)

               return(0);

            indicator1 = iRVI(Rvi,Sig);

            break;

           }

         case INDICATOR_ADX:

           { 

            static double Adx[1];

            static double Pdi[2];

            static double Mdi[2];

            if(CopyBuffer(indHandle1,0,time1,1,Adx)!=1)

               return(0);

            if(CopyBuffer(indHandle1,1,time1,2,Pdi)!=2)

               return(0);

            if(CopyBuffer(indHandle1,2,time1,2,Mdi)!=2)

               return(0);

            indicator1 = iADX(Adx,Pdi,Mdi);

            break;

           }

         case INDICATOR_TRIX:

           { 

            static double Trix[];

            if(ArraySize(Trix)!=TrixSignal+1)

               ArrayResize(Trix,TrixSignal+1);

            if(CopyBuffer(indHandle1,0,time1,TrixSignal+1,Trix)!=TrixSignal+1)

               return(0);

            indicator1 = iTriX(Trix);

            break;

           }

         case INDICATOR_BANDS:

           { 

            static double Middle[1];

            static double Upper[1];

            static double Lower[1];

            static double High[1];

            static double Low[1];

            static double Close[1];

            if(CopyBuffer(indHandle1,0,time1,1,Middle)!=1)

               return(0);

            if(CopyBuffer(indHandle1,1,time1,1,Upper)!=1)

               return(0);

            if(CopyBuffer(indHandle1,2,time1,1,Lower)!=1)

               return(0);

            if(CopyHigh(_Symbol,TimeFrame1,time1,1,High)!=1)

               return(0);

            if(CopyLow(_Symbol,TimeFrame1,time1,1,Low)!=1)

               return(0);

            if(CopyClose(_Symbol,TimeFrame1,time1,1,Close)!=1)

               return(0);

            indicator1 = iBands(Middle,Upper,Lower,High,Low,Close);

            break;

           }

        }


      if(Indicator2!=INDICATOR_NONE)

        {

         if(CopyTime(_Symbol,TimeFrame2,time[i],1,Time)!=1)

            return(0);

         const datetime time2 = Time[0];

         switch(Indicator2)

           {

            case INDICATOR_MA:

              { 

               static double MoAv[1];

               static double High[1];

               static double Low[1];

               static double Close[1];

               if(CopyBuffer(indHandle2,0,time2,1,MoAv)!=1)

                  return(0);

               if(CopyHigh(_Symbol,TimeFrame2,time2,1,High)!=1)

                  return(0);

               if(CopyLow(_Symbol,TimeFrame2,time2,1,Low)!=1)

                  return(0);

               if(CopyClose(_Symbol,TimeFrame2,time2,1,Close)!=1)

                  return(0);

               indicator2 = iMA(MoAv,High,Low,Close);

               break;

              }

            case INDICATOR_MACD:

              { 

               static double Macd[2];

               static double Sign[2];

               if(CopyBuffer(indHandle2,0,time2,2,Macd)!=2)

                  return(0);

               if(CopyBuffer(indHandle2,1,time2,2,Sign)!=2)

                  return(0);

               indicator2 = iMACD(Macd,Sign);

               break;

              }

            case INDICATOR_OSMA:

              { 

               static double OsMa[];

               if(ArraySize(OsMa)!=OsMASignal+1)

                  ArrayResize(OsMa,OsMASignal+1);

               if(CopyBuffer(indHandle2,0,time2,OsMASignal+1,OsMa)!=OsMASignal+1)

                  return(0);

               indicator2 = iOsMA(OsMa);

               break;

              }

            case INDICATOR_STOCHASTIC:

              { 

               static double Stoc[2];

               static double Sign[2];

               if(CopyBuffer(indHandle2,0,time2,2,Stoc)!=2)

                  return(0);

               if(CopyBuffer(indHandle2,1,time2,2,Sign)!=2)

                  return(0);

               indicator2 = iStochastic(Stoc,Sign);

               break;

              }

            case INDICATOR_RSI:

              { 

               static double Rsi[];

               if(ArraySize(Rsi)!=RSISignal+1)

                  ArrayResize(Rsi,RSISignal+1);

               if(CopyBuffer(indHandle2,0,time2,RSISignal+1,Rsi)!=RSISignal+1)

                  return(0);

               indicator2 = iRSI(Rsi);

               break;

              }

            case INDICATOR_CCI:

              { 

               static double Cci[2];

               if(CopyBuffer(indHandle2,0,time2,2,Cci)!=2)

                  return(0);

               indicator2 = iCCI(Cci);

               break;

              }

            case INDICATOR_RVI:

              { 

               static double Rvi[2];

               static double Sig[2];

               if(CopyBuffer(indHandle2,0,time2,2,Rvi)!=2)

                  return(0);

               if(CopyBuffer(indHandle2,1,time2,2,Sig)!=2)

                  return(0);

               indicator2 = iRVI(Rvi,Sig);

               break;

              }

            case INDICATOR_ADX:

              { 

               static double Adx[1];

               static double Pdi[2];

               static double Mdi[2];

               if(CopyBuffer(indHandle2,0,time2,1,Adx)!=1)

                  return(0);

               if(CopyBuffer(indHandle2,1,time2,2,Pdi)!=2)

                  return(0);

               if(CopyBuffer(indHandle2,2,time2,2,Mdi)!=2)

                  return(0);

               indicator2 = iADX(Adx,Pdi,Mdi);

               break;

              }

            case INDICATOR_TRIX:

              { 

               static double Trix[];

               if(ArraySize(Trix)!=TrixSignal+1)

                  ArrayResize(Trix,TrixSignal+1);

               if(CopyBuffer(indHandle2,0,time2,TrixSignal+1,Trix)!=TrixSignal+1)

                  return(0);

               indicator2 = iTriX(Trix);

               break;

              }

            case INDICATOR_BANDS:

              { 

               static double Middle[1];

               static double Upper[1];

               static double Lower[1];

               static double High[1];

               static double Low[1];

               static double Close[1];

               if(CopyBuffer(indHandle2,0,time2,1,Middle)!=1)

                  return(0);

               if(CopyBuffer(indHandle2,1,time2,1,Upper)!=1)

                  return(0);

               if(CopyBuffer(indHandle2,2,time2,1,Lower)!=1)

                  return(0);

               if(CopyHigh(_Symbol,TimeFrame2,time2,1,High)!=1)

                  return(0);

               if(CopyLow(_Symbol,TimeFrame2,time2,1,Low)!=1)

                  return(0);

               if(CopyClose(_Symbol,TimeFrame2,time2,1,Close)!=1)

                  return(0);

               indicator2 = iBands(Middle,Upper,Lower,High,Low,Close);

               break;

              }

           }

        }


      if(Indicator2==INDICATOR_NONE)

        {

         if(indicator1==SIGNAL_BUY)

           {

            Buy[i] = low[i] - Range(i);

            if(AlertsOn && prev_calculated>0) 

               AlertsHandle(time[0],SIGNAL_BUY);

            Sell[i] = 0;

           }

         else if(indicator1==SIGNAL_SELL)   

           {

            Sell[i] = high[i] + Range(i);

            if(AlertsOn && prev_calculated>0) 

               AlertsHandle(time[0],SIGNAL_SELL);

            Buy[i] = 0;

           }

         else

           {

            Buy[i] = 0;

            Sell[i]= 0;

           } 

        }

      else

        {

         if(indicator1==SIGNAL_BUY && indicator2==SIGNAL_BUY)

           {

            Buy[i] = low[i] - Range(i);

            if(AlertsOn && prev_calculated>0) 

               AlertsHandle(time[0],SIGNAL_BUY);

            Sell[i] = 0;

           }

         else if(indicator1==SIGNAL_SELL && indicator2==SIGNAL_SELL)   

           {

            Sell[i] = high[i] + Range(i);

            if(AlertsOn && prev_calculated>0) 

               AlertsHandle(time[0],SIGNAL_SELL);

            Buy[i] = 0;

           }

         else

           {

            Buy[i] = 0;

            Sell[i]= 0;

           } 

        }

     }

//--- return value of prev_calculated for next call

   return(rates_total);

  }

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

//| Custom indicator initialization function                         |

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

void OnDeinit(const int reason)

  {

//---check & delete labels

   if(ObjectFind(0,LabelBox)!=-1)

      ObjectDelete(0,LabelBox);

   if(ObjectFind(0,Label1)!=-1)

      ObjectDelete(0,Label1);

   if(ObjectFind(0,Label2)!=-1)

      ObjectDelete(0,Label2);

   if(ObjectFind(0,Label3)!=-1)

      ObjectDelete(0,Label3);

   if(ObjectFind(0,Label4)!=-1)

      ObjectDelete(0,Label4);

   IndicatorRelease(rangeHandle);

   IndicatorRelease(indHandle1);

   IndicatorRelease(indHandle2);

   return;

  }

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

//|  Average Range                                                   |

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

double Range(int idx)

  {

   static double range[1];

   if(CopyBuffer(rangeHandle,0,idx+1,1,range)!=1)

      return(0.0);

   double avgRange = range[0];

   return(avgRange);

  }

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

//|  Moving Average                                                  |

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

int iMA(const double &moav[],

        const double &high[],

        const double &low[],

        const double &close[])

  { 

   int signal=SIGNAL_NONE;

   if(close[0]>moav[0] && low[0]<moav[0])

      signal=SIGNAL_BUY;

   if(close[0]<moav[0] && high[0]>moav[0])

      signal=SIGNAL_SELL;

//---

   return(signal);

  }

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

//|  Moving Average Convergence/Divergence                           |

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

int iMACD(const double &macd[],

          const double &sign[])

  { 

   double currMacd = macd[1];

   double prevMacd = macd[0];

   double currSign = sign[1];

   double prevSign = sign[0];

//---

   int signal=SIGNAL_NONE;

   if(currMacd>currSign && prevMacd<prevSign)

      signal=SIGNAL_BUY;

   if(currMacd<currSign && prevMacd>prevSign)

      signal=SIGNAL_SELL;

//---

   return(signal);

  }

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

//|  Oscillator of Moving Averages                                   |

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

int iOsMA(const double &osma[])

  { 

   ArraySetAsSeries(osma,true);

   double sum1 = 0.0;

   double sum2 = 0.0;

   for(int i=0,j=1;i<OsMASignal;i++,j++)

     { 

      sum1 += osma[i];

      sum2 += osma[j];

     }

   double currOsma = osma[0];

   double prevOsma = osma[1];

   double currSign = sum1 / OsMASignal;

   double prevSign = sum2 / OsMASignal;

//---

   int signal=SIGNAL_NONE;

   if(currOsma>currSign && prevOsma<prevSign)

      signal=SIGNAL_BUY;

   if(currOsma<currSign && prevOsma>prevSign)

      signal=SIGNAL_SELL;

//---

   return(signal);

  }

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

//|  Stochastic Oscillator                                           |

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

int iStochastic(const double &stoc[],

                const double &sign[])

  { 

   double currStoc = stoc[1];

   double prevStoc = stoc[0];

   double currSign = sign[1];

   double prevSign = sign[0];

//---

   int signal=SIGNAL_NONE;

   if(currStoc>currSign && prevStoc<prevSign)

      signal=SIGNAL_BUY;

   if(currStoc<currSign && prevStoc>prevSign)

      signal=SIGNAL_SELL;

//---

   return(signal);

  }            

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

//|  Relative Strength Index                                         |

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

int iRSI(const double &rsi[])

  { 

   ArraySetAsSeries(rsi,true);

   double sum1 = 0.0;

   double sum2 = 0.0;

   for(int i=0,j=1;i<RSISignal;i++,j++)

     { 

      sum1 += rsi[i];

      sum2 += rsi[j];

     }

   double currRsi = rsi[0];

   double prevRsi = rsi[1];

   double currSig = sum1 / RSISignal;

   double prevSig = sum2 / RSISignal;

//---

   int signal=SIGNAL_NONE;

   if(currRsi>currSig && prevRsi<prevSig)

      signal=SIGNAL_BUY;

   if(currRsi<currSig && prevRsi>prevSig)

      signal=SIGNAL_SELL;

//---

   return(signal);

  }            

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

//|  Commodity Channel Index                                         |

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

int iCCI(const double &cci[])

  { 

   double currCci = cci[1];

   double prevCci = cci[0];

   double level[3] = {-100,0,100};

//---

   int signal=SIGNAL_NONE;

   for(int i=0;i<3;i++)

     {

      if(currCci>level[i] && prevCci<=level[i])

        {

         signal=SIGNAL_BUY;

         break;

        } 

      if(currCci<level[i] && prevCci>=level[i])

        {

         signal=SIGNAL_SELL;

         break;

        } 

     } 

//---

   return(signal);

  }            

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

//|  Relative Vigor Index                                            |

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

int iRVI(const double &rvi[],

         const double &sig[])

  { 

   double currRvi = rvi[1];

   double prevRvi = rvi[0];

   double currSig = sig[1];

   double prevSig = sig[0];

//---

   int signal=SIGNAL_NONE;

   if(currRvi>currSig && prevRvi<prevSig)

      signal=SIGNAL_BUY;

   if(currRvi<currSig && prevRvi>prevSig)

      signal=SIGNAL_SELL;

//---

   return(signal);

  }            

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

//|  Average Directional Movement Index                              |

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

int iADX(const double &Adx[],

         const double &pdi[],

         const double &mdi[])

  { 

   bool adx = Adx[0] < 25;

   double currPdi = pdi[1];

   double prevPdi = pdi[0];

   double currMdi = mdi[1];

   double prevMdi = mdi[0];

//---

   int signal=SIGNAL_NONE;

   if(adx && currPdi>currMdi && prevPdi<prevMdi)

      signal=SIGNAL_BUY;

   if(adx && currPdi<currMdi && prevPdi>prevMdi)

      signal=SIGNAL_SELL;

//---

   return(signal);

  }            

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

//|  Triple Exponential Moving Averages                              |

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

int iTriX(const double &trix[])

  { 

   ArraySetAsSeries(trix,true);

   double sum1 = 0.0;

   double sum2 = 0.0;

   for(int i=0,j=1;i<TrixSignal;i++,j++)

     { 

      sum1 += trix[i];

      sum2 += trix[j];

     }

   double currTrix = trix[0];

   double prevTrix = trix[1];

   double currSign = sum1 / TrixSignal;

   double prevSign = sum2 / TrixSignal;

//---

   int signal=SIGNAL_NONE;

   if(currTrix>currSign && prevTrix<prevSign)

      signal=SIGNAL_BUY;

   if(currTrix<currSign && prevTrix>prevSign)

      signal=SIGNAL_SELL;


//---

   return(signal);

  }               

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

//|  Bollinger Bands                                                 |

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

int iBands(const double &midle[],

           const double &upper[],

           const double &lower[],

           const double &high[],

           const double &low[],

           const double &close[])

  { 

   int signal=SIGNAL_NONE;

   if((low[0]<lower[0] && close[0]>lower[0]) ||

      (low[0]<midle[0] && close[0]>midle[0]))

      signal=SIGNAL_BUY;

   if((high[0]>upper[0] && close[0]<upper[0]) ||

      (high[0]>midle[0] && close[0]<midle[0]))

      signal=SIGNAL_SELL;

//---

   return(signal);

  }               

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

//|  Alerts Handle                                                   |

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

void AlertsHandle(const datetime &time,

                  const ENUM_SIGNAL alert_type)

  {

   static datetime timePrev;

   static ENUM_SIGNAL typePrev;

   string alertMessage;

   double price = 0.0;

   if(SymbolInfoTick(_Symbol,tick))

      price = tick.bid;

   

   if(timePrev!=time || typePrev!=alert_type)

     {

      timePrev = time;

      typePrev = alert_type;

      alertMessage = StringFormat("%s @ %s %s @ %s",_Symbol,TimeToString(TimeLocal(),TIME_MINUTES),

                                  StringSubstr(EnumToString(alert_type),7),DoubleToString(price,_Digits));

      if(AlertsMessage) 

         Alert(alertMessage);

      if(AlertsEmail) 

         SendMail(_Symbol+" Arrow Alert",alertMessage);

      if(AlertsSound) 

         PlaySound("alert2.wav");

     }

  }

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


 
Mladen Rakic:

TestPrice -> the price you want to compare to MA (0==close)

alertsOnCurrent -> if tru, alerts on still opened bar, if false, alerts on a first closed bar

alertsPushNotif -> if true it will send a push notification on alert

Hi 

whats is:

Input M Aval

Input M Atype

Input M Ashift

Input MAprice

I would like to set the alert so it triggers on a close above / below a 5 ema based on high and low 

Thanks in advance

 
<Decompiled code removed>
 
Cruz s:
<Decompiled code removed>

Post decompiled code again and you will be banned.

   int Gi_unused_128 = 0;
   bool Gi_132 = FALSE;
   bool Gi_136 = FALSE;
   bool Gi_140 = FALSE;
   double Ld_92;
   double Ld_100;
   double Ld_108;
   double Ld_116;
 

Does anyone here have a source code/mq4 file of this indicator? id like to fix some alert problems in it.

<ex4 file deleted>

 
Mladen Rakic:

DMNIK

This is a version with alerts added (the usual types : message, sound, email, push notification and a choice of a closed bar or a still opened bar). It will not work on older builds of metatrader 4

Hi Mladen;
Your post is 6 years old but the indidonchian_channel__atr_amp_alerts.mq4 ,still works fine. One thing however, the pop-up alert does not specify the time frame on which the alert was triggered. Can this be added or is there a code I can add myself (and where)?
While I am at it is there a way to set alerts in general so that they only pop-up "once per event"? And is there a way in general to delete each alert once it has been acted on, or at least marked as already acted upon, or alerts being turned off for a completed event? See attachment.
Thank you for any help you can offer.

https://www.mql5.com/en/charts/11752779/gbpchf-d1-axicorp-financial-services

https://www.mql5.com/en/charts/11752779/gbpchf-d1-axicorp-financial-services

Sorry, I can't seem to catch the knack of attaching an image. Hope youu can see what I talking about in any case.
Ian
 
fxmillionaire:

Programmers Needed

Here is the indicator renko_2.mq4. Please any programmer there kindly add alert sound when box color changes. tnx

Hi

It's my question also. Anybody can help us? we want alert sound for this indicator! change to blue color get sound alert and if change to red color again get sound alert and continues.

thank you in advance