open order depending current bid ak price

 

hi guys im triing to open orders if a spwcified prices between highs and lows is reached, but the ea does not open orders.

the findentry and buyconditionis called every tick, can someone help me to get this snall snippet working?

ist there maybe a problem with the speed of the whole program, i have lots of loops for eg takeprofit called in the startfunction.

void findentry()
{
barshigh =High[iHighest(NULL,Timeframe,MODE_HIGH,5,1)];
barslow =Low[iLowest(NULL,Timeframe,MODE_LOW,5,1)];
}
bool buycondition()
{
if(
  (NormalizeDouble(Bid,Digits) == NormalizeDouble((((barslow+barshigh/2)+barslow)/2),Digits)) &&
  (iADX(NULL,Timeframe,ADXPeriod,PRICE_MEDIAN,MODE_MAIN,1) < ADXLevel) && 
  (iADX(NULL,Timeframe,ADXPeriod,PRICE_MEDIAN,MODE_PLUSDI,1) > iADX(NULL,Timeframe,ADXPeriod,PRICE_MEDIAN,MODE_MINUSDI,1))
  )
  {
  return(true); 
  }
  return (false);
}
 
  NormalizeDouble((((barslow+barshigh/2)+barslow)/2),Digits)
Print this out and consider if Bid is ever going to equal the result
 
barshigh =High[iHighest(NULL,Timeframe,MODE_HIGH,5,1)];
You are mixing apples and oranges
 

thanks for your responses, i found the error,  @ gumrai thank you

my price calculation was completly wrong :/

this works now:

NormalizeDouble(((((barslow+barshigh)/2)+barslow)/2),Digits))


@ Whroeder

thanks for your link

concerning High and iHigh, i'm using an integer called Timeframe, that has the same value as the current open chart, its just to avoid attaching to wrong timeframes.

in my case these 2 conditions are equal when i print the values out. if i need the values from a higher timeframe i have to use iHigh.

barshigh =iHigh(NULL,Timeframe,iHighest(NULL,Timeframe,MODE_HIGH,5,1));

barshigh2 =High[iHighest(NULL,Timeframe,MODE_HIGH,5,1)];
Reason: