_Implement BreakEven

 

Hello,

 

how to implement a working Break Even?

 

i was thinking, i use the Bid and the Ask price, compare that with the Order Open Price and finished

 

void OnTick()
  {
   if(PositionSelect(_Symbol))
     {

     
      if(PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_BUY 
      && PositionGetDouble(POSITION_PRICE_OPEN) < Bid+BreakEven*_Point
      && PositionGetDouble(POSITION_PRICE_OPEN)!=PositionGetDouble(POSITION_SL) 
      && PositionGetDouble(POSITION_SL)<PositionGetDouble(POSITION_PRICE_OPEN))
        {

         PositionModify(_Symbol,PositionGetDouble(POSITION_PRICE_OPEN),PositionGetDouble(POSITION_TP));
         Print("Test");
       //  Print("BuyModify: ",PositionGetDouble(POSITION_PRICE_OPEN)," Ask: ",Ask," SL: ",PositionGetDouble(POSITION_PRICE_OPEN));
        }
        
  
      if(PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_SELL 
           &&   PositionGetDouble(POSITION_PRICE_OPEN) > Bid+BreakEven*_Point
           && PositionGetDouble(POSITION_PRICE_OPEN)!=PositionGetDouble(POSITION_SL) 
           && PositionGetDouble(POSITION_SL)>PositionGetDouble(POSITION_PRICE_OPEN)
           )
        {
         PositionModify(_Symbol,PositionGetDouble(POSITION_PRICE_OPEN),PositionGetDouble(POSITION_TP));
   
         Print("SellModify"," Bid: ",Bid," BreakEven*Point: ",BreakEven*_Point," Bid + BE*Point: ",Bid+BreakEven*_Point);

        }

 

 for PositionModify i use 

 

 

bool PositionModify(const string symbol,const double sl,const double tp)
  {

   MqlTradeRequest m_request = {0};
   MqlTradeResult result;

//--- setting request
   
   m_request.action=TRADE_ACTION_SLTP;
   m_request.symbol=symbol;
   m_request.sl    = sl;
   m_request.tp    = tp;
//--- action and return the result
   return(OrderSendAsync(m_request,result));
  }

 

Ask and Bid

double Ask = SymbolInfoDouble(_Symbol,SYMBOL_ASK);
double Bid = SymbolInfoDouble(_Symbol,SYMBOL_BID);

 

 but why is this code not working?

what is wrong in the comparison between OrderOpen and Bid/Ask?

 

 

can someone be so kind and help?

 

amando