Download MetaTrader 5

Find Last Red Candle - page 2

To add comments, please log in or register
Vasyl Nosal
19307
Vasyl Nosal  
FxTrader_:

I hope it clear :)



 

fxtrader_
247
fxtrader_  

Hi eevviill,

Thank you But your code doesn't solve the problem

Vasyl Nosal
19307
Vasyl Nosal  
FxTrader_:

Hi eevviill,

Thank you But your code doesn't solve the problem

Why?
fxtrader_
247
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??
Vasyl Nosal
19307
Vasyl Nosal  
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.
fxtrader_
247
fxtrader_  

I hope it clear :)



Vasyl Nosal
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)
{
if(i==0) Alert(Hihihhi);
break;
}
}
Keith Watford
Moderator
10612
Keith Watford  
   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

12
To add comments, please log in or register