I'm stuck on how to create a sine wave of varying length in days. I want length to be start of the wave to start of the next wave (daily timeframe, so 1 bar=1 day).
ln = param("Length (days)", 250, 10,500,1);
//CODE HERE
//I CAN SEE sin(x) --- but it's not cycle length
plot(sinewave, "Sin", colorblue);
// Plot a sinewave with definable length and amplitude
// Define parameters for the sine wave
Length = Param( "Length", 50, 10, 200, 1 );
Amplitude = Param( "Amplitude", 10, 1, 100, 1 );
// Calculate the phase for each bar
// BarIndex() gives the 0-based index of the current bar
// We want the phase to go from 0 to 2 * PI over the specified Length
Phase = 2 * 3.1415926535 * BarIndex() / Length;
// Calculate the sine wave value
SineWave = Amplitude * sin( Phase );
// Plot the sine wave
Plot( SineWave, "Sine Wave", colorBlue, styleLine );
// Add a commentary to the chart
printf( "Sine Wave (Length: %g, Amplitude: %g)", Length, Amplitude );
This is Gemini 2.5 Flash which is essentially free (unlike Claude).