# Find Last Red Candle - page 2

19307
Vasyl Nosal

I hope it clear :)

247

Hi eevviill,

Thank you But your code doesn't solve the problem

19307
Vasyl Nosal

Hi eevviill,

Thank you But your code doesn't solve the problem

Why?
247

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]

19307
Vasyl Nosal
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]

Maybe screenshot helps. Becouse you give bad explanation.
247

I hope it clear :)

19307
Vasyl Nosal
```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)
{
break;
}
}```
Moderator
10612

```   int last_Red_candle_index=1;
static datetime last_Red_candle_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++;
}
{
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(),"  ");