-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 341f185
Showing
8 changed files
with
1,854 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# editorconfig.org | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
end_of_line = lf | ||
indent_size = 2 | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.{html,twig,md}] | ||
indent_size = 2 | ||
|
||
[*.php] | ||
charset = utf-8 | ||
indent_style = tab | ||
indent_size = 4 | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: Macd | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- uses: php-actions/composer@v1 | ||
- name: run tests | ||
run: vendor/bin/phpunit tests/* --testdox |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
vendor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Moving Average Convergence/Divergence | ||
|
||
Calculate the MACD of giving values. | ||
|
||
![Ema](https://github.com/romulodl/macd/workflows/Macd/badge.svg) | ||
|
||
## Instalation | ||
|
||
``` | ||
composer require romulodl/macd | ||
``` | ||
|
||
or add `romulodl/macd` to your `composer.json`. Please check the latest version in releases. | ||
|
||
## Usage | ||
|
||
```php | ||
$macd = new Romulodl\Macd(); | ||
$macd->calculate(array $values, array $previous_values = [], int $short_period = 12, int $long_period = 26); | ||
//returns a float value | ||
``` | ||
|
||
For example: | ||
```php | ||
$macd = new Romulodl\Macd(); | ||
$macd->calculate([10, 12, 14, 20, 14, 10, 11]); | ||
``` | ||
|
||
#### What is `$previous_values` for? | ||
|
||
The EMA calculation (used by the MACD) is based on the previous round of calculation. So the n round depends on n - 1 results. | ||
Then what is n - 1 for the first calculation? If `$previous_values` is not available, it uses a simple moving average | ||
for it. With `$previous_values` set, it will start the calculation of the EMA before and the result will be more | ||
accurate (at least closest to what Trading view shows.) | ||
|
||
It is recommended that you use the same ammount of `$values` and `$previous_values` for more accurate results. FOr example, send the previous 26 values when calculating a default MACD(12, 26). | ||
|
||
|
||
## Why did you do this? | ||
|
||
The PECL Trading extension is crap and not everyone wants to install it. | ||
I am building a trading bot and building more complex trading indicators that uses the MACD as a basic step. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"name": "romulodl/macd", | ||
"description": "MACD without the PECL trader extension", | ||
"license": "Apache-2.0", | ||
"require-dev": { | ||
"phpunit/phpunit": "^8.5" | ||
}, | ||
"authors": [ | ||
{ | ||
"name": "Romulo De Lazzari", | ||
"email": "romulodelazzari@gmail.com" | ||
} | ||
], | ||
"require": { | ||
"romulodl/ema": "^1.3" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Romulodl\\": "src/" | ||
} | ||
} | ||
} |
Oops, something went wrong.