Experimenting with InputSourcePrice, RSI smoothed with MAType, Delay BuySignal

stable
By Kobalt in Miscellaneous Published September 2022 👁 1,349 views 💬 3 comments

Description

RSI smoothed with MA Type, select SourcePrices with InputSourcePrice, Delay BuySignal.
HaasScript
-- Define command
DefineCommand('EasyDelayedSmoothRSI', 'RSI smoothed with MA Type, select SourcePrices with InputSourcePrice, Delay BuySignal.')
local market = PriceMarket()

-- Define command parameters.
local chartIndex = DefineParameter(NumberType, 'chartIndex', 'The index on which to chart', true, 1, 'Number')
local name = DefineParameter(StringType, 'name', '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')
local isPlotting = DefineParameter(BooleanType, 'isPlotting', 'Disable plot.', false, true, 'Input, true/false.')
local fullcdl = true-- DefineParameter(BooleanType, 'fullcdl', 'Disable plot.', false, true, 'Input, true/false.')
local hlc = false
local source = DefineParameter(EnumType, 'sourcePrice', '', false, HLPriceSource, 'PriceSourceEnum/InputSourcePrice')

DefineIntervalOptimization(interval)

-- Input fields for the indicator. Add the name in front.
InputGroupHeader('Smooth RSi')
local rsiLength = Input(name..' RSI Length', 6)
local sellLevel = Input(name..' Sell Level', 88)
local buyLevel = Input(name..' Buy Level', 16)
local maType = InputMaTypes('maType', WmaType, '', '')
local smoothLength = Input(name..' Smooth Length', 5)
local source = InputSourcePrice('sourcePrice', OHLCPriceSource, '', '')
local hlc = Input("hlcStyle", false, 'When enabled, the data returned will be adjusted for HLC instead of OHLC. Meaning that the OHL data can change.')
local prices = SourcePrices(source, interval, fullcdl, market, hlc)
--local source2 = InputSourcePrice('sourcePrice', OHLCPriceSource, '', '')
--local prices2 = SourcePrices(source2, shInterval2, fullcdl, market, hlc)

-- and MA plot
local ma = MA(prices, smoothLength, maType)
local rsi = RSI(prices, rsiLength)
local smoothRSI = MA(rsi, smoothLength, maType) 

-- Determine the signal.
local signal = GetBuySellLevelSignal(smoothRSI, buyLevel, sellLevel)
local delaysig = DelaySignal(SignalLong, Input(name..'Delay BuySignal', 3, '(minutes)', 'Smooth RSi'))
-- Plot the indicator Use the chartIndex parameter.
PlotLineBuySellZone(chartIndex, 'SmoothRSI', smoothRSI, buyLevel, sellLevel)
ChartSetOptions(chartIndex, 'SmoothRSI', 0.24 )
ChartSetAxisOptions(chartIndex, RightAxis, 0, 100)
--Return the custom signal.
DefineOutput(EnumType, signal, 'Signal result', 'TradeBotContainer, IndicatorContainer, Signal Helpers')
--DoSignal(signal)

3 Comments

Sign in to leave a comment.

A
Akmonsalba over 3 years ago

Experimenting with RSI smoothed with Ma in visual format would be awesome

K
Kobalt over 3 years ago

here you go, you can replace MFI with anything.
https://www.haasscripts.com/t/kobaltschrodingers-cash-a-quantum-physmoothmfi10-vhoney-bear-trap/

A
Akmonsalba over 3 years ago

Thank you. much appreciated. given me lots to think about and learn from.