trader_bbands

(PECL trader >= 0.2.0)

trader_bbandsBollinger Bands

Description

array trader_bbands ( array $real [, integer $timePeriod [, float $nbDevUp [, float $nbDevDn [, integer $mAType ]]]] )

Parameters

real

Array of real values.

timePeriod

Number of period. Valid range from 2 to 100000.

nbDevUp

Deviation multiplier for upper band. Valid range from TRADER_REAL_MIN to TRADER_REAL_MAX.

nbDevDn

Deviation multiplier for lower band. Valid range from TRADER_REAL_MIN to TRADER_REAL_MAX.

mAType

Type of Moving Average. TRADER_MA_TYPE_* series of constants should be used.

Return Values

Returns an array with calculated data or false on failure.

Коментарии

<?php

// According to Wikipedia and the internet:
// Bollinger Bands chart the price and volatility of a financial instrument over time 
// and yield an "envelope" minimum and maximum and middle "bands" of moving averages
// which provide a relative definition of high and low market prices
// Prices are "high" at or near the upper band and "low" at or near the lower band. 
// Bollinger Bands are considered useful for pattern recognition

$closes = array(112.82117.32113.49112115.355115.54112.13110.34106.84110.08111.81107.12108.22112.28);
$time_period 5;
$upper_deviation_multiplier 2.0;
$lower_deviation_multiplier 2.0;

$ma_type TRADER_MA_TYPE_SMA// Simple Moving Average
           //TRADER_MA_TYPE_EMA   - Exponential Moving Average
           //TRADER_MA_TYPE_WMA   - Weighted Moving Average
           //TRADER_MA_TYPE_DEMA  - Double Exponential Moving Average 
           //TRADER_MA_TYPE_TEMA  - Triple Exponential Moving Average 
           //TRADER_MA_TYPE_TRIMA - Triangular Moving Average
           //TRADER_MA_TYPE_KAMA  - Kaufman's Adaptive Moving Average
           //TRADER_MA_TYPE_MAMA  - MESA Adaptive Moving Average
           //TRADER_MA_TYPE_T3)   - T3 Moving Average
                 

var_dump(trader_bbands($closes$time_period$upper_deviation_multiplier$lower_deviation_multiplier$ma_type));

// Index 0 is "upper" band.
// Index 1 is "middle" band.
// Index 2 is "lower" band.

/*
array(3) {
  [0]=>
  array(10) {
    [4]=>
    float(118.025)
    [5]=>
    float(118.401)
    [6]=>
    float(116.739)
    [7]=>
    float(117.153)
    [8]=>
    float(118.563)
    [9]=>
    float(116.676)
    [10]=>
    float(113.996)
    [11]=>
    float(113.114)
    [12]=>
    float(112.577)
    [13]=>
    float(113.892)
  }
  [1]=>
  array(10) {
    [4]=>
    float(114.197)
    [5]=>
    float(114.741)
    [6]=>
    float(113.703)
    [7]=>
    float(113.073)
    [8]=>
    float(112.041)
    [9]=>
    float(110.986)
    [10]=>
    float(110.24)
    [11]=>
    float(109.238)
    [12]=>
    float(108.814)
    [13]=>
    float(109.902)
  }
  [2]=>
  array(10) {
    [4]=>
    float(110.369)
    [5]=>
    float(111.081)
    [6]=>
    float(110.667)
    [7]=>
    float(108.993)
    [8]=>
    float(105.519)
    [9]=>
    float(105.296)
    [10]=>
    float(106.484)
    [11]=>
    float(105.362)
    [12]=>
    float(105.051)
    [13]=>
    float(105.912)
  }
}
*/
2021-02-17 22:33:22
http://php5.kiev.ua/manual/ru/function.trader-bbands.html

    Поддержать сайт на родительском проекте КГБ