[Kobalt updated sorted] Mad Hatter Indicators: MHB RSI v2
stableDescription
MadHatter RSIV2
Input Menu Group format and order of elements.
Every MHB Indicator has option of using a different timeframe.
-- Sorted Input Group items to match MadHatter, clean group format.
-- Added Interval per indicator
-- Optional description name, included in chart plot instead of script name.
HaasScript
-- Author: kob
-- Define command
DefineCommand("MadHatterRSIV2", "Custom RSI signal implementation for MadHatter")
-- Added Input Menu Groups [kob]
-- Define command parameters.
local chartIndex = DefineParameter(NumberType, 'chartIndex', 'The index on which to chart', true, 1, 'Number')
local name = DefineParameter(StringType, 'name', 'Optional unique name of the indicator.', false, '', 'Text')
local interval = DefineParameter(NumberType, 'interval', 'Used interval for price data. Default is 0 and the main interval will be used.', false, 0, 'Number,InputInterval')
DefineIntervalOptimization(interval)
-- Input fields for the indicator. Add the name in front.
--InputGroupHeader('MHB RSI '..name)
local interval = InputInterval(name..' Interval', 1, 'The timeframe for MadHatter RSI.', {group = "MHB RSI"})
local length = Input(name..' RSI Length', 12, {group = "MHB RSI"})
local buyLevel = Input(name..'RSI Buy Level', 30, {group = "MHB RSI"})
local sellLevel = Input(name..'RSI Sell Level', 70, {group = "MHB RSI"})
-- Calculate the indicator
local prices = ClosePrices(interval)
local rsi = RSI(prices, length)
local signal = SignalNone
if rsi < buyLevel and IsRising(rsi, 1) then
signal = SignalLong
elseif rsi[2] < buyLevel and IsRising(rsi, 1) then
signal = SignalLong
elseif rsi > sellLevel and IsFalling(rsi, 1) then
signal = SignalShort
elseif rsi[2] > sellLevel and IsFalling(rsi, 1) then
signal = SignalShort
end
-- Plot the indicator Use the chartIndex parameter.
PlotLineBuySellZone(chartIndex, 'MHB RSI', rsi, buyLevel, sellLevel)
ChartSetOptions(chartIndex, name.. 'MHB RSI')
--Return the custom signal.
DefineOutput(EnumType, signal, 'Signal result', 'TradeBotContainer, IndicatorContainer, Signal Helpers')
0 Comments
Sign in to leave a comment.
No comments yet. Be the first!