Candle Change

 
Hi everyone,

I'm looking for a push notification  after the current candle closes opposite colour of the previous candle (ie. bull to bear or vice versa). I've searched but cannot find one.

Thank you.
 
which language?
 

mql4

 
vorexx1:
I'm looking for a push notification  after the current candle closes opposite colour of the previous candle (ie. bull to bear or vice versa). I've searched but cannot find one.

What you are describing sounds extremely simple. For example:

#property strict

// Store the start time of the most recent bar
datetime glbLastBarStart = 0;

void OnTick()
{
   // For compatibility with both MQL4 and MQL5, use CopyRates rather than
   // the simpler MQL4-only Time[], Open[], and Close[] pseudo-arrays
   MqlRates rates[];
   ArraySetAsSeries(rates, true);
   if (CopyRates(Symbol(), Period(), 0, 3, rates) < 3) return; // WTF? Don't have 3 bars of history?
  
   // On the first tick, when glbLastBarStart will be zero, get the start time of the current bar
   if (!glbLastBarStart) {
      glbLastBarStart = rates[0].time;
      Print("Starting at ", TimeToString(glbLastBarStart), "; no alerts before next candle starts");
   }

   // See if a new bar has started, by comparing the time of the current bar against
   // the cached value
   if (rates[0].time != glbLastBarStart) {
      // New bar has started. Check up/down status of bars 1 and 2.
      if (rates[1].open > rates[1].close && rates[2].open < rates[2].close) {
         SendNotification("New candle direction change: down");
      
      } else if (rates[1].open < rates[1].close && rates[2].open > rates[2].close) {
         SendNotification("New candle direction change: up");
      
      } else {
         // No change in candle direction, or open exactly equal to close
      }
  
      // Record new start time
      glbLastBarStart = rates[0].time;
   }
}
 
Thanks mate