0

I am developing pinescript indicator with multi timeframe support

indicator("My indicator", timeframe = "")

I want to plot somevalue with offset

plot(somevalue, offset = 5)

This works fine if indicator is on the default chart timeframe, but if it is on some other custom timeframe the offset value is wrong. The offset argument is always measured in the number of bars on the chart's timeframe. But script's logic runs on a higher timeframe.

//@version=6
indicator("My indicator", timeframe="")
somevalue = close
offset = 5
plot(somevalue, offset=offset)

I need to calculate the ratio between the indicator's timeframe and the chart's timeframe and then multiply my offset by this ratio. How to accomplish this? timeframe.main_period and timeframe.period both return indicator's timeframe. How do I get chart timeframe?

One example of such indicator is built-in Williams Alligator. It technically has multi timeframe support but it is not displayed correctly if timeframe is different from Chart.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.