Why EA is not open buy order when price was hit the set point? (EA Beginner)

konbalove  

Good Morning, I am the new one for EA coding. My expectation is "EA should open "ONLY BUY ORDER" when the graph was crossing the red line. My problem is "Sometime when the price was hit the red line, EA can open Buy Order. Buy, Sometime EA is not open buy when the price was hit the read line as you can see in the picture.

Please kindly help to solve this problem or explain the reason behind this problem. Thank you so much


void OnTick()
  {

double PriceAsk = MarketInfo(Symbol(), MODE_ASK);
double PriceBid = MarketInfo(Symbol(), MODE_BID);
Comment(StringFormat("PriceAsk + %G\n",PriceAsk));

if ((PriceBid == 1.15758)||(PriceAsk == 1.15758)) {
OrderSend(Symbol(),OP_BUY,0.01,Ask,0,0,price_grid[1],"Slopeup",0,0,Green);
}
else if ((PriceBid == 1.17334)||(PriceAsk == 1.17334)){
OrderSend(Symbol(),OP_BUY,0.01,Ask,0,0,price_grid[2],"Slopeup",0,0,Green);
}
else if ((PriceBid == 1.18910)||(PriceAsk == 1.18910)){
OrderSend(Symbol(),OP_BUY,0.01,Ask,0,0,price_grid[3],"Slopeup",0,0,Green);
}
else if ((PriceBid == 1.20486)||(PriceAsk == 1.20486)){
OrderSend(Symbol(),OP_BUY,0.01,Ask,0,0,price_grid[4],"Slopeup",0,0,Green);
}
else if ((PriceBid == 1.22062)||(PriceAsk == 1.22062)){
OrderSend(Symbol(),OP_BUY,0.01,Ask,0,0,price_grid[5],"Slopeup",0,0,Green);
}
else if ((PriceBid == 1.23638)||(PriceBid == 1.23638)){
OrderSend(Symbol(),OP_BUY,0.01,Ask,0,0,price_grid[6],"Slopeup",0,0,Green);
}
}
Files:
EA.PNG  68 kb