Summary: This heat study script generates values based on support and resistance levels of an indicator. Returns: Support: 1 Resistance: -1
' Assign the script parameters to script variables. _supportMargin = supportMargin _resistanceMargin = resistanceMargin ' Use for holding indicator keys based on the specified indicator key, indexed by symbol index. Redefine _indicatorKeys(SymbolCount() - 1) ' Use for holding indicator keys based on the specified support indicator key, indexed by symbol index. Redefine _supportIndicatorKeys(SymbolCount() - 1) ' Use for holding indicator keys based on the specified resistance indicator key, indexed by symbol index. Redefine _resistanceIndicatorKeys(SymbolCount() - 1) ' Iterate over all of the account symbols. For i As Integer = 0 To SymbolCount() - 1 ' Create an indicator for each account symbol, based on the specified indicator. _indicatorKeys(i) = IndicatorCopy(indicatorKey, i) ' Create an indicator for each account symbol, based on the specified support indicator. _supportIndicatorKeys(i) = IndicatorCopy(supportIndicatorKey, i) ' Create an indicator for each account symbol, based on the specified resistance indicator. _resistanceIndicatorKeys(i) = IndicatorCopy(resistanceIndicatorKey, i) Next
' Get the indicator value, indexed by bar index. Define value As Number = IndicatorValue(_indicatorKeys(symbolIndex)) ' Get the support indicator value, indexed by bar index. Define supportValue As Number = IndicatorValue(_supportIndicatorKeys(symbolIndex)) ' Get the resistance indicator value, indexed by bar index. Define resistanceValue As Number = IndicatorValue(_resistanceIndicatorKeys(symbolIndex)) ' Support. If (supportValue <= value And value <= supportValue * (1 + _supportMargin)) Then Return 1 ' Resistance. ElseIf (resistanceValue * (1 + _resistanceMargin) <= value And value <= resistanceValue) Then Return -1 End If