Return Starting Price of last order ??

 

Hello everybody,

I am trying to make my EA do a little hedgeing under certain conditions.

I have my buy orders happening at the correct time, I would like the EA to open sell orders when:

//Open Sell

if(Ask = Last Orders Start Price - 0.0025)

code code code...open sell (I have this part done).

Any suggestions ? I have tried to do it with ideas like: if( AccountProfit() <= AccountBalance-0.0025)

but sometimes this makes the sell orders happen above the buy orders.

Thank you all.

 
double GetLastOrderOpenPrice() 
{
   datetime time = 0;
   double price = 0;
   int index = 0;
  
   while (OrderSelect(index, SELECT_BY_POS, MODE_TRADES | MODE_HISTORY ))
   {
       if (time < OrderOpenTime())
       {
               time = OrderOpenTime();
       price = OrderOpenPrice();
   }
       index++;
   }
  
   return (price);
}


Reason: