candle pattern bullish engulfing candle - page 2

 
Agent86:

And to top things off there is no engulfing candle which engulfs the previous bearish candle anywhere near this time frame or location at all.

Please advise
Thanks
Is this an EA or an Indicator that you are running ? Maybe you should show your code . .
 
It's just an EA with other stuff in it for experimentation purposes, but here it is as it stands now

//+------------------------------------------------------------------+
//|                                                  Agent86_5min.mq4 |
//|                                                    Unfinished POS |
//|                                    
//+------------------------------------------------------------------+
#property copyright "Unfinished POS by Agent86"


//---- input parameters
extern double    TakeProfit=20.0;
extern double    Lots=0.1;
extern double    StopLoss=15.0;
extern int MagicNumber=123486;

double v1[];
double v2[];
double v3[];
double val1;
double val2;
double val3;


//++++ These are adjusted for 5 digit brokers.

int     pips2points;    // slippage  3 pips    3=points    30=points
double  pips2dbl;       // Stoploss 15 pips    0.0015      0.00150
int     Digits.pips;    // DoubleToStr(dbl/pips2dbl, Digits.pips)

    // OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
   if (Digits == 5 || Digits == 3)
   {    // Adjust for five (5) digit brokers.
      pips2dbl    = Point*10; pips2points = 10;   Digits.pips = 1;
   } 
   else 
    {    
      pips2dbl    = Point;    pips2points =  1;   Digits.pips = 0; 
    }
    // OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl
     
   
    
//---- 

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 
   
//----
   return(0);
  }
   
    
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
  
   int i=0;                 
   val1=iFractals(NULL, 0, MODE_UPPER,3);
   val2=iFractals(NULL, 0, MODE_LOWER,3); 
   double   faster = iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,3), //MODE_MAIN
            slower = iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,3); //MODE_SIGNAL

if(Close [2] < Open [2]
   && Close[1] > Open[1] 
   && Open[1]<=Close[2] 
   && Close[1]>Open[2])
   Print (Close[1], " Bullish Engulfing Candle "); 

for(i=0; val1==0 || val2==0; i++)
     {
     if(iFractals(NULL, 0, MODE_UPPER,i) > 0 && val1 == 0) 
     val1 = iFractals(NULL, 0, MODE_UPPER, i);
     if(iFractals(NULL, 0, MODE_LOWER, i) > 0 && val2 == 0)
     val2 = iFractals(NULL, 0, MODE_LOWER, i);
     double A = val2;
     if(val2 != 0)  
     Print (A, " A loop");  //so how to print A in the if(statements)
      
     //Print (" Last UPPER Fractal at ", val1, " Last LOWER Fractal at ", val2);
         
     }   
                  
/*                
   if(val1 > 0 && faster > slower)
      {
       //Print (val1, " val1");
       //Print(TimeToStr(Time[3],TIME_DATE|TIME_MINUTES), " = val1 time");      
       //datetime b = Time[3];
       ////Print (A, " A if");
       double Z=(val1-A)/2;
       double C=A+Z;
       ////Print (C, " C");
       if(Low[0]<=C)
       Print (Low[0], " Low [0] ", C, " and C"); 
       //if(Close [2] < Open [2] && Open[1]<=Close[2] && Close[1]>Open[2]&& Close[1] < val1)
       //Print (Close[1], " Bullish Engulfing Candle "); 
      }
   if(val2 > 0 && faster > slower)
      {
       //Print (val2, " val2");
       //Print(TimeToStr(Time[3],TIME_DATE|TIME_MINUTES), " = val2 time");
       //datetime c = Time[3]; 
      }
            
*/   
                 
   return(0);
  }    

//+------------------------------------------------------------------+


This is the part I'm working on that does not seem to coordinate on the chart as expected

if(Close [2] < Open [2]   //bear
   && Close[1] > Open[1]  //bull
   && Open[1]<=Close[2]   //opening of bull is <=close of bear
   && Close[1]>Open[2])   //close of bull is > then open of bear
   Print (Close[1], " Bullish Engulfing Candle ");  //so after these conditions print something

//then stop the tester or let is finish and review the print time with the candle that formed at those times


And when comparing the print statement time with the candles I cannot find any candles matching the if statement so why did it print anything if the candle is not there or even near by.

I mean a bullish engulfing candle closest to the print statement could be hours away and the if(statement did not even print anything for that so I'm not sure what I'm doing wrong here.

 
Separate question and observation:

I took out all the print statements except the Print (Close[1])
When you print Close[1] ? Doesn't it print Close[1] at the time of Close[1] or can it print it anytime during Bar[0] because Close[1] will still be Close[1] value anytime ?

After reviewing the prints and candles there does appear to be some bullish candles in range, however now it prints and prints and print the whole time during Bar[0] which is ok, but I think I see now why the prints are not on the 5's on the 5min chart because it can print anytime during Bar[0] and I'm guessing even a bit late and thus it may not be on the 5's

But also still printing many bullish engulfing statements with NO bullish candles in site or in range for as many as 10-15 candles away from the time of the print statement. So it's clearly not referring to those, and just printing out an engulfing statement for not reason that could be observed on the charts
Anyhow just some more info to this topic

Thanks
 
int start()
   {
   if (New_Bar())
      {
      if(Close [2] < Open [2]   //bear
        && Close[1] > Open[1]  //bull
        && Open[1]<=Close[2]   //opening of bull is <=close of bear
        && Close[1]>Open[2])   //close of bull is > then open of bear
        Print (Close[1], " Bullish Engulfing Candle ");  //so after these conditions print something
      }
   return (0);
   }


bool New_Bar()
   {
   static datetime New_Time = 0;
   bool New_Bar = false;
   if (New_Time != Time[0])
      {
      New_Time = Time[0];
      New_Bar = true;
      }
   return(New_Bar);
   }
 
Agent86:
But also still printing many bullish engulfing statements with NO bullish candles in site or in range for as many as 10-15 candles away from the time of the print statement. So it's clearly not referring to those, and just printing out an engulfing statement for not reason that could be observed on the charts

Seems to work fine for me, I looked through the log and found the engulfing bars, I have marked a few with a red arrow . . .

Don't forget, the time stamp is current time, think bar 0, your engulfing bar is bar 1 so you need to look back to the previous candle compared to the time stamp in the log.

 
Ok, thanks

I'll review it a bit more and keep working on it

Thanks

bool New_Bar()
   {
   static datetime New_Time = 0;
   bool New_Bar = false;
   if (New_Time != Time[0])
      {
      New_Time = Time[0];
      New_Bar = true;
      }
   return(New_Bar);
   }

I see this that you added, I think this is the same as a previous one I was working on that freezes things until the next bar
I was going to work on that part next since it is printing out the statement all the time I figured this would also create multiple orders too.

Is there need to put this at the beginning of the start or anywhere global ?


And on last thing, how will this effect any trades if I want to trade based on the Close[1] of the bullish engulfing candle ? I'm assuming if the print statement is printing later then I want then I have to make changes to insure that any orders would be opened on the close of that candle as well, or the Open[0] may be ok as well.
Will opening orders be opened late as well as the print statements ?


Thanks

 
RaptorUK:

Seems to work fine for me, I looked through the log and found the engulfing bars, I have marked a few with a red arrow . . .

Don't forget, the time stamp is current time, think bar 0, your engulfing bar is bar 1 so you need to look back to the previous candle compared to the time stamp in the log.

Now when i c your EA in play, i need to tell u your logic isn't right



 
qjol:

Now when i c your EA in play, i need to tell u your logic isn't right

They are engulfing according to Agent86's definition . . in other words his code is working.
 

hooopssssssssssss

didn't mean you, only your quote & the pic

 
qjol:

hooopssssssssssss

didn't mean you, only your quote

Yep, I realised what you meant. Agent86's definition of an Engulfing candle isn't the same as mine either . . but his code seems to be doing what it is meant to be doing . . .
Reason: