Could anyone help me to have a look what is the problem of my "candle long shadow" code?

 

i tried to code a function to see if there is a bullish candlestick with long shadow/wick, but when i backtested it, there are many trades happen in candlestick without long shadow/wick. i double check my function, i really could see any problem, could someone help? thank a lot.

input double b_shad_percentage = 0.3;  

bool buy_shadow()
  {
   bool b_shadow=false;
   double B_P_open = iOpen(NULL,0, 1);
   double B_P_high = iHigh(NULL, 0, 1);
   double B_P_low = iLow(NULL, 0, 1);
   double B_P_close = iClose(NULL, 0, 1);

   double B_P_range = B_P_high - B_P_low;
   double B_P_percent = B_P_range * b_shad_percentage;
   double B_P_level = B_P_high - B_P_percent; 
   

   if (B_P_close >= B_P_level && B_P_close >= B_P_open)      {
      b_shadow=true;
     }
   else
     {
      b_shadow=false;
     }
   return (b_shadow);
  }
 
  1. gogoknow: i really could see any problem, could someone help?

    Use the debugger or print out your variables, including _LastError and prices and find out why. Do you really expect us to debug your code for you?

  2. Your code
       if (B_P_close >= B_P_level && B_P_close >= B_P_open)      {
          b_shadow=true;
         }
       else
         {
          b_shadow=false;
         }
       return (b_shadow);
    simplified
       return B_P_close >= B_P_level && B_P_close >= B_P_open;

Reason: