Login Register






Thread Rating:
  • 0 Vote(s) - 0 Average


Trading Script: Divider MFT Persistent [PineScript, OpenSource] filter_list
Author
Message
Trading Script: Divider MFT Persistent [PineScript, OpenSource] #1
[Image: image-2023-12-31-004413652.png]

Divider MFT Persistent [Elysian_Mind]

Dear Esteemed Members,

You asked me to write this script. So, here it is. Sinisterly is the only place where I released this code. If you visit the TradingView page, you can see it's a private script. So, only people with the direct link can see, and consequentially, only people who read this thread. I hope you appreciate it.

OVERVIEW

The "Divider MFT Persistent" indicator, developed by Elysian_Mind, is a versatile TradingView script designed to visually represent separators for different time intervals on the chart. This script aids traders in customizing their trading week parameters, allowing for a more personalized analysis of price movements.

CHART EXPLANATION

The chart generated by the "Divider MFT Persistent" indicator offers a clear visual representation of the trading week, facilitating enhanced analysis.

Below are key features and their corresponding visual elements:

1. Day Separators:

White Vertical Lines: Each day of the week (Monday to Friday) is delineated by a white vertical line. These separators assist in easily identifying and distinguishing individual trading days.

2. Week Separators:

Blue Vertical Lines: Weekly divisions are denoted by blue vertical lines on the chart. The specified number of days in a trading week, adjustable using the weeksLength parameter, determines the placement of these lines.

3. Month Separators:

Purple Vertical Lines: Monthly divisions are represented by purple vertical lines. The background color changes on the first bar of each month, providing an additional visual cue for monthly transitions.

4. Customizable Parameters:
  • Colors: The color of each type of separator (daily, weekly, and monthly) can be personalized. For instance, white for days, blue for weeks, and purple for months.

  • Widths: Adjust the line widths according to preference using the lineWidth parameter.

  • Weekly Length: Tailor the trading week by setting the number of days with the weeksLength parameter.

  • Weekly Open Day: Define the starting day of the trading week using the weekOpenDay parameter.

  • Hour of the Day: Specify the hour at which the separators are displayed with the openHour parameter.

5. Day Names:

At the bottom of the chart, day names (Monday to Friday) are displayed, aiding in quick orientation.

By leveraging the flexibility of customizable parameters, traders can adapt the chart to their specific trading schedules and preferences, fostering a more personalized and efficient analysis of price movements. Customize line styles and widths to tailor the appearance of daily, weekly, and monthly separators. Adjust day name colors individually for each day of the week. The script dynamically plots vertical lines to represent daily, weekly, and monthly separators. Background color changes on the first bar of each month for improved visibility.

METHODS

Code Explanation

1. User Configuration Section

Code:
// User Configuration
openHour = 0
weeksLength = 5
weekOpenDay = 3
lineStyle = line.style_solid
lineWidth = 1
dailyDivCol = color.new(#FFFFFF, 0)
weeklyDivCol = color.new(#00aeff, 0)
monthlyDivCol = color.new(#590094, 0)
daySunNameColor = color.new(color.white, 0)
dayMonNameColor = color.new(color.white, 0)
dayTueNameColor = color.new(color.white, 0)
dayWedNameColor = color.new(color.white, 0)
dayThuNameColor = color.new(color.white, 0)
dayFriNameColor = color.new(color.white, 0)
daySatNameColor = color.new(color.white, 0)
displayedHour = input(openHour, "Display Hour")

The openHour, weeksLength, and weekOpenDay parameters allow users to define the starting hour, the number of days in the trading week, and the day when the week begins, respectively.

lineStyle and lineWidth: These parameters control the style and width of the separator lines.

Color Definitions: Colors for daily, weekly, and monthly separators, as well as day names, are defined using the color.new function.

displayedHour: User input for the hour to display separators.

2. Computations and Methods

Code:
var float lastDay = na
var int separatorCount = 0
do_plot = hour(time) == displayedHour and minute(time) == 0 and dayofweek != lastDay

lastDay and separatorCount: Variables to store the last day of the week and count the separators.

do_plot: Condition to determine whether to plot separators at the specified hour and on a new day.

Code:
isSeventhSeparator() =>
    separatorCount % weeksLength == weekOpenDay

isSeventhSeparator Function: Checks if the separator is the seventh one, representing the beginning of a new trading week.

Code:
vline(BarIndex, Color, LineStyle, LineWidth) =>
    line.new(BarIndex, low - ta.tr, BarIndex, high + ta.tr, xloc.bar_index, extend.both, Color, LineStyle, LineWidth)

vline Function: Defines a function to create a vertical line on the chart.

Code:
lineColor = do_plot ? (isSeventhSeparator() ? weeklyDivCol : dailyDivCol) : na
if do_plot
    lineObj = vline(bar_index, lineColor, lineStyle, lineWidth)


lineColor: Determines the color of the separator based on whether it's a daily or weekly separator.

Separator Plotting: If conditions for plotting are met, a vertical line is plotted using the vline function.

Code:
lastDay := dayofweek
separatorCount := do_plot ? separatorCount + 1 : separatorCount

Update Variables: Updates the last day and increments the separator count if conditions for plotting are met.

Code:
isFirstCandleOfMonth() =>
    month != month[1]

isFirstCandleOfMonth Function: Checks if a bar is the first bar of the month.

Code:
bgcolor(isFirstCandleOfMonth() ? monthlyDivCol : na)

Background Color: Sets the background color conditionally based on whether it's the first bar of the month.

3. Closing Price Plot

Code:
plot(close, title="Close", color=color.rgb(33, 149, 243, 100), linewidth=2)

Closing Price Plot: Plots the closing price for reference, with customizable color and width.

4. Day Names Display

Code:
plotchar(hour == 12 and minute == 0 and dayofweek == dayofweek.sunday, text='Sunday', char = ".", color=daySunNameColor, location=location.bottom, offset=0)
plotchar(hour == 12 and minute == 0 and dayofweek == dayofweek.monday, text='Monday', char = ".", color=dayMonNameColor, location=location.bottom, offset=0)
plotchar(hour == 12 and minute == 0 and dayofweek == dayofweek.tuesday, text='Tuesday', char = ".", color=dayTueNameColor, location=location.bottom, offset=0)
plotchar(hour == 12 and minute == 0 and dayofweek == dayofweek.wednesday, text='Wednesday', char = ".", color=dayWedNameColor, location=location.bottom, offset=0)
plotchar(hour == 12 and minute == 0 and dayofweek == dayofweek.thursday, text='Thursday', char = ".", color=dayThuNameColor, location=location.bottom, offset=0)
plotchar(hour == 12 and minute == 0 and dayofweek == dayofweek.friday, text='Friday', char = ".", color=dayFriNameColor, location=location.bottom, offset=0)
plotchar(hour == 12 and minute == 0 and dayofweek == dayofweek.saturday, text='Saturday', char = ".", color=daySatNameColor, location=location.bottom, offset=0)

Day Names Display: Uses plotchar to display day names at the bottom of the chart based on the specified conditions.

AUTHOR'S COMMENTS

Mozilla Public License 2.0: The script is subject to the terms of the Mozilla Public License 2.0, available at mozilla.org/MPL/2.0.

Author: Developed by Elysian_Mind.

DISCLAIMER

This script is provided for informational purposes only and does not constitute financial advice. Users are encouraged to conduct their own research and analysis before making trading decisions.




RELATED INDICATORS

If you like, check out my Sinisterly trading scripts:

Trading Script: Adaptive MFT Extremum Pivots [PineScript, OpenSource]
The Adaptive MFT Extremum Pivots indicator, developed by Elysian_Mind (me), is a powerful Pine Script tool that dynamically displays key market levels, including Monthly Highs/Lows, Weekly Extremums, Pivot Points, and dynamic Resistances/Supports. The term "dynamic" emphasizes the adaptive nature of the calculated levels, ensuring they reflect real-time market conditions
https://sinister.ly/Thread-Trading-Scrip...OpenSource

Trading Script: Advanced Dynamic Threshold RSI Indicator [PineScript, OpenSource]
The Advanced Dynamic Threshold RSI Indicator is a powerful tool designed for traders seeking a unique approach to RSI-based signals. This indicator combines traditional RSI analysis with dynamic threshold calculation and optional Bollinger Bands to generate weighted buy and sell signals.
https://sinister.ly/Thread-Trading-Scrip...OpenSource

Kind regards,
Ely
(This post was last modified: 12-31-2023, 12:58 AM by ElysianSignals. Edit Reason: Added related indicators )

Reply







Users browsing this thread: 1 Guest(s)