Hi,

I dont like trail function. With this TMF function you can lock profit without laugh

Code
//--------------------- TMF --------------------------------------------------------
#define VAR_LOCK TradeVar[0]
#define VAR_ACTI TradeVar[1]
#define VAR_CLOSE TradeVar[2]

int myTMF(){
  if (TradeIsEntry){
    // only one each trade?
    VAR_LOCK=-1;  // No lock
    VAR_ACTI=1*TradeLots;          // 1 USD/per LOTS ... MT4 1=0.01
    VAR_CLOSE=VAR_ACTI*0.8;        // after profit is target, profit under 80% close trade
  }
  
  if(TradeIsOpen){
    if (TradeProfit > VAR_ACTI)
      VAR_LOCK=1.0; // activate trigger

    if (VAR_LOCK > 0 )
    if (TradeProfit < VAR_CLOSE){
      exitTrade(ThisTrade);
      return 16;
    }

    if (TradeProfit > VAR_ACTI*1.05){
      // Profit > ACTI+5%
      VAR_ACTI=TradeProfit;
      VAR_CLOSE=VAR_ACTI*0.8;
    }
  }    
  
  return 0;
}

Last edited by Grat; 07/14/19 15:54.