alert at current candle open (or last candle close)

 

hello,

i'm trying to code an indicator derived from an EMA Crossover indicator .

the indicator draw an arrow on the current candle when conditions are met and it does his job.

now the problem is with the popup and ring-tone alert, it comes too late, the ring-tone and the popup window appear at the candle close...

i would like to get the pop up and the arrows at the same time, so i tried to move the alert inside the same condition (with the arrows) and it works but the problem is that when i load the indicator it freezes the computer because of the popup and ring-tone ringing for each arrows drawn on the chart....


here is the code:

#property indicator_chart_window

#property indicator_buffers 2

#property indicator_color1 2026496

#property indicator_color2 236

#property indicator_width1 1

#property indicator_width2 1



double CrossUp[];

double CrossDown[];

extern bool SoundON=true;

double alertTag;

 double control=2147483647;

 

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

//| Custom indicator initialization function                         |

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

int init()

  {

//---- indicators

   SetIndexStyle(0, DRAW_ARROW, EMPTY,1);

   SetIndexArrow(0, 233);

   SetIndexBuffer(0, CrossUp);

   SetIndexStyle(1, DRAW_ARROW, EMPTY,1);

   SetIndexArrow(1, 234);

   SetIndexBuffer(1, CrossDown);

//----

   return(0);

  }

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

//| Custom indicator deinitialization function                       |

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

int deinit()

  {

//---- 



//----

   return(0);

  }

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

//| Custom indicator iteration function                              |

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

int start() {

   int limit, i, counter;

   double MA00;

   double MA01;

   double MA1;

   double MA2;

   double MA3;

   double MA4;

   double MA5;

   double MA6;

   double MA7;

   double Range, AvgRange;

   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=Bars-counted_bars;

   

   for(i = 0; i <= limit; i++) {

   

      counter=i;

      Range=0;

      AvgRange=0;

      for (counter=i ;counter<=i+9;counter++)

      {

         AvgRange=AvgRange+MathAbs(High[counter]-Low[counter]);

      }

      Range=AvgRange/10;

   

   MA00=iMA(NULL,0,1,0,MODE_LWMA,PRICE_CLOSE,i+1);

   MA01=iMA(NULL,0,1,0,MODE_LWMA,PRICE_CLOSE,i+2);

   MA2=iMA(NULL,0,30,0,MODE_LWMA,PRICE_CLOSE,i);   

   MA3=iMA(NULL,0,40,0,MODE_LWMA,PRICE_CLOSE,i);

   MA4=iMA(NULL,0,55,0,MODE_LWMA,PRICE_CLOSE,i);

   MA5=iMA(NULL,0,60,0,MODE_LWMA,PRICE_CLOSE,i);

   MA6=iMA(NULL,0,90,0,MODE_LWMA,PRICE_CLOSE,i);

   MA7=iMA(NULL,0,120,0,MODE_LWMA,PRICE_CLOSE,i);

   

   

      

      if ( (MA4 > MA5 && MA5 > MA6 && MA6 > MA7) && MA01 < MA3 && MA00 > MA2) {

         CrossUp[i] = Low[i] - Range*0.5;
                                                 //drawing arrows
      }

      else if ( (MA4 < MA5 && MA5 < MA6 && MA6 < MA7) && MA01 > MA3 && MA00 < MA2) {

          CrossDown[i] = High[i] + Range*0.5;

      }

        if (SoundON==true && i==1 && CrossUp[i] > CrossDown[i] && alertTag!=Time[0]){

         Alert("SHORT on ",Symbol()," ",Period());
                                        //popup alert
        alertTag = Time[0];

      }

        if (SoundON==true && i==1 && CrossUp[i] < CrossDown[i] && alertTag!=Time[0]){

       Alert("LONG on ",Symbol()," ",Period());

        alertTag = Time[0];

        } 

  }

   return(0);

}


what i need is just the same indicator but ringing at current candle open or at the last candle close.

any input really appreciated, i tried many things i found on this forum but nothing working.

i suck at coding so, please if you answer be explicit...


THX

 
Kfree 2010.11.28 17:10
now the problem is with the popup and ring-tone alert, it comes too late, the ring-tone and the popup window appear at the candle close...
 if (SoundON==true && i==1 ...
i == 1 only at the start of a new candle, current candle is zero.
 
WHRoeder:
i == 1 only at the start of a new candle, current candle is zero.

many thanks WHRoeder, i will try this, and post the final version of my indicator if you want give it a try.
 
//+------------------------------------------------------------------+
//|                                                   VOLCANOWMA.mq4 |
//|                                         Copyleft © 2010, Kikoolol|
//|                                                                  |
//+------------------------------------------------------------------+

/*
  +------------------------------------------------------------------+
  | Allows you to enter in the market at the right moment ;)     
  +------------------------------------------------------------------+
*/   
#property copyright "kikoolol"
#property link      "http://localhost/"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 2026496
#property indicator_color2 236
#property indicator_width1 1
#property indicator_width2 1

double CrossUp[];
double CrossDown[];
extern bool SoundON=true;
double alertTag;
 double control=2147483647;
 
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0, DRAW_ARROW, EMPTY,1);
   SetIndexArrow(0, 233);
   SetIndexBuffer(0, CrossUp);
   SetIndexStyle(1, DRAW_ARROW, EMPTY,1);
   SetIndexArrow(1, 234);
   SetIndexBuffer(1, CrossDown);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start() {
   int limit, i, counter;
   double MA00;
   double MA01;
   double MA1;
   double MA2;
   double MA3;
   double MA4;
   double MA5;
   double MA6;
   double MA7;
   double MA02;
   double MA05;
   double Range, AvgRange;
   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=Bars-counted_bars;
   
   for(i = 0; i <= limit; i++) {
   
      counter=i;
      Range=0;
      AvgRange=0;
      for (counter=i ;counter<=i+9;counter++)
      {
         AvgRange=AvgRange+MathAbs(High[counter]-Low[counter]);
      }
      Range=AvgRange/10;
   
   MA00=iMA(NULL,0,1,0,MODE_LWMA,PRICE_CLOSE,i+1);
   MA01=iMA(NULL,0,1,0,MODE_LWMA,PRICE_CLOSE,i+2);
   MA2=iMA(NULL,0,30,0,MODE_LWMA,PRICE_CLOSE,i);
   MA02=iMA(NULL,0,30,0,MODE_LWMA,PRICE_CLOSE,i+1);    
   MA3=iMA(NULL,0,40,0,MODE_LWMA,PRICE_CLOSE,i);
   MA4=iMA(NULL,0,55,0,MODE_LWMA,PRICE_CLOSE,i);
   MA5=iMA(NULL,0,60,0,MODE_LWMA,PRICE_CLOSE,i);
   MA05=iMA(NULL,0,60,0,MODE_LWMA,PRICE_CLOSE,i+1);
   MA6=iMA(NULL,0,90,0,MODE_LWMA,PRICE_CLOSE,i);
   MA7=iMA(NULL,0,120,0,MODE_LWMA,PRICE_CLOSE,i);
      
      
      if ( (MA4 > MA5 && MA5 > MA6 && MA6 > MA7) && MA01 < MA3 && MA00 > MA02 && iClose(NULL,0,i+1) > iOpen(NULL,0,i+1) 
      && iClose(NULL,0,i+1) > MA02 && iClose(NULL,0,i+1) > MA05)  {
         CrossUp[i] = Low[i] - Range*1.2;
         
         if (SoundON==true && i==0 && CrossUp[i] < CrossDown[i] && alertTag!=Time[0]){
         Alert("LONG on ",Symbol()," ",Period());
          alertTag = Time[0];
        } 
         
      }
      else if ( (MA4 < MA5 && MA5 < MA6 && MA6 < MA7) && MA01 > MA3 && MA00 < MA02 && iClose(NULL,0,i+1) < iOpen(NULL,0,i+1) 
      && iClose(NULL,0,i+1) < MA02 && iClose(NULL,0,i+1) < MA05) {
          CrossDown[i] = High[i] + Range*1.2;
          
          if (SoundON==true && i==0 && CrossUp[i] > CrossDown[i] && alertTag!=Time[0]){
          Alert("SHORT on ",Symbol()," ",Period());
           alertTag = Time[0];
        }
      }       
  }
   return(0);
}

you put me on the way, many thanks again...

you can check out my thread on FF to see how to use it: http://www.forexfactory.com/showthread.php?t=262960

Regards

 

can anyone please help me and optimize this indicator to alert within the first 10 seconds of candle formation. the alert comes sometimes up to 2 minutes late. I will be very grateful

Files:
KM-SA.mq4  3 kb
 

I am sorry, I attached the wrong file. I meant to attach the MBK ASCtrend

Files:
 
ofwono: optimize this indicator to alert within the first 10 seconds of candle formation. the alert comes sometimes up to 2 minutes late. I will be very grateful
  1. Since the indicator processes all bar every tick it can't alert late. It alerts when you receive a new tick on a new bar.
  2. How grateful? Are you going to send me money?
 
whroeder1:
  1. Since the indicator processes all bar every tick it can't alert late. It alerts when you receive a new tick on a new bar.
  2. How grateful? Are you going to send me money?

Hi whroeder,   sure I would pay you handsomely if you could make that MBKASCtrend send alert within 10 seconds of candle formation. please try it out, the alert is too useless for binary trade, it is always way too late.

 

hi can anyone please help me. id like this indicator to alert me on candle open not after the candle closes. 

<Decompiled code deleted>

 
  1. rojack2: can anyone please help me. id like this indicator to alert me on candle open not after the candle closes. 
    There is no candle close. Only when a new bar starts is the previous one closed.

  2. Don't Hijack other threads for your off-topic post. Next time, make your own, new, thread.

  3.    gia_348[gi_256] = 0;
       gia_348[gi_260] = 0;
       gia_348[gi_264] = 0;

    Ask the owner of the source code to give it to you or have him fix it for you.

    De-compiled code is stolen code. Either you are a thief, a fence, or the receiver of stolen (intellectual) property. Either way we will not be an accomplice after the fact to that theft.
              See also forum.MQL4.com/41864#490649

    If you post decompiled code again, you will likely be banned.

    Don't tell us you found it on the 'net: if someone stole your bank details and uploaded them on to the internet, is it OK for everyone to use them because "someone uploaded it, I don't know why I can't use that"?

 

Hi everyone please i need your help on this indicator, i adjusted fractal so that you can switch between periods,
so i used bollinger bands and fractal to avoid false signals, the aim is that if fractal at your desired period shows and current close is above or below the bollinger bands then you sell or buy, it works very great but the problem is that i get alerts very late and arrows also shows very late and i tried alot but still yet i cant figure it out,
so please if their is anything you can add i will really appreciate your help, Thanks in advance.



Files:
FractalsAD.mq4  13 kb
Reason: