TakeProfit is Disappearing! Help me solve this mystery! Please!

 

First time poster.

Behold my trailing stop function. It moves my SL by 10. It also moves my TP by 10 as well, which is a lot better than it completely being removed if I add a 0 on the end at the:

Bid-takeProfit* _Point);

location.


QUESTION: How do I not move my TP. I looked everywhere for an answer and couldnt find it. Find attached function below.

 void bearishTrailingStop(double Bid)
  {
   double SL=NormalizeDouble(Bid+stopLoss*_Point,_Digits);
   for(int i=PositionsTotal()-1; i>=0; i--)
   {
      string symbol = PositionGetSymbol(i);
   
   
      if(_Symbol == symbol)
      {
         ulong PositionTicket = PositionGetInteger(POSITION_TICKET);
         double CurrentStopLoss=PositionGetDouble(POSITION_SL);
         
         
         if(CurrentStopLoss>SL)
         {
            trade.PositionModify(PositionTicket,(CurrentStopLoss-20*_Point),Bid-takeProfit* _Point);
            
         }
  
      } 
    } 
  }

Will provide more if necessary.

 
   double currentTakeProfit = PositionGetDouble(POSITION_TP);
   if(currentTakeProfit == 0) {
      // set initial take profit here
      currentTakeProfit = ...;
   }

         if(CurrentStopLoss>SL)
         {
            trade.PositionModify(PositionTicket,(CurrentStopLoss-20*_Point),currentTakeProfit);
            
         }
Note by convention local scope variables start with lower case.
 
lippmaje:
Note by convention local scope variables start with lower case.
CHAMPION. Thanks heaps!
Reason: