waves█ OVERVIEW
This library intended for use in Bar Replay provides functions to generate various wave forms (sine, cosine, triangle, square) based on time and customizable parameters. Useful for testing and in creating oscillators, indicators, or visual effects.
█ FUNCTIONS
• getSineWave()
• getCosineWave()
• getTriangleWave()
• getSquareWave()
█ USAGE EXAMPLE
//@version=6
indicator("Wave Example")
import kaigouthro/waves/1
plot(waves.getSineWave(cyclesPerMinute=15))
█ NOTES
* barsPerSecond defaults to 10. Adjust this if not using 10x in Bar Replay.
* Phase shift is in degrees.
---
Library "waves"
getSineWave(cyclesPerMinute, bar, barsPerSecond, amplitude, verticalShift, phaseShift)
`getSineWave`
> Calculates a sine wave based on bar index, cycles per minute (BPM), and wave parameters.
Parameters:
cyclesPerMinute (float) : (float) The desired number of cycles per minute (BPM). Default is 30.0.
bar (int) : (int) The current bar index. Default is bar_index.
barsPerSecond (float) : (float) The number of bars per second. Default is 10.0 for Bar Replay
amplitude (float) : (float) The amplitude of the sine wave. Default is 1.0.
verticalShift (float) : (float) The vertical shift of the sine wave. Default is 0.0.
phaseShift (float) : (float) The phase shift of the sine wave in radians. Default is 0.0.
Returns: (float) The calculated sine wave value.
getCosineWave(cyclesPerMinute, bar, barsPerSecond, amplitude, verticalShift, phaseShift)
`getCosineWave`
> Calculates a cosine wave based on bar index, cycles per minute (BPM), and wave parameters.
Parameters:
cyclesPerMinute (float) : (float) The desired number of cycles per minute (BPM). Default is 30.0.
bar (int) : (int) The current bar index. Default is bar_index.
barsPerSecond (float) : (float) The number of bars per second. Default is 10.0 for Bar Replay
amplitude (float) : (float) The amplitude of the cosine wave. Default is 1.0.
verticalShift (float) : (float) The vertical shift of the cosine wave. Default is 0.0.
phaseShift (float) : (float) The phase shift of the cosine wave in radians. Default is 0.0.
Returns: (float) The calculated cosine wave value.
getTriangleWave(cyclesPerMinute, bar, barsPerSecond, amplitude, verticalShift, phaseShift)
`getTriangleWave`
> Calculates a triangle wave based on bar index, cycles per minute (BPM), and wave parameters.
Parameters:
cyclesPerMinute (float) : (float) The desired number of cycles per minute (BPM). Default is 30.0.
bar (int) : (int) The current bar index. Default is bar_index.
barsPerSecond (float) : (float) The number of bars per second. Default is 10.0 for Bar Replay
amplitude (float) : (float) The amplitude of the triangle wave. Default is 1.0.
verticalShift (float) : (float) The vertical shift of the triangle wave. Default is 0.0.
phaseShift (float) : (float) The phase shift of the triangle wave in radians. Default is 0.0.
Returns: (float) The calculated triangle wave value.
getSquareWave(cyclesPerMinute, bar, barsPerSecond, amplitude, verticalShift, dutyCycle, phaseShift)
`getSquareWave`
> Calculates a square wave based on bar index, cycles per minute (BPM), and wave parameters.
Parameters:
cyclesPerMinute (float) : (float) The desired number of cycles per minute (BPM). Default is 30.0.
bar (int) : (int) The current bar index. Default is bar_index.
barsPerSecond (float) : (float) The number of bars per second. Default is 10.0 for Bar Replay
amplitude (float) : (float) The amplitude of the square wave. Default is 1.0.
verticalShift (float) : (float) The vertical shift of the square wave. Default is 0.0.
dutyCycle (float) : (float) The duty cycle of the square wave (0.0 to 1.0). Default is 0.5 (50% duty cycle).
phaseShift (float) : (float) The phase shift of the square wave in radians. Default is 0.0.
Returns: (float) The calculated square wave value.
Barreplay
Bar ReplayThis indicator mirrors TradingView's bar replay feature to a certain extent, offering traders a streamlined way to analyze past market movements. It's a practical tool for strategy testing, pattern recognition, and refining trading approaches.
While it may have some limitations, it offers a practical solution for strategy testing and refining trading approaches for free and gets the job done. After all, having a tool is better than having none.
This is just an experiment so don't take it that seriously. I hope you guys find it useful.
If you have some ideas for improvement or found any bugs, kindly let me know.
How to use it?
Step 1 : Add the indicator to the chart.
Step 2 : Select the candle .
Step 3 : Make the changes visible.
Step 4 : How to Navigate
Step 5 : Change the date easily
The blank screen issue.
Note : There are some limitations
The data is limited to the free plan.
It's not smooth as the real Bar replay feature.
I haven't checked the bugs so let me know if you found any.
Vertical line by bar_indexThis indicator helps in letting the trader focus on a particular date/candle across many symbols.
Tradingview currently has a bug in Bar Replay - when we switch symbols, the bar replay resets.
Hence if you are backtesting & running through a bunch of symbols, it is nearly impossible to focus on a particular historical candle across all symbols.
This indicator plots a vertical line on a given bar_index which remains as it is while you are switching symbols.
Feel free to copy, modify and use as you like!