signalLib_yashgode9Signal Generation Library = "signalLib_yashgode9"
This library, named "signalLib_yashgode9", is designed to generate buy and sell signals based on the price action of a financial instrument. It utilizes various technical indicators and parameters to determine the market direction and provide actionable signals for traders.
Key Features:-
1.Trend Direction Identification: The library calculates the trend direction by comparing the number of bars since the highest and lowest prices within a specified depth. This allows the library to determine the overall market direction, whether it's bullish or bearish.
2.Dynamic Price Tracking: The library maintains two chart points, zee1 and zee2, which dynamically track the price levels based on the identified market direction. These points serve as reference levels for generating buy and sell signals.
3.Customizable Parameters: The library allows users to adjust several parameters, including the depth of the price analysis, the deviation threshold, and the number of bars to consider for the trend direction. This flexibility enables users to fine-tune the library's behavior to suit their trading strategies.
4.Visual Representation: The library provides a visual representation of the buy and sell signals by drawing a line between the zee1 and zee2 chart points. The line's color changes based on the identified market direction, with red indicating a bearish signal and green indicating a bullish signal.
Usage and Integration:
To use this library, you can call the "signalLib_yashgode9" function and pass in the necessary parameters, such as the lower and higher prices, the depth of the analysis, the deviation threshold, and the number of bars to consider for the trend direction. The function will return the direction of the market (1 for bullish, -1 for bearish), as well as the zee1 and zee2 chart points.You can then use these values to generate buy and sell signals in your trading strategy. For example, you could use the direction value to determine when to enter or exit a trade, and the zee1 and zee2 chart points to set stop-loss or take-profit levels.
Potential Use Cases:
This library can be particularly useful for traders who:
1.Trend-following Strategies: The library's ability to identify the market direction can be beneficial for traders who employ trend-following strategies, as it can help them identify the dominant trend and time their entries and exits accordingly.
2.Swing Trading: The dynamic price tracking provided by the zee1 and zee2 chart points can be useful for swing traders, who aim to capture medium-term price movements.
3.Automated Trading Systems: The library's functionality can be integrated into automated trading systems, allowing for the development of more sophisticated and rule-based trading strategies.
4.Educational Purposes: The library can also be used for educational purposes, as it provides a clear and concise way to demonstrate the application of technical analysis concepts in a trading context.
Important Notice:- This library effectively work on timeframe of 5-minute and 15-minute.
Zigzaglibrary
ZigLibLibrary "ZigLib"
Calculate the points for ZigZag++.
You can use custom data and resolution for your ZigZag++.
Sample Usage
import DevLucem/ZigLib/1 as ZigZag
= ZigZag.zigzag(low, high)
bgcolor(direction<0? color.rgb(255, 82, 82, 80): color.rgb(0, 230, 119, 80))
line zz = line.new(z1.time, z1.price, z2.time, z2.price, xloc.bar_time, width=3)
if direction==direction
line.delete(zz )
zigzag(_low, _high, depth, deviation, backstep)
Get current zigzag points and direction
Parameters:
_low (float)
_high (float)
depth (int)
deviation (int)
backstep (int)
Returns direction, chart point 1 and chart point 2
zigzagplusThis is same as existing zigzag library with respect to functionality. But, there is a small update with respect to how arrays are used internally. This also leads to issues with backward compatibility. Hence I decided to make this as new library instead of updating the older one.
Below are the major changes:
Earlier version uses array.unshift for adding new elements and array.pop for removing old elements. But, since array.unshift is considerably slower than alternative method array.push. Hence, this library makes use of array.push method to achieve performance.
While array.push increases the performance significantly, there is also an issue with removing as we no longer will be able to remove the element using pop which is again faster than shift (which need to shit all the elements by index). Hence, have removed the logic of removing elements for zigzag pivots after certain limit. Will think further about it once I find better alternative of handling it.
These implementation change also mean that zigzag pivots received by calling method will be ordered in reverse direction. Latest pivots will be stored with higher array index whereas older pivots are stored with lower array index. This is also the reason why backward compatibility is not achievable with this code change.
Library "zigzagplus"
Library dedicated to zigzags and related indicators
zigzag(length, useAlternativeSource, source, oscillatorSource, directionBias) zigzag: Calculates zigzag pivots and generates an array
Parameters:
length : : Zigzag Length
useAlternativeSource : : If set uses the source for genrating zigzag. Default is false
source : : Alternative source used only if useAlternativeSource is set to true. Default is close
oscillatorSource : : Oscillator source for calculating divergence
directionBias : : Direction bias for calculating divergence
Returns: zigzagpivots : Array containing zigzag pivots
zigzagpivotbars : Array containing zigzag pivot bars
zigzagpivotdirs : Array containing zigzag pivot directions (Lower High : 1, Higher High : 2, Lower Low : -2 and Higher Low : -1)
zigzagpivotratios : Array containing zigzag retracement ratios for each pivot
zigzagoscillators : Array of oscillator values at pivots. Will have valid values only if valid oscillatorSource is provided as per input.
zigzagoscillatordirs: Array of oscillator directions (HH, HL, LH, LL) at pivots. Will have valid values only if valid oscillatorSource is provided as per input.
zigzagtrendbias : Array of trend bias at pivots. Will have valid value only if directionBias series is sent in input parameters
zigzagdivergence : Array of divergence sentiment at each pivot. Will have valid values only if oscillatorSource and directionBias inputs are provided
newPivot : Returns true if new pivot created
doublePivot : Returns true if two new pivots are created on same bar (Happens in case of candles with long wicks and shorter zigzag lengths)
drawzigzag(length, , source, linecolor, linewidth, linestyle, oscillatorSource, directionBias, showHighLow, showRatios, showDivergence) drawzigzag: Calculates and draws zigzag pivots
Parameters:
length : : Zigzag Length
: useAlternativeSource: If set uses the source for genrating zigzag. Default is false
source : : Alternative source used only if useAlternativeSource is set to true. Default is close
linecolor : : zigzag line color
linewidth : : zigzag line width
linestyle : : zigzag line style
oscillatorSource : : Oscillator source for calculating divergence
directionBias : : Direction bias for calculating divergence
showHighLow : : show highlow label
showRatios : : show retracement ratios
showDivergence : : Show divergence on label (Only works if divergence data is available - that is if we pass valid oscillatorSource and directionBias input)
Returns: zigzagpivots : Array containing zigzag pivots
zigzagpivotbars : Array containing zigzag pivot bars
zigzagpivotdirs : Array containing zigzag pivot directions (Lower High : 1, Higher High : 2, Lower Low : -2 and Higher Low : -1)
zigzagpivotratios : Array containing zigzag retracement ratios for each pivot
zigzagoscillators : Array of oscillator values at pivots. Will have valid values only if valid oscillatorSource is provided as per input.
zigzagoscillatordirs: Array of oscillator directions (HH, HL, LH, LL) at pivots. Will have valid values only if valid oscillatorSource is provided as per input.
zigzagtrendbias : Array of trend bias at pivots. Will have valid value only if directionBias series is sent in input parameters
zigzagdivergence : Array of divergence sentiment at each pivot. Will have valid values only if oscillatorSource and directionBias inputs are provided
zigzaglines : Returns array of zigzag lines
zigzaglabels : Returns array of zigzag labels