[GnAsHeR] Inverse Fisher Transform on CCI - IFTCCI
stableDescription
-- Inverse Fisher Transfor on CCI indicator
--
-- About INVERSE FISHER TRANSFORM:
--
-- The purpose of technical indicators is to help with your timing decisions to buy or sell. Hopefully, the signals are clear
-- and unequivocal. However, more often than not your decision to pull the trigger is accompanied by crossing your
-- fingers. Even if you have placed only a few trades you know the drill.
-- The Fisher Transform can be applied to almost any normalized data set to make the resulting PDF nearly Gaussian,
-- with the result that the turning points are sharply peaked and easy to identify.
-- The Fisher Transform is defined by the equation
-- 1) Whereas the Fisher Transform is expansive, the Inverse Fisher Transform is compressive. The Inverse Fisher Transform
-- is found by solving equation 1 for x in terms of y. The Inverse Fisher Transform is:
-- 2) The transfer response of the Inverse Fisher Transform is shown in Figure If the input falls between –0.5 and +0.5,
-- the output is nearly the same as the input.
-- For larger absolute values (say, larger than 2), the output is compressed to be no larger than unity .
-- The result of using the Inverse Fisher Transform is that the output has a very high probability of being either +1 or –1.
-- This bipolar probability distribution makes the Inverse Fisher Transform ideal for generating an indicator that provides
-- clear buy and sell signals.
--
-- Author: KıvanÇ @fr3762 twitter - ported by GnAsHeR twitter : @Eris Kucukoglu
HaasScript
-- Define command
DefineCommand('IFTCCI', 'Inverse Fisher Transform on CCI')
-- Define command parameters.
local chartIndex = DefineParameter(NumberType, 'chartIndex', 'The index on which to chart', true, 1, 'Number')
local name = DefineParameter(StringType, 'name', 'Inverse Fisher Transform on STOCHASTIC', 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')
-- This will improve our backtest speed when using the command.
DefineIntervalOptimization(interval)
-- Input fields for the indicator.
InputGroupHeader('IFTCCI '..name..' Settings')
local ccilength = Input('CCI Length', 5)
local wmalength = Input('Smoothing length', 9)
local buyLevel = Input(name..' Buy Level', -0.5)
local sellLevel = Input(name..' Sell Level', 0.5)
-- Calculate the indicator
local c = ClosePrices()
local h = HighPrices()
local l = LowPrices()
local v1 = 0.1*(CCI(h, l, c, ccilength))
local v2 = WMA(v1, wmalength)
local INV = (Exp(2*v2)-1)/(Exp(2*v2)+1)
-- Determine the signal.
local signal = SignalNone
if INV < buyLevel and IsRising(INV, 1) then
signal = SignalLong
elseif INV[2] < buyLevel and IsRising(INV, 1) then
signal = SignalLong
elseif INV > sellLevel and IsFalling(INV, 1) then
signal = SignalShort
elseif INV[2] > sellLevel and IsFalling(INV, 1) then
signal = SignalShort
end
-- Plot Indicator
PlotLineBuySellZone(chartIndex, 'IFTCCI', INV, buyLevel, sellLevel)
ChartSetAxisOptions(chartIndex, RightAxis, -1, 1)
PlotHorizontalLine(chartIndex, 'Overbought', Blue, sellLevel, Dashed)
PlotHorizontalLine(chartIndex, 'Oversold', Red, buyLevel, Dashed)
--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!