OPEN-SOURCE SCRIPT

@tk · fractal emas

█  OVERVIEW


This script is an indicator that plots short, medium and long moving averages for multiple fractals. This script was based on sharks EMAs by rlvs indicator, that plots multiple rays for each fractals into the chart. The main feature of this indicator is the customizability. The calculation itself is simple as moving average.


█  MOTIVATION


The trader can customize all aspects of the plotted data. The text size, extended line length, the moving average type — exponential, simple, etc... — the length of fractal rays, line style, line width and visibility. To keep minimalist, this indicator simplifies the logic of line colors based on the purpose of each moving averages. To prevent overnoise the chart with multiple lines with multiple colors for each fractal timefraes, the trader needs to keep in mind that the all lines with the "short" moving average color for example, will represents the short moving averages lines for all fractals. This logic is applied for medium and long moving averages either.


█  CONCEPT


The trading concept to use this indicator is to make entries on uptrend or downtrend pullbacks when the asset price reaches the short, medium or long moving averages price levels. But this strategy don't works alone. It needs to be aligned together with others indicators like RSI, Chart Patterns, Support and Resistance, and so on... Even more confluences that you have, bigger are your chances to increase the probability for a successful trade. So, don't use this indicator alone. Compose a trading strategy and use it to improve your analysis.


█  CUSTOMIZATION


This indicator allows the trader to customize the following settings:

GENERAL

Text size
Changes the font size of the labels to improve accessibility.
Type: string
Options: `tiny`, `small`, `normal`, `large`.
Default: `small`

SHORT

Type
Select the Short Moving Average calculation type.
Type: string
Options: `EMA`, `SMA`, `HMA`, `VWMA`, `WMA`.
Default: `EMA`

Length
Changes the base length for the Short Moving Average calculation.
Type: int
Default: 12

Source
Changes the base source for the Short Moving Average calculation.
Type: float
Default: close

Color
The base color that will represent the Short Moving Average.
Type: color
Default: color.rgb(255, 235, 59) (yellow)

Fractal Style
The fractal ray line style.
Type: string
Options: `dotted`, `dashed`, `solid`.
Default: `dotted`

Fractal Width
The fractal ray line width.
Type: string
Options: `1px`, `2px`, `3px`, `4px`.
Default: `1px`

Fractal Ray Length
The fractal ray line length.
Type: int
Default: 12

MEDIUM

Type
Select the Medium Moving Average calculation type.
Type: string
Options: `EMA`, `SMA`, `HMA`, `VWMA`, `WMA`.
Default: `EMA`

Length
Changes the base length for the Medium Moving Average calculation.
Type: int
Default: 26

Source
Changes the base source for the Medium Moving Average calculation.
Type: float
Default: close

Color
The base color that will represent the Short Moving Average.
Type: color
Default: color.rgb(0, 230, 118) (lime)

Fractal Style
The fractal ray line style.
Type: string
Options: `dotted`, `dashed`, `solid`.
Default: `dotted`

Fractal Width
The fractal ray line width.
Type: string
Options: `1px`, `2px`, `3px`, `4px`.
Default: `1px`

Fractal Ray Length
The fractal ray line length.
Type: int
Default: 12

LONG

Type
Select the Long Moving Average calculation type.
Type: string
Options: `EMA`, `SMA`, `HMA`, `VWMA`, `WMA`.
Default: `EMA`

Length
Changes the base length for the Long Moving Average calculation.
Type: int
Default: 200

Source
Changes the base source for the Long Moving Average calculation.
Type: float
Default: close

Color
The base color that will represent the Short Moving Average.
Type: color
Default: color.rgb(255, 82, 82) (red)

Fractal Style
The fractal ray line style.
Type: string
Options: `dotted`, `dashed`, `solid`.
Default: `dotted`

Fractal Width
The fractal ray line width.
Type: string
Options: `1px`, `2px`, `3px`, `4px`.
Default: `1px`

Fractal Ray Length
The fractal ray line length.
Type: int
Default: 12

VISIBILITY

Show Fractal Rays · (Short)
Shows short moving average fractal rays.
Type: bool
Default: true

Show Fractal Rays · (Medium)
Shows short moving average fractal rays.
Type: bool
Default: true

Show Fractal Rays · (Long)
Shows short moving average fractal rays.
Type: bool
Default: true


█  FUNCTIONS


The script contains the following functions:


`fn_labelizeTimeFrame`
Labelize timeframe period in minutes and hours.
Parameters:
tf: (string) Timeframe period to be labelized.
Returns: (string) Labelized timeframe string.


`fn_builtInLineStyle`
Converts simple string to built-in line style variable value.
Parameters:
lineStyle: (string) The line style simple string.
Returns: (string) Built-in line style string value.


`fn_builtInLineWidth`
Converts simple pixel string to line width number value.
Parameters:
lineWidth: (string) The line width pixel simple string.
Returns: (string) Built-in line width number value.


`fn_requestFractal`
Requests fractal data based on `period` given an expression.
Parameters:
period: (string) The period timeframe of fractal.
expression: (series float) The expression to retrieve data from fractal.
Returns: (mixed) A result determined by `expression`.


`fn_plotRay`
Plots line after chart bars.
Parameters:
y: (float) Y axis line position.
label: (string) Label to be ploted after line.
color: (color) Line and label color.
length: (int) Line length.
show: (bool) Flag to display the line. (default: `true`)
lineStyle: (string) Line style to be applied. (default: `line.style_dotted`)
lineWidth: (int) Line width. (default: `1`)
Returns: void


`fn_plotEmaRay`
Plots moving average line for a specific period.
Parameters:
period: (simple string) Period of fractal to retrieve
expression: (series float) The expression to retrieve data from fractal.
color: (color) Line and label color.
length: (int) Line length. (default: `12`)
show: (bool) Flag to display the line. (default: `true`)
lineStyle: (string) Line style to be applied. (default: `line.style_dotted`)
lineWidth: (string) Line width. (default: `1px`)
Returns: void


`fn_plotExtendedEmaRay`
Draws extended line for current timeframe moving average.
Parameters:
coordY: (float) Extended line Y axis position.
textValue: (simple string) Extended line label text.
textColor: (color) Extended line text color.
length: (int) Extended length. (default: `5`)
Returns: void
cryptocustomizablefractalesmoving_averageMoving AveragesmultiplemovingaveragemultipletimeframemultitimeframeTK

オープンソーススクリプト

TradingViewの精神に則り、このスクリプトの作者は、トレーダーが理解し検証できるようにオープンソースで公開しています。作者に敬意を表します!無料で使用することができますが、このコードを投稿で再利用するには、ハウスルールに準拠する必要があります。 お気に入りに登録してチャート上でご利用頂けます。

チャートでこのスクリプトを利用したいですか?

免責事項