if ($newTrade['is_live'] == 1) {
             //if trade is live
             sendMail('[Bitfinex] Buy ' . $tradeAmt . ' ' . $currency . ' at ' . $latestPrice);
             update_last_action($last_action_data);
             //update the last action
             $output .= '[ buy ]' . $newline;
             $output .= array_debug($newTrade) . $newline;
         }
     } else {
         //no balance left to trade
         $output .= ' no balance to trade ';
     }
     //if active postion - claim short/long margin position
     if ($position['amount'] < 0 && $position['status'] == 'ACTIVE') {
         $data['position_id'] = $position_id;
         $claimPos = $bitfinexAPI->claim_positions($data);
         //close short position
         echo $newline . $claimPos['message'] . $newline;
     }
 }
 //stop loss
 if ($latestPrice > $ma_30) {
     //stop loss (long pos) is 2% below ATH
     $stopHigh = $ATH - $ATH * 0.02;
     $output .= $newline . 'ATH: ' . number_format($ATH, 4) . ' | stop loss: ' . number_format($stopHigh, 4) . ' | ';
     if ($latestPrice <= $stopHigh) {
         $output .= ' stop loss exit';
         if ($debug != 1 && $bitfinex_trading == 1) {
             $data['position_id'] = $position_id;
             $claimPos = $bitfinexAPI->claim_positions($data);
             echo $newline . $claimPos['message'] . $newline;