diff --git a/snippets/cat_algorithm/nth_fibonacci.md b/snippets/cat_algorithm/nth_fibonacci.md new file mode 100644 index 0000000..92d52d6 --- /dev/null +++ b/snippets/cat_algorithm/nth_fibonacci.md @@ -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: + + +```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..... + + + +```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) +``` + diff --git a/snippets/readme.md b/snippets/readme.md new file mode 100644 index 0000000..cd3e6db --- /dev/null +++ b/snippets/readme.md @@ -0,0 +1,56 @@ +# Snippets. + +## Code Snippets for Tradingview Pine Script language: +needs a small description here... + +
+ + Algorithms: + + #### 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) +
+ +
+ + Category A + + #### Category A Snippets + Perhaps a description is usefull.. + 1. Snippet A1 + 2. Snippet A2 family: + * Snippet A2.1 + * Snippet A2.2 + 3. Snippet A3 +
+ +
+ + Category B + + #### Category B Snippets + Perhaps a description is usefull.. + + *** + +
+ + Sub Category BA1 + + 1. Snippet SB1 + 2. Snippet SB2 family: + * Snippet SB2.1 + * Snippet SB2.2 + 3. Snippet SB3 +
+ + *** + + 1. Snippet B1 + 2. Snippet B2 + 3. Snippet B3 family: + * Snippet B3.1 + * Snippet B3.2 + 4. Snippet B3 +
diff --git a/snippets/template.md b/snippets/template.md new file mode 100644 index 0000000..b404cf4 --- /dev/null +++ b/snippets/template.md @@ -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: + + +```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 ... + + + +```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) +```