//+------------------------------------------------------------------+
//| find-red.mq4 |
//| Copyright 2022, MetaQuotes Software Corp. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2022, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
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;
}
}
double redcandle =0;
for(int i=last_red_bar-1;i>=0 && last_red_bar>0;i--)
{
redcandle = Close[i]>Open[i];
if(High[i]>red_high)
{
if(i==0) Alert("Hihihhi",red_high);
break;
}
}
datetime last_Red_candle_time=0;
while(true)
{
if(iOpen(Symbol(),0,last_red_bar)>iClose(Symbol(),0,last_red_bar))
{
last_Red_candle_time=iTime(Symbol(),0,last_red_bar);
break;
}}
int shift=iBarShift(Symbol(),0,last_Red_candle_time);
datetime newtime = iTime(Symbol(),0,shift);
Comment("red high",red_high, " red candle ",last_Red_candle_time, " newtime ",newtime);
}
//+------------------------------------------------------------------+