Tracking the last bull/bear candle

 
Hello,anyone who knows how to track the last bull/bear candle? I kindly ask for your help.
 
 simply,am looking forward to create an indicator that gives buy signals whenever the current bull candle closes above the last bear candle AND sell signals whenever a bear candle closes bolow the last bull candle. 

As I’ve highlighted in my attachment below 
1st rectangle as a buy signal 
2nd rectangle as a sell signal 
3rd rectangle as a buy signal 
Files:
IMG_3393.jpeg  202 kb
 
  • Usually people who can't code don't receive free help on this forum.
  • If you show your attempts and describe your problem clearly, you will most probably receive an answer from the community. Use the CODE button (Alt-S) when inserting code.
  • To learn MQL programming, you can research the many available Articles on the subject, or examples in the Codebase, as well as reference the online Documentation.
  • If you do not want to learn to code, that is not a problem. You can either look at the Codebase if something free already exists, or in the Market for paid products (also sometimes free). However, recommendations or suggestions for Market products are not allowed on the forum, so you will have to do your own research.
  • Finally, you also have the option to hire a programmer in the Freelance section.
 
Your topic has been moved to the section: Technical Indicators
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
 
input ENUM_TIMEFRAMES               TimeFrame                  = PERIOD_CURRENT;         // EA Timeframe
  
double  Close = iClose(_Symbol,TimeFrame,1);
 double  Open = iOpen(_Symbol,TimeFrame,1);

if(Close >Open)
{
// BUY SIGNAL
}

if(Open<Close)
{
// SELL SIGNAL
}

I think this will do the job.

 
Fernando Carreiro #:
  • Usually people who can't code don't receive free help on this forum.
  • If you show your attempts and describe your problem clearly, you will most probably receive an answer from the community. Use the CODE button (Alt-S) when inserting code.
  • To learn MQL programming, you can research the many available Articles on the subject, or examples in the Codebase, as well as reference the online Documentation.
  • If you do not want to learn to code, that is not a problem. You can either look at the Codebase if something free already exists, or in the Market for paid products (also sometimes free). However, recommendations or suggestions for Market products are not allowed on the forum, so you will have to do your own research.
  • Finally, you also have the option to hire a programmer in the Freelance section.
Thank you 🙏🏻 
 
shoky afroking:
Hello,anyone who knows how to track the last bull/bear candle? I kindly ask for your help.
 
 simply,am looking forward to create an indicator that gives buy signals whenever the current bull candle closes above the last bear candle AND sell signals whenever a bear candle closes bolow the last bull candle. 

As I’ve highlighted in my attachment below 
1st rectangle as a buy signal 
2nd rectangle as a sell signal 
3rd rectangle as a buy signal 

i see you have something similar like Engulf. these codes are freely available on codebase which you can modify and help yourself

Sie Samuel Roland Youl #:

I think this will do the job.

No it wont do the job. check the op's requirement he mentions last candle.

something like this may work.

input ENUM_TIMEFRAMES               TimeFrame                  = PERIOD_CURRENT;         // EA Timeframe
  
double  last_Close = iClose(_Symbol,TimeFrame,2);
 double   last_Open = iOpen(_Symbol,TimeFrame,2);

double cur_Close = iClose(_Symbol,TimeFrame,1);
 double   cur_Open = iOpen(_Symbol,TimeFrame,1);

if(last_Close < last_Open /* if prev candle is bear*/&&  cur_Close > cur_Open /* if current candle is bull*/&& cur_Close > last_Open /* if a closing is detected above bear candle */  ) 
{
// BUY SIGNAL
}
 //vice versa for sell

Additionally as per screenshot of Op, it looks like he wants to have a closing of bull above bear but its not the last candle. In this case he may have to store the info of candles in array and look for closing for n candles and break the loop or empty the array when a close is above bear found.

Bullish and Bearish Engulfing
Bullish and Bearish Engulfing
  • www.mql5.com
The EA trades based on the "Bullish and Bearish Engulfing" pattern.