How to use iHigh and iLow for StopLoss?

 

I want to use high/ low of previous bar for SL.

Right now I have it set at static value in extern int. 

I want to add sl = iHigh(NULL,0,1) and I understand that the change needs to come after order send, but whatever I try it will compile with no errors but not run properly on backtester...

Please see my code for sell signal, any suggestions or advice much appreciated! :)

void Sell(string comm)
  {
      double op=0,sl=0,tp=0; 
      op = NormalizeDouble(Bid,Digits);   
      //CalcLot();
      Print("Putting SELL-order (v=" + DoubleToStr(Lots, 2) +"), OP=" + DoubleToStr(op,Digits) +"; SL=" + DoubleToStr(sl,Digits) + "; TP=" + DoubleToStr(tp,Digits));
      if (AccountFreeMarginCheck(Symbol(),OP_SELL,Lots)<=0 || GetLastError()==134) 
      {
        Print("Not enough free money to open SELL order, Lot size: " + DoubleToStr(Lots,2));
        return;
      }  
      int Ticket = OrderSend(Symbol(), OP_SELL, Lots, op, Slippage, 0, 0, comm, Magic, 0 ,Red); 
      if (PrintError(329)==0)
      {
        //SendMail("Sapsan " + AccountNumber() + " " + Symbol(),"New SELL-order #"+Ticket+" was opened; Equity=" + DoubleToStr(AccountEquity(),0));
        if (OrderSelect( Ticket, SELECT_BY_TICKET)==false) return;
        op = NormalizeDouble(OrderOpenPrice(),Digits);          
        tp = NormalizeDouble(op - (TakeProfit)*Point,Digits);   
        if (TakeProfit==0) tp=0;   
        sl = NormalizeDouble(op + (StopLoss)*Point,Digits);                              
        if (StopLoss==0) sl=0;
        if (sl!=0 || tp!=0) 
        {
          Print("Modify SELL-order #" + IntegerToString(Ticket));
          if (OrderModify( Ticket, op, sl, tp, 0, Yellow)==false)
            PrintError(340);                                               
        }  
      }            
  }  
Reason: