Fibonacci Stoploss and takeprofit

 

Hello.. good day..

please is something wrong with my codes..

am trying to code EA to identify Fibonacci levels that are manually plotted from

insert>Fibonacci>Retracement..

The EA is not placing the stoploss and takeprofit!! at those levels..

the entry signals are wrong.. my entry signal

The First candle needs to be outside of the bollinger band and then the second candle needs to be higher than the first candle.

entry once crossed below

this is example of a sell


finding first candle that crossed the BB must be Lower than upper candle

The entry point is only entered if the second candle closes inside of the bollinger band and the target is the 50% Fib level.

is this code correct to get the previous closed High[1]

if(High[1]>upband)d=true;
if(Close[2]>upband)e=true;
if(d>e)f=true;
double upband=iBands(NULL, PERIOD_CURRENT, BB_Period,BB_Deviation,0,PRICE_CLOSE,MODE_UPPER,0);  
double dnband=iBands(NULL, PERIOD_CURRENT, BB_Period, BB_Deviation,0,PRICE_CLOSE,MODE_LOWER,0);  
   //Open Buy Order, instant signal is tested first
double a=false,b=false,c=false,d=false,e=false,f=false,g=false;
double SL,TP;
 // if(kinjunc < senkouA && kinjunc < senkouB)ab1=true;
 
bool ab1=false,ab2=false,bs1=false,bs2=false;
if(High[1]>dnband)a=false;else a=true;
if(Close[2]>dnband)b=false;else b=true;
if(a<b)c=true;

if(High[1]>upband)d=true;
if(Close[2]>upband)e=true;
if(d>e)f=true;

if(High[1]>Close[2])f=true;
if(e==true && f==true)g=true;

  if(c==true && Cross(0, Open[0] > dnband))
     {
      RefreshRates();
      price = Ask;   
       SL = FindFib("0.0",4);
       TP = FindFib("50",4);
      if(IsTradeAllowed())
        {
         ticket = sendmeorder(OP_BUY, price,SL,TP, FixedLot, "");
         closeorder(OP_SELL, 100,"");
         if(ticket <= 0) return;
        }
      else //not autotrading => only send alert
         myAlert("order", "");
     }
double FindFib(string tp_name, int dig)
{
   double tp1 = 0.0;
   for(int i_label = 0; i_label < ObjectsTotal(OBJ_LABEL); i_label++)
   {
      string n = ObjectName(ChartID(), i_label, -1, OBJ_LABEL);
      string v = ObjectGetString(ChartID(), n, OBJPROP_TEXT);
      int ftp1 =StringFind(v, tp_name);
      if(ftp1 != -1)
      {
         tp1 = StringToDouble(StringSubstr(v, ftp1+StringLen(tp_name)+1, dig));
         if(tp1 != 0.0)
            break;
      }  
   }
   return tp1;
}


What am i doing wrong

 

Do not complicate things. Just calculate the Fibo prices

Suppose the price rises from $10 to $15, and these two price levels are the points used to draw the retracement indicator. Then, the 23.6% level will be at $13.82 ($15 - ($5 x 0.236) = $13.82). The 50% level will be at $12.50 ($15 - ($5 x 0.5) = $12.50).