snusmumriken
Pine Script Rookie
Pine Script Rookie
Posts: 1
Joined: January 8th, 2023

Change imput interval

Hello
I'm working on a strategy based on Ichimoku and I need some help.

Code: Select all

conversionPeriods = input.int(9, minval=1, title="Conversion Line Length")
donchian(len) => math.avg(ta.lowest(len), ta.highest(len))
conversionLine = donchian(conversionPeriods)
These lines will take the average of highest and lowest price starting 9 time periods from the latest candle.
What I need is to take the average (still a period of 9), which start 18 timeperiods, and ends 9 timeperiods away from the latest candle, i.e move the period 9 steps backwards.

Im new both to pinescript and this community so just let me know if I'm in the wrong channel or anything else I need to know.

Steve Burman
Moderator
Moderator
Posts: 109
Joined: January 13th, 2023

Re: Change imput interval

Yes this should be possible.You could do something like this:

conversionPeriod1 = input.int(9, minval=1, title="Conversion Line Length 1")
conversionPeriod2 = input.int(18, minval=1, title="Conversion Line Length 2")
donchian(len1,len2) => math.avg(ta.lowest(len2), ta.highest(len1)
conversionLine = donchian(conversionPeriod1,conversionPeriod2)

Return to “Pine Script Q&A”