[GnAsHeR] MavilimW - MavilimW Trend Indicator
stableDescription
-- Easy Mavilim Trend indicator
-- This Indicator plots smoothed weighted moving average combinations of various Fibonacci numbers
-- a great support and resistance for long term trading and confirmation
--
-- Notes
-- 1- MavilimW has 2 colors now. Blue signals for uptrend, Red for downtrend.
-- 2- You can cghange the sensitivity of the indicator by changing the first two parameters
-- 3- In the settings you can also add the original version by checking the "Show previous version" button
-- 4- The indicator calculates Fibonacci series automatically when you change the two parameters
--
-- HINT: first parameter must be equal or less then second
-- Some examples: 0,1 or 1,1 or 1,2 or 2,3 or even 5,5 and so on...
-- by increasing the parameters the indicator becomes less sensitive for buy and sell signals but will have
-- high potential of becoming support or resistance line
-- by decreasing the parameters you can have more sensitive buy an sell signals which changes the color of the indicator.
--
-- Author/Yazar: KıvanÇ @fr3762 twitter - ported by GnAsHeR twitter : @Eris Kucukoglu
HaasScript
-- Define command
DefineCommand('MavilimW', 'MavilimW Trend Indicator')
-- Define command parameters.
local chartIndex = DefineParameter(NumberType, 'chartIndex', 'The index on which to chart', true, 0, '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')
-- This will improve our backtest speed when using the command.
DefineIntervalOptimization(interval)
--Data
local c = HeikenClosePrices(interval, true)
-- Input fields for the indicator.
InputGroupHeader('MavilimW '..name..' Settings')
local mavilimold = Input('Show Previous Version of MavilimW ?', false)
local fmal = Input('First Moving Average length', 3)
local smal = Input('Second Moving Average length', 5)
-- Stuff
local upperId = Load('uid', NewGuid())
local lowerId = Load('lid', NewGuid())
local result
-- Calculate the indicator
local tmal = fmal + smal
local Fmal = smal + tmal
local Ftmal = tmal + Fmal
local Smal = Fmal + Ftmal
local M1 = WMA(c, fmal)
local M2 = WMA(M1, smal)
local M3 = WMA(M2, tmal)
local M4 = WMA(M3, Fmal)
local M5 = WMA(M4, Ftmal)
local MAVW = WMA(M5, Smal)
local col1 = MAVW > MAVW[1]
local col3 = MAVW < MAVW[1]
local M12= WMA(c, 3)
local M22= WMA(M12, 5)
local M32= WMA(M22, 8)
local M42= WMA(M32, 13)
local M52= WMA(M42, 21)
local MAVW2= WMA(M52, 34)
-- Signal logic
-- local result = IfElse(CrossOver(MAVW, c), SignalSell, SignalBuy)
-- Calculate the indicator
local result = SignalNone
if c > MAVW and IsFalling(MAVW, 1) and IsRising(c, 1) then
result = SignalLong
elseif MAVW > c and IsRising(MAVW, 1) and IsFalling(c, 1) then
result = SignalShort
end
--Ploting Chart
if mavilimold == true then
Plot(chartIndex, ' MavWOLD', MAVW2, LineOptions({color=Blue, width=2}))
elseif mavilimold == false and MAVW > c then
upperId = NewGuid() -- reset lower id
Plot(chartIndex, name..' Sell', MAVW, {c=Red, width=2, id=lowerId})
elseif mavilimold == false and MAVW < c then
lowerId = NewGuid() -- reset upper id
Plot(chartIndex, name..' Buy', MAVW, {c=Blue, width=2, id=upperId})
end
Save('uid', upperId)
Save('lid', lowerId)
-- Output Signal
DefineOutput(EnumType, result, 'MavilimW Signal Output')
1 Comment
Sign in to leave a comment.
Cool!