Retard the alert several seconds

Back to topics list  | 1 2 3 4 5 To post a new topic, please log in or register
avatar
63
omissamf 2016.03.07 09:22 #
 
Hi guys, I have to apologize to Gum Rai. This morning calmly and open markets have entered your code and IT WORKS !!!!
I did not understand what was wrong, because I think I entered like last time, but surely it's me that I'm wrong. Excuse me, GumRai. You are a great !!!

Greetings, Massimo.


int start()
{
  static datetime BarStart=0;
   static bool check=false;
    if(BarStart!=Time[0])
     {
      BarStart=Time[0];
      check=true;
     }
   if(check && TimeCurrent()>=Time[0]+3)
     {
      check=false;
      //Check Condition
    

//_________________________________

/*void OnTimer(){
{
if(Bars!=prev_bars) current_candle_alert_been=false;
prev_bars=Bars;

if(current_candle_alert_been) return;
if(TimeLocal()-time_dif<Time[0]+seconds) return;
current_candle_alert_been=true;
 */    
      //Indicator Buffer 1
      if(iRSI(NULL, PERIOD_CURRENT, Period1, 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, Period1, 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);
}
 //-----------------------------------------------------------------------------------------------------------------------------


avatar
Moderator
3427
GumRai 2016.03.07 12:48 #
 

No worries,

I am just happy that you have it worked out

avatar
13009
WHRoeder 2016.03.07 16:22 #
 
GumRai: But what you are saying is that Bars increases by adding earlier data to a chart. So that means that by adding the earlier bars, the return from bars will increase, so using Bars instead of Time[] will detect a new bar even when there has not been a new bar?

Exactly.

Indicators do not use new bar code. They use either rates_total and previous_calculated, or Bars and IndicatorCounted() so they recalculate the newly added earlier data.

EA's use the Time[0] new bar code to detect a new bar.

Example on the daily: Thursday=[1] Friday=[0] Bars=2

Then history is added: Tuesday=[3], Wednesday=[2] Thursday=[1] Friday=[0] Bars changed to 4 but the day is still Friday: no new day.

Bars is unreliable (a refresh/reconnect can change number of bars on chart) volume is unreliable (miss ticks) Always use time. New candle - MQL4 forum

avatar
872
eevviill 2016.03.07 16:45 #
 
WHRoeder:

Exactly.

Indicators do not use new bar code. They use either rates_total and previous_calculated, or Bars and IndicatorCounted() so they recalculate the newly added earlier data.

EA's use the Time[0] new bar code to detect a new bar.

Example on the daily: Thursday=[1] Friday=[0] Bars=2

Then history is added: Tuesday=[3], Wednesday=[2] Thursday=[1] Friday=[0] Bars changed to 4 but the day is still Friday: no new day.


Ye ye, ofcourse. You are wrong again. No new day. But there are new bars-data-days and you need to recount all data in indicator or EA.


Back to topics list   | 1 2 3 4 5  

To add comments, please log in or register