Page 251 of 434

Re: MT4 Indicators with alerts/signals

Posted: Mon Oct 14, 2019 2:35 am
by mrtools
cc06 wrote: Sat Oct 12, 2019 2:10 pm Hi @mrtools,

Appreciate your as usual great help to add an email and push alert for attached indicator with Symbol, TF and buy/sell info after candle close.

Many Thanks !!!!
An alert on what?

Re: MT4 Indicators with alerts/signals

Posted: Mon Oct 14, 2019 2:41 am
by mrtools
^eagle^ wrote: Mon Oct 14, 2019 2:18 am I don't know if this is possible but I am looking to make the slow line wider. mt4 only goes up to a line width of 5. would it be possible to make a line wider in the code than mt4s maximum line width? I was also thinking of maybe having the line widen by standard deviation. I think that might be overkill though. The SD would have to have upper and lower bounds so the fast line would break free from the band. Im trying to understand the code. It looks as though it is using a mean of two fast and two slow EMAs to produce a trigger. Is that correct? The reasoning behind the thick line is to filter out false breakouts. I want to see if anything above a 5 width will help filter out the breakouts. Like the trigger line of TDFI. But maybe even make it form fitting to the ATR? I might be over thinking it with that.

Code: Select all

//------------------------------------------------------------------
#property link      "www.forex-station.com"
#property copyright "www.forex-station.com"
//------------------------------------------------------------------
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1  clrLimeGreen
#property indicator_color2  clrPaleVioletRed
#property indicator_width1  2
#property indicator_style2  STYLE_DOT
#property strict

//
//
//
//
//
extern ENUM_TIMEFRAMES   TimeFrame             = PERIOD_CURRENT;    // Time frame to use
input int                r                     = 2;                 // First ema period
input int                s                     = 10;                // Second ema period
input int                u                     = 5;                 // Third ema period
input int                trigger               = 3;                 // Signal ema period
input ENUM_APPLIED_PRICE Price                 = PRICE_CLOSE;       // Price to use
input bool               alertsOn              = true;              // Alerts on true/false?
input bool               alertsOnCurrent       = false;             // Alerts on open bar true/false?
input bool               alertsMessage         = true;              // Alerts popup message true/false?
input bool               alertsSound           = false;             // Alerts sound true/false?
input bool               alertsEmail           = false;             // Alerts email true/false?
input bool               alertsPushNotif       = false;             // Alerts notification true/false?
input bool               arrowsVisible         = false;             // Arrows visible true/false?
input bool               arrowsOnNewest        = false;             // Arrows drawn on newest bar of higher time frame bar true/false?
input string             arrowsIdentifier      = "erg Arrows1";     // Unique ID for arrows
input double             arrowsUpperGap        = 0.1;               // Upper arrow gap
input double             arrowsLowerGap        = 0.1;               // Lower arrow gap
input color              arrowsUpColor         = clrBlue;           // Up arrow color
input color              arrowsDnColor         = clrCrimson;        // Down arrow color
input int                arrowsUpCode          = 116;               // Up arrow code
input int                arrowsDnCode          = 116;               // Down arrow code
input int                arrowsUpSize          = 2;                 // Up arrow size
input int                arrowsDnSize          = 2;                 // Down arrow size
input bool               Interpolate           = true;              // Interpolate true/false?

double tsi[],sig[],trend[],count[];
string indicatorFileName;
#define _mtfCall(_buff,_ind) iCustom(NULL,TimeFrame,indicatorFileName,PERIOD_CURRENT,r,s,u,trigger,Price,alertsOn,alertsOnCurrent,alertsMessage,alertsSound,alertsEmail,alertsPushNotif,arrowsVisible,arrowsOnNewest,arrowsIdentifier,arrowsUpperGap,arrowsLowerGap,arrowsUpColor,arrowsDnColor,arrowsUpCode,arrowsDnCode,arrowsUpSize,arrowsDnSize,_buff,_ind)

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

int OnInit()
{
   IndicatorBuffers(4);
   SetIndexBuffer(0,tsi,INDICATOR_DATA); SetIndexStyle(0, DRAW_LINE);
   SetIndexBuffer(1,sig,INDICATOR_DATA); SetIndexStyle(1, DRAW_LINE);
   SetIndexBuffer(2,trend,INDICATOR_CALCULATIONS);
   SetIndexBuffer(3,count,INDICATOR_CALCULATIONS);
   
   indicatorFileName = WindowExpertName();
   TimeFrame         = fmax(TimeFrame,_Period);
   
   IndicatorShortName(timeFrameToString(TimeFrame)+" BH ergodic ("+ (string)r +","+ (string)s +","+ (string)u +") Trigger"+ (string)trigger +")");
return(INIT_SUCCEEDED);
}
void OnDeinit(const int reason)
{ 
    string lookFor       = arrowsIdentifier+":";
    int    lookForLength = StringLen(lookFor);
    for (int i=ObjectsTotal()-1; i>=0; i--)
    {
       string objectName = ObjectName(i);
       if (StringSubstr(objectName,0,lookForLength) == lookFor) ObjectDelete(objectName);
    }
}

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

   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[])
{
  
   int i,counted_bars = prev_calculated;
      if(counted_bars < 0) return(-1);
      if(counted_bars > 0) counted_bars--;
            int limit=fmin(rates_total-counted_bars,rates_total-2); count[0] = limit;
            if (TimeFrame!=_Period)
            {
               limit = (int)fmax(limit,fmin(rates_total-1,_mtfCall(3,0)*TimeFrame/Period()));
               for (i=limit; i>=0; i--)
               {
                  int y = iBarShift(NULL,TimeFrame,Time[i]);
                     tsi[i] = _mtfCall(0,y);
                     sig[i] = _mtfCall(1,y); 
                  
                     //
                     //
                     //
                     //
                     //
                  
                     if (!Interpolate || (i>0 && y==iBarShift(NULL,TimeFrame,Time[i-1]))) continue;
                      #define _interpolate(buff) buff[i+k] = buff[i]+(buff[i+n]-buff[i])*k/n
                      int n,k; datetime btime = iTime(NULL,TimeFrame,y);
                         for(n = 1; (i+n)<rates_total && Time[i+n] >= btime; n++) continue;	
                         for(k = 1; k<n && (i+n)<rates_total && (i+k)<rates_total; k++)
                         {
                           _interpolate(tsi);
                           _interpolate(sig);
                         }
              }          
   return(rates_total);
   } 
              
   //
   //
   //
   //
   //

   for(i=limit; i>= 0; i--)
   {
      double priceDiff=0;
      if (i<rates_total-1) priceDiff = iMA(NULL,0,1,0,MODE_EMA,Price,i)-iMA(NULL,0,1,0,MODE_EMA,Price,i+1);
      double avg = iEma(iEma(iEma(     priceDiff ,r,i,rates_total,0),s,i,rates_total,1),u,i,rates_total,2);
      double ava = iEma(iEma(iEma(fabs(priceDiff),r,i,rates_total,3),s,i,rates_total,4),u,i,rates_total,5);
      tsi[i] = (ava != 0) ? 100.0*avg/ava : 0;
      sig[i] = iEma(tsi[i],trigger,i,rates_total,6);
      trend[i] = (i<rates_total-1) ? (tsi[i]>sig[i]) ? 1 : (tsi[i]<sig[i]) ? -1 : trend[i+1] : 0; 
      
      //
      //
      //
      //
      //
      
      if (arrowsVisible)
      {
         string lookFor = arrowsIdentifier+":"+(string)Time[i]; ObjectDelete(lookFor);            
         if (i<(rates_total-1) && trend[i] != trend[i+1])
         {
            if (trend[i] == 1) drawArrow(i,arrowsUpColor,arrowsUpCode,arrowsUpSize,false);
            if (trend[i] ==-1) drawArrow(i,arrowsDnColor,arrowsDnCode,arrowsDnSize, true);
         }
      }  
   }
   
   //
   //
   //
   //
   //
      
   if (alertsOn)
   {
      int whichBar = 1; if (alertsOnCurrent) whichBar = 0;
      if (trend[whichBar] != trend[whichBar+1])
      if (trend[whichBar] == 1)
            doAlert("crossing signal up");
      else  doAlert("crossing signal down");       
   }  
return(rates_total);
}

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

double workEma[][7];
double iEma(double price, double period, int i, int bars, int instanceNo=0)
{
   if (ArrayRange(workEma,0)!= bars) ArrayResize(workEma,bars); i = bars-i-1;

   //
   //
   //
   //
   //
      
   double alpha = 2.0 / (1.0+period);
          workEma[i][instanceNo] = workEma[i-1][instanceNo]+alpha*(price-workEma[i-1][instanceNo]);
   return(workEma[i][instanceNo]);
}

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

string sTfTable[] = {"M1","M5","M15","M30","H1","H4","D1","W1","MN"};
int    iTfTable[] = {1,5,15,30,60,240,1440,10080,43200};

string timeFrameToString(int tf)
{
   for (int i=ArraySize(iTfTable)-1; i>=0; i--) 
         if (tf==iTfTable[i]) return(sTfTable[i]);
                              return("");
}

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

void doAlert(string doWhat)
{
   static string   previousAlert="nothing";
   static datetime previousTime;
   string message;
   
      if (previousAlert != doWhat || previousTime != Time[0]) {
          previousAlert  = doWhat;
          previousTime   = Time[0];

          //
          //
          //
          //
          //

          message = timeFrameToString(_Period)+" "+_Symbol+" at "+TimeToStr(TimeLocal(),TIME_SECONDS)+" BH - ergodic "+doWhat;
             if (alertsMessage)   Alert(message);
             if (alertsPushNotif) SendNotification(message);
             if (alertsEmail)     SendMail(_Symbol+" BH - ergodic ",message);
             if (alertsSound)     PlaySound("alert2.wav");
      }
}


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

void drawArrow(int i,color theColor,int theCode, int theSize, bool up)
{
   string name = arrowsIdentifier+":"+(string)Time[i];
   double gap  = iATR(NULL,0,20,i);   
   
      //
      //
      //
      //
      //

      datetime atime = Time[i]; if (arrowsOnNewest) atime += _Period*60-1;      
      ObjectCreate(name,OBJ_ARROW,0,atime,0);
         ObjectSet(name,OBJPROP_ARROWCODE,theCode);
         ObjectSet(name,OBJPROP_COLOR,theColor);
         ObjectSet(name,OBJPROP_WIDTH,theSize);
         if (up)
               ObjectSet(name,OBJPROP_PRICE1,High[i] + arrowsUpperGap * gap);
         else  ObjectSet(name,OBJPROP_PRICE1,Low[i]  - arrowsLowerGap * gap);
}

Not sure about standard deviation width control, but you can change

Code: Select all

#property indicator_style2  STYLE_DOT
to this

Code: Select all

#property indicator_width2   10
on that example changed the width to 10, but you can enter whatever number you want.

Re: MT4 Indicators with alerts/signals

Posted: Mon Oct 14, 2019 7:20 am
by Speters
Speters wrote: Thu Aug 01, 2019 5:34 am Hi
I’ve been looking for a “spike” Stochs indicator, but haven’t been able to locate anything similar.
As per the attached picture, indicator is based on 3 points (corresponding to bars on the price chart.
Point 2 on the stoch line needs to be at a value of 0, 50 or 100. Then both points 1 & 3 need to be either above 0 (or 50) for a BUY alert or below 100 (or 50) for a SELL alert.
Alert to be on the chart (and email/SMS).
Has anyone seen anything similar ?
Thanks Stan
Hi Coders - I previously posted this indy request, but unfortunately I didn't get any response.
Anyone able to code the indicator or is it an impossible ask ?
Thanks Stan

Re: MT4 Indicators with alerts/signals

Posted: Mon Oct 14, 2019 7:53 am
by pacois
Speters wrote: Mon Oct 14, 2019 7:20 am

Hi Coders - I previously posted this indy request, but unfortunately I didn't get any response.
Anyone able to code the indicator or is it an impossible ask ?
Thanks Stan
Hi, at least know the names of the indicators, what kind.

Re: MT4 Indicators with alerts/signals

Posted: Mon Oct 14, 2019 9:36 am
by cc06
mrtools wrote: Mon Oct 14, 2019 2:35 am

An alert on what?
When it move from low to high trigger buy and from high to low trigger sell. Thanks ! Thanks !

Re: MT4 Indicators with alerts/signals

Posted: Mon Oct 14, 2019 1:26 pm
by nickbyniel1541
mrtools wrote: Mon Oct 14, 2019 2:33 am

Have you seen this version? viewtopic.php?p=1295351863#p1295351863
Thanks mrtools looks pretty good for some top quality trading

Re: MT4 Indicators with alerts/signals

Posted: Tue Oct 15, 2019 6:02 am
by Speters
pacois wrote: Mon Oct 14, 2019 7:53 am

Hi, at least know the names of the indicators, what kind.
Hi Pacois
The indicator I use is the standard Stochastic, the default one in metatrader.
The settings I use are 4,4,2.

thanks Stan

Re: MT4 Indicators with alerts/signals

Posted: Tue Oct 15, 2019 8:43 am
by pacois
Speters wrote: Tue Oct 15, 2019 6:02 am

Hi Pacois
The indicator I use is the standard Stochastic, the default one in metatrader.
The settings I use are 4,4,2.

thanks Stan
Hi, do you use 2 Stochastic standards?(4-4-2 :?: )

Re: MT4 Indicators with alerts/signals

Posted: Tue Oct 15, 2019 11:47 pm
by bmwaddicted
mrtools wrote: Wed Oct 09, 2019 11:09 am

Added a more user friendly mtf.

How to use Momentum Scalper for MT4: Instructions.
Hi mrtools,

Is it possible to have an alert when the zone goes from red/green and green/red? Found this very good especially filtered with Adaptive jurik with lower period for opening/closing trades.
Thank you!

Re: MT4 Indicators with alerts/signals

Posted: Wed Oct 16, 2019 5:04 am
by Alphonse91
mrtools wrote: Wed Oct 09, 2019 11:09 am

Added a more user friendly mtf.

How to use Momentum Scalper for MT4: Instructions.
Hello Mr. Tools, thank you very much for this indicator, but it seems there still glitch or is this normal? Also may I know if this indi is repainting/recalculating or not?
The light green/red green sometimes not plotting and sometimes turn from red to green. The pics below is on the 5 min. TF, when the glitch happen, I have to cycle through another TF. Sometimes it back to normal, sometimes it isn't. Thank you very much.