Summary: This indicator script measures the highest price of an underlying symbol in a specified number of periods. Calculation: The highest high in a specified number of periods of the underlying symbol. Developer: Richard Donchian Interpretation: 1. Resistance: When the underlying symbol is moving upwards towards the indicator script, the underlying symbol is likely to reverse direction and move downwards. 2. Resistance Broken: When the underlying symbol breaks resistance by crossing above the indicator script, the underlying symbol is likely to continue moving upwards.
' Assign the parameter to script variables. _symbolIndex = symbolIndex _periods = periods
' Get the highest prices of the symbol, indexed by bar index. Define high() As Number = BarHigh(_symbolIndex, barIndex, length + _periods) Define max As Number ' Use for the calculated Donchian Channel Upper values, indexed by bar index. Define results(length - 1) As Number ' Calculate the Donchian Channel Upper values for the specified bar range. For i As Integer = length - 1 To 0 Step -1 max = 0 ' Calculate the Donchian Channel Upper value for the current bar. For j As Integer = i + _periods - 1 To i Step -1 If (high(j) > max) Then max = high(j) End If Next results(i) = max Next Return results