Ritardare l'allarme di alcuni secondi

 
Ciao a tutti.
Vorrei modificare questo codice in modo che l' alert, invece di apparire all'apertura della candela, rilevi le condizioni dopo qualche secondo.

Grazie di tutto, 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: Vorrei modificare questo codice
  1. Quindi cosa ti ferma? Impara a codificarlo o paga qualcuno. Non lo codificheremo PER voi. Siamo disposti ad AIUTARVI quando posterete il vostro tentativo (usando SRC) e la natura del vostro problema.
  2. Hai provato
      BarStart = Time[0]; 
      Sleep(3000); RefreshRates();

 
Ciao WHRoeder , grazie per la risposta. Mi scuso per il mio comportamento, ma non era mia intenzione offendere e mancare di rispetto a nessuno. Ho provato tutto il giorno per cambiare il codice per realizzare questo , ma non ho avuto successo . Sono l'inizio dello studio MQL4 . Chiedo nuovamente scusa agli amministratori. Saluti , Massimo
 

Ciao WHRoeder, ho provato, ma non funziona!!!Ho provato in tutti i modi, ma non capisco dove sbaglio!

Comunque, grazie di tutto, Massimo.

 
Non vedo un avviso nel tuo codice
 
Ciao GunRai, ti invio il codice completo, quindi ti spiego. Non ho potuto ritardare la conferma delle condizioni di apertura della candela (come sta facendo ora), ma dopo 3 secondi, anche il suggerimento di WHRoeder. Non riesco a capire dove sbaglio !!!

Grazie, 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);
  }
//+------------------------------------------------------------------+
 
Hai ragione, stai eseguendo un indicatore.
int start(){
if (BarStart !=Time[0]) 
{
  BarStart = Time[0]; 
   Sleep(3000); RefreshRates(); //this code don't work
Provi questo
#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:
Hai ragione, stai eseguendo un indicatore.
Provi questo

Grazie, ora mi studio il codice che mi hai postato e poi ti faccio sapere.
Per ora, infinite grazie, Massimo.
 
WHRoeder:
Hai ragione, stai eseguendo un indicatore.
y thi

WHRoeder Ciao, ho provato a cambiare il codice con le tue istruzioni. Ho provato vari modi e quello che mandi è quello che non ha errori, ma il ritardo di circa cinque secondi c'è solo sull'alert sound, mentre le frecce continuano a comparire all'apertura esatta della candela.

Ciao e grazie, 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: c'è solo il suono dell'allarme,
  1. Non ho idea di cosa volessi dire.
  2. Alert( ATTENTION!!!!); }
    Prova a postare del codice che compila.
 
WHRoeder:
  1. Non ho idea di cosa volessi dire.
  2. Prova a postare del codice che compila.
Ho messo ATTENZIONE !!! perché è quello che appare in allarme sonoro/visivo, ma sto cercando, con il vostro aiuto, di ritardare l'insorgenza della Freccia pochi secondi. In questo caso. Attenzione !!! Apparirà dopo 5 secondi, mentre le Frecce appaiono appena aperta la candela.
Grazie di tutto, Massimo.
Motivazione: