Retrasa la alerta varios segundos

 
Hola a todos.
Me gustaría modificar este código para que la alerta, en lugar de aparecer en la apertura de la vela, detecte las condiciones después de unos segundos.

Gracias por todo, Massimo.


int start(){
if (BarStart !=Time[0]) 
{
  BarStart = Time[0]; 

  //Indicator Buffer 1
     
       if ( iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, 0+1) > 70
      
      
      )
        {
         Buffer1[0] = Low[0] - iATR(NULL, PERIOD_CURRENT, 14, 0); //Set indicator value at Candlestick Low - Average True Range
        }
      else
        {
         Buffer1[0] = 0;
        }
      //Indicator Buffer 2
    
      && iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, 0) < 30
     
      )
        {
         Buffer2[0] = High[0] + iATR(NULL, PERIOD_CURRENT, 14, 0); //Set indicator value at Candlestick High + Average True Range
        }
      else
        {
         Buffer2[0] = 0;
        }
     }
   return(0);
  }
 
omissamf: Me gustaría modificar este código
  1. Así que, ¿qué te detiene? Aprende a codificarlo o paga a alguien. No vamos a codificar para ti. Estamos dispuestos a AYUDARTE cuando publiques tu intento (usando SRC) y la naturaleza de tu problema.
  2. ¿Ha intentado
      BarStart = Time[0]; 
      Sleep(3000); RefreshRates();

 
Hola WHRoeder , gracias por la respuesta . Me disculpo por mi comportamiento, pero no era mi intención de ofender y faltar el respeto a nadie. He intentado todo el día para cambiar el código para lograr esto, pero no lo logré. Son los inicios del estudio MQL4. Pido de nuevo disculpas a los administradores. Saludos, Massimo
 

Hola WHRoeder, lo he intentado, pero no funciona!!! lo he intentado de todas las maneras, pero no entiendo donde me equivoco!!!

De todos modos, gracias por todo, Massimo.

 
No veo una alerta en su código
 
Hola GunRai, te envío el código completo, así que voy a explicar. No pude retrasar la confirmación de las condiciones de la apertura de la vela (como lo está haciendo ahora), pero después de 3 segundos, incluso la sugerencia de WHRoeder. ¡¡¡ No puedo entender donde me equivoco !!!

Gracias, Max.


//+------------------------------------------------------------------+
//|                                                    RSI 70-30.mq4 |
//|                                                          Massimo |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Massimo"
#property link      "https://www.mql5.com"
#property version   "1.00"
#include <stdlib.mqh>
#include <stderror.mqh>

//--- indicator settings
#property indicator_chart_window
#property indicator_buffers 2

#property  indicator_type1 DRAW_ARROW
#property  indicator_width1 1
#property  indicator_color1 0xFFAA00
#property  indicator_label1 "Buy"

#property  indicator_type2 DRAW_ARROW
#property  indicator_width2 1
#property  indicator_color2 0x0000FF
#property  indicator_label2 "Sell"
static datetime BarStart=0;

//--- indicator buffers
double Buffer1[];
double Buffer2[];

datetime time_alert; //used when sending alert
extern bool Audible_Alerts = true;
double myPoint; //initialized in OnInit

void myAlert(string type, string message)
  {
   if(type == "print")
      Print(message);
   else if(type == "error")
     {
      Print(type+" | RSI 30-70 @ "+Symbol()+","+Period()+" | "+message);
     }
   else if(type == "order")
     {
     }
   else if(type == "modify")
     {
     }
   else if(type == "indicator")
     {
      if(Audible_Alerts) Alert(type+" | RSI 30-70 @ "+Symbol()+","+Period()+" | "+message);
     }
  }
  
  //+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {   
   IndicatorBuffers(2);
   SetIndexBuffer(0, Buffer1);
   SetIndexEmptyValue(0, 0);
   SetIndexArrow(0, 241);
   SetIndexBuffer(1, Buffer2);
   SetIndexEmptyValue(1, 0);
   SetIndexArrow(1, 242);
   //initialize myPoint
   myPoint = Point();
   if(Digits() == 5 || Digits() == 3)
     {
      myPoint *= 10;
     }
   return(INIT_SUCCEEDED);
  }
//_____________________________________________
//_____________________________________________


int start(){
if (BarStart !=Time[0]) 
{
  BarStart = Time[0]; 
   Sleep(3000); RefreshRates(); //this code don't work

//
     
      //Indicator Buffer 1
      if(iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, 0) < 30
      
      )
        {
         Buffer1[0] = Low[0] - iATR(NULL, PERIOD_CURRENT, 14, 0); //Set indicator value at Candlestick Low - Average True Range
         if(0 == 0 && Time[0] != time_alert) { myAlert("indicator", "Buy"); time_alert = Time[0]; } //Instant alert, only once per bar
        }
      else
        {
         Buffer1[0] = 0;
        }
      //Indicator Buffer 2
      if(iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, 0) > 70
     
      )
        {
         Buffer2[0] = High[0] + iATR(NULL, PERIOD_CURRENT, 14, 0); //Set indicator value at Candlestick High + Average True Range
         if(0 == 0 && Time[0] != time_alert) { myAlert("indicator", "Sell"); time_alert = Time[0]; } //Instant alert, only once per bar
        }
      else
        {
         Buffer2[0] = 0;
        }
     }
   return(0);
  }
//+------------------------------------------------------------------+
 
Tiene razón, está ejecutando un indicador.
int start(){
if (BarStart !=Time[0]) 
{
  BarStart = Time[0]; 
   Sleep(3000); RefreshRates(); //this code don't work
Pruebe esto
#define   MAX_DATETIME   D'3000.12.31 23:59:59'  // 32,535,215,999
#define   MIN_DATETIME   D'1970.01.01 00:00:00'  // Zero.

int start(){
static datetime alertTime = MAX_DATETIME;
if(TimeCurrent() > alertTime){ alertTime = MAX_DATETIME; Alert(...); }
if (BarStart !=Time[0]) 
{
  BarStart = Time[0]; 
  :
  if(condition) alertTime = TimeCurrent() + 3; // Delay
 
WHRoeder:
Tiene razón, está ejecutando un indicador.
Pruebe esto

Gracias, ahora estudio el código que me has puesto y luego te cuento.
Por ahora, infinitas gracias, Massimo.
 
WHRoeder:
Está en lo cierto; está ejecutando un indicador.
y esto

WHRoeder Hola, he tratado de cambiar el código con sus instrucciones. Probé varias maneras y eso es lo que usted envía es lo que no tiene errores, pero el retraso de unos cinco segundos sólo hay sull'alert sonido, mientras que las flechas siguen apareciendo apertura exacta de la vela.

Hola y gracias, Massimo.

#define   MAX_DATETIME   D'3000.12.31 23:59:59'  // 32,535,215,999
#define   MIN_DATETIME   D'1970.01.01 00:00:00'  // Zero.


int start(){
static datetime alertTime = MAX_DATETIME;
if (TimeCurrent() > alertTime)
{ alertTime = MAX_DATETIME;
 Alert(“ ATTENTION!!!!); }

if (BarStart !=Time[0]) 
{
  BarStart = Time[0]; 
  
//
     
      //Indicator Buffer 1
      if(iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, 0) < 30
      
      )
        {
         alertTime = TimeCurrent() + 3;
         Buffer1[0] = Low[0] - iATR(NULL, PERIOD_CURRENT, 14, 0);        }
      else
        {
         Buffer1[0] = 0;
        }
      //Indicator Buffer 2
      if(iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, 0) > 70
     
      )
        {
                     alertTime = TimeCurrent() + 3;
         Buffer2[0] = High[0] + iATR(NULL, PERIOD_CURRENT, 14, 0);                }
      else
        {
         Buffer2[0] = 0;
        }
     }
   return(0);
  }
//+------------------------------------------------------------------+





 
omissamf: sólo hay sonido sull'alert,
  1. Ni idea de lo que quieres decir.
  2. Alert( ATTENTION!!!!); }
    Intenta/publica el código que compila.
 
WHRoeder:
  1. Ni idea de lo que quieres decir.
  2. Pruebe/publique el código que compila.
Puse ATENCIÓN! !! porque es el que aparece en el sonido / alerta visual, pero estoy tratando, con su ayuda, para retrasar el inicio de la Flecha unos segundos. En este caso. ¡¡¡ Atención!! ! Aparecerá después de 5 segundos , mientras que las flechas aparecen justo al abrir la vela.
Gracias por todo, Massimo.
Razón de la queja: