Inside bar

QEDStonks

Newbie
May 15, 2022
1
0
1
28
Hello,


First post LFG!

I'm pretty new to MT4. I coded a lot in python so MT4 will take some getting used to.

1) What resources do you recommend as I can't find decent ones online

2) I'm trying to make an EA that checks if the last bar printed is inside the previous one


Like say we're at time, T. Is the bar T-1 inside of T-2? If so, print some signal

Again its on the 1m timeframe


Thx
 

Enivid

Administrator
Staff member
Nov 30, 2008
16,815
978
144
Odessa
www.earnforex.com
  • 👍
Reactions: QEDStonks

abiroid

Trader
Jul 5, 2022
1
2
8
36
If you are only interested in candle body, use Open and Close.
This is just a sample of what you could do.

MQL4:
   // Candle1 is on right side and candle2 is on left
   double open1 = iOpen(Symbol(), PERIOD_CURRENT, shift);
   double open2 = iOpen(Symbol(), PERIOD_CURRENT, shift+1);
   double close1 = iClose(Symbol(), PERIOD_CURRENT, shift);
   double close2 = iClose(Symbol(), PERIOD_CURRENT, shift+1);
 
   // Candle2 is Bearish and Candle1 is bullish   
   if(type == OP_BUY && close1 > open1 && open2 > close2 && close1 > open2) {
      return true;
   }
   // Candle2 is Bullish and Candle1 is bearish
   else if(type == OP_SELL && close1 < open1 && open2 < close2 && close1 < open2) {
      return true;
   }

int type could be whatever direction you are checking for.

You could look through mql5.com codebase for engulfing EA code. There are a few.
Or maybe look for a simple EA and build from there.
 
  • ℹ️
Reactions: Enivid