# Quick opinion on bullish and bearish candle formation

87

Hi guys,

I'm in the process of just adjusting a few entry command but i was wondering how one would attempt coding my EA to enter on a two bullish bar formation?  I've tried the Close[0]>Open[0] but when I run the EA it doesnt actually open positions when the conditions are met.

It still sometimes enters on bars which aren't bullish. This is such an amateur question but would appreciate any help as this would literally be the final piece to my puzzle.

How would i be able to code those to enter AFTER the close of the second postive bar and AFTER the second negative bar which are both circled.

Moderator
15103

`if(Close[1]>Open[1] && Close[2]>Open[2])`
68

you need to look back from the current candle which is still building

to detemine whether a candle is bullish or bearish

```// candle[0] --> current óne, not finished yet
// a candle body is usually calculated from:
//   Open - Close price
//
// bearish candles open at the top and close at the bottom
// bullish candles open at the bottom and close at the top
//
// thus a beairsh candle has a positive, a bullish one a negative value

// check for bearish series
if ( (iOpen(Symbol(), Period(), 1) - iClose(Symbol(), Period(), 1)) > 0) { // 1st candle before current must be bearish

if ( (iOpen(Symbol(), Period(), 2) - iClose(Symbol(), Period(), 2)) > 0) { // 2nd candle before current must be bearish

}

}

// check for bullish series
if ( (iOpen(Symbol(), Period(), 1) - iClose(Symbol(), Period(), 1)) < 0) { // 1st candle before current must be bullish

if ( (iOpen(Symbol(), Period(), 2) - iClose(Symbol(), Period(), 2)) < 0) { // 2nd candle before current must be bullish