Find Last Red Candle - page 2

 
FxTrader_:

I hope it clear :)



 

 

Hi eevviill,

Thank you But your code doesn't solve the problem

 
FxTrader_:

Hi eevviill,

Thank you But your code doesn't solve the problem

Why?
 
Assuming the last red candle index [5] and candle index [4,3,2,1] all closed above the High of candle [5] . I need the alert to alert me once NOT for each candle that closed above the high of last red candle.

Also if the last red candle index [5] and candle index [2,1] closed above the High of candle [5] I need the alert to alert me for candle[2] only NOT for candle [2 and 1]

dose your code do that??
 
FxTrader_:
Assuming the last red candle index [5] and candle index [4,3,2,1] all closed above the High of candle [5] . I need the alert to alert me once NOT for each candle that closed above the high of last red candle.

Also if the last red candle index [5] and candle index [2,1] closed above the High of candle [5] I need the alert to alert me for candle[2] only NOT for candle [2 and 1]

dose your code do that??

Maybe screenshot helps. Becouse you give bad explanation.
 

I hope it clear :)



 
int last_red_bar=-1;
double red_high=-1;
for(int i=0;i<Bars-20;i++)
{
if(Close[i]<Open[i])
{
last_red_bar=i;
red_high=High[i];
break;
}
}

for(int i=last_red_bar-1;i>=0 && last_red_bar>0;i--)
{
if(High[i]>red_high)
{
if(i==0) Alert(Hihihhi);
break;
}
}
 
   int last_Red_candle_index=1;
   static datetime last_Red_candle_time=0;
   static datetime alert_reference_time=0;

   while(true)
     {
      if(iOpen(Symbol(),0,last_Red_candle_index)>iClose(Symbol(),0,last_Red_candle_index))
        {
         last_Red_candle_time=iTime(Symbol(),0,last_Red_candle_index);
         break;
        }
      last_Red_candle_index++;
     }
   if(alert_reference_time!=last_Red_candle_time)
     {
      double red_candle_high=iHigh(Symbol(),0,last_Red_candle_index);
      for(int x=last_Red_candle_index-1;x>0;x--)
        {
         if(iClose(Symbol(),0,x)>red_candle_high)
           {
            Alert("Close Above Red Candle High  "+Symbol(),"    ",TimeToStr(CurTime(),TIME_DATE|TIME_MINUTES),
                  "   M",Period(),"  ");
            alert_reference_time=last_Red_candle_time;
            break;
           }
        }
     }

This should help you out

Reason: