SHARE
TWEET

RSI PHP

kinhoSilva Mar 24th, 2019 (edited) 242 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. /**
  3. * RSI PHP
  4. */
  5. $start = time() - 4550;
  6. $end = time();
  7.  
  8. $file_ = file_get_contents("https://poloniex.com/public?command=returnChartData&currencyPair=BTC_ZEC&start=$start&end=$end&period=300");
  9.  
  10. //var_dump($file_);
  11. $array_file = json_decode($file_, true);
  12.  
  13. //krsort($array_file);
  14. $array_close = [];
  15. foreach ($array_file as $value) {
  16.  
  17.     $array_close[] = $value['close'];
  18. }
  19.  
  20. $array_ganho = [];
  21. $array_perda = [];
  22.  
  23. //var_dump(ksort($array_close));
  24.  
  25. for($i=0; $i < count($array_close); $i++){
  26.     if(!array_key_exists($i+1 , $array_close)){
  27.         break;
  28.     }else{
  29.         $variacao = (double)$array_close[$i] - (double)$array_close[$i+1];
  30.     }
  31.     if($variacao < 0){
  32.         $array_ganho[] = abs($variacao);
  33.     }else{
  34.         $array_perda[] = abs($variacao);
  35.     }
  36. }
  37.  
  38.  
  39. $forca_r = array_sum($array_ganho) / array_sum($array_perda);
  40.  
  41. $indice_r_f = 100 - (100 / (1 + $forca_r));
  42.  
  43. var_dump($indice_r_f);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top