Skip to content
45 changes: 45 additions & 0 deletions snippets/cat_algorithm/nth_fibonacci.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Function to find Nth fibonacci

#### Snippet Description:

Function to find the sequence value of the Nth fibonacci number.

references:
* [link1](https://www.geeksforgeeks.org/program-for-nth-fibonacci-number/ "Multiple Methods:")


#### Code:
<!-- -->
<!-- code goes between the backticks: -->
```javascript
//-----------------
//Binet's Formula to solve the Nth Fibonacci Number
f_n_fib(_step) =>
_phi = 1.618
_n_phi = 1/_phi
_return = round(_step >= 0 ? pow(_phi, _step) / sqrt(5) : pow(-_n_phi, _step) / sqrt(5))
//-----------------
```


#### Example:

in the next code it uses the function to do something with it.....

<!-- -->
<!-- code goes between the backticks: -->
```javascript
//@version=4
study(title="how to use the function:")

//-----------------
//Binet's Formula to solve the Nth Fibonacci Number
f_n_fib(_step) =>
_phi = 1.618
_n_phi = 1/_phi
_return = round(_step >= 0 ? pow(_phi, _step) / sqrt(5) : pow(-_n_phi, _step) / sqrt(5))
//-----------------

plot(close)
```

56 changes: 56 additions & 0 deletions snippets/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Snippets.

## Code Snippets for Tradingview Pine Script language:
needs a small description here...

<details open>
<!-- leave a blank line after summary -->
<summary>Algorithms:</summary>

#### Algorithms:
Multiple use algorithms:
* [Nth Fibonacci](https://github.com/ricardosantos79/pine-utils/blob/master/snippets/cat_algorithm/nth_fibonacci.md#function-to-find-nth-fibonacci)
</details>

<details open>
<!-- leave a blank line after summary -->
<summary>Category A</summary>

#### Category A Snippets
Perhaps a description is usefull..
1. Snippet A1
2. Snippet A2 family:
* Snippet A2.1
* Snippet A2.2
3. Snippet A3
</details>

<details>
<!-- leave a blank line after summary -->
<summary>Category B</summary>

#### Category B Snippets
Perhaps a description is usefull..

***

<details>
<!-- leave a blank line after summary -->
<summary>Sub Category BA1</summary>

1. Snippet SB1
2. Snippet SB2 family:
* Snippet SB2.1
* Snippet SB2.2
3. Snippet SB3
</details>

***

1. Snippet B1
2. Snippet B2
3. Snippet B3 family:
* Snippet B3.1
* Snippet B3.2
4. Snippet B3
</details>
52 changes: 52 additions & 0 deletions snippets/template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Template Snippet name

#### Snippet Description:

Description text o Lorem Ipsum é um texto modelo da indústria tipográfica e de impressão. O Lorem Ipsum tem vindo a ser o texto padrão usado por estas indústrias desde o ano de 1500, quando uma misturou os caracteres de um texto para criar um espécime de livro. Este texto não só sobreviveu 5 séculos, mas também o salto para a tipografia electrónica, mantendo-se essencialmente inalterada. Foi popularizada nos anos 60 com a disponibilização das folhas de Letraset, que continham passagens com Lorem Ipsum, e mais recentemente com os programas de publicação como o Aldus PageMaker que incluem versões do Lorem Ipsum.


#### Code:
<!-- -->
<!-- code goes between the backticks: -->
```javascript
//@version=4
study(title="this is a script example")
bool something = true
string some_text = ""

if something
some_text := "O Lorem Ipsum é um texto modelo da indústria tipográfica e de impressão."
else
some_text := ""

var label la = na
label.delete(la)
la := label.new(x=time, y=open, text=some_text)
```


#### Example:

description text of the example, la lala lalaal ...
description text of the example, la lala lalaal ...
description text of the example, la lala lalaal ...
description text of the example, la lala lalaal ...
description text of the example, la lala lalaal ...

<!-- -->
<!-- code goes between the backticks: -->
```javascript
//@version=4
study(title="this is a script example")
bool something = true
string some_text = ""

if something
some_text := "O Lorem Ipsum é um texto modelo da indústria tipográfica e de impressão."
else
some_text := ""

var label la = na
label.delete(la)
la := label.new(x=time, y=open, text=some_text)
```