Posting a new Vortex Indicator. 'kingscorpion' has requested this indicator to be developed for marketscope, and short description was inserted here from his original request.
Information on this indicator can be found here:http://www.traders.com/Reprints/PDF_reprints/VFX_VORTEX.PDF
Vortex Indicator
by kingscorpion
Vortex, developed by Etienne Botes & Douglas Siepman of http://www.VortexFund.com, uses the relationship between today's high and yesterday's low for VM+ (similar to DMI+) and today's low and yesterday's high for VM- (similar to DMI-). The indicator plots only two line.
The first calculation is for the positive trending vortex movement VM+:
= ABS(Today's High - Yesterday's Low)
Next, calculate the negative trending vortex movement –VM. The formula is:
=ABS(Today's Low - Yesterday's High)
A 14-period sum of both VM+ and VM- is calculated.
Next, we calculate the true range (TR) and need to get the sum of the last 14 periods’ true range.
Finally, we need to calculate the ratio of each 14 period VM+ and 14 period VM- to the sum of the last 14 days’ daily true ranges.
And now the two ratios are drawn for the Vortex Indicator.
-kingscorpion
- Code: Select all
-- Indicator profile initialization routine
function Init()
indicator:name("The Vortext Indicator");
indicator:description("The indicator was described in Jan, 10 issue of the 'Stock and Commodites' Magazin");
indicator:requiredSource(core.Bar);
indicator:type(core.Oscillator);
indicator.parameters:addInteger("N", "Length of the vortex", "No description", 14);
indicator.parameters:addColor("VIP_color", "Color of VI+", "Color of VI+", core.rgb(0, 255, 0));
indicator.parameters:addColor("VIM_color", "Color of VI-", "Color of VI-", core.rgb(255, 0, 0));
end
-- Indicator instance initialization routine
-- Processes indicator parameters and creates output streams
local N;
local first;
local source = nil;
-- Streams block
local VIP = nil;
local VIM = nil;
local iVIP = nil;
local iVIN = nil;
local iATR = nil;
-- Routine
function Prepare()
N = instance.parameters.N;
source = instance.source;
iATR = core.indicators:create("ATR", instance.source, 1);
first = iATR.DATA:first() + N;
local name = profile:id() .. "(" .. source:name() .. ", " .. N .. ")";
instance:name(name);
VIP = instance:addStream("VIP", core.Line, name .. ".VI+", "VI+", instance.parameters.VIP_color, first);
VIM = instance:addStream("VIM", core.Line, name .. ".VI-", "VI-", instance.parameters.VIM_color, first);
iVIP = instance:addInternalStream(1, 0);
iVIM = instance:addInternalStream(1, 0);
end
-- Indicator calculation routine
function Update(period, mode)
iATR:update(mode);
if period >= 1 then
iVIP[period] = math.abs(source.high[period] - source.low[period - 1]);
iVIM[period] = math.abs(source.low[period] - source.high[period - 1]);
end
if period >= first then
local svip, svim, satr;
local range;
range = core.rangeTo(period, N);
svip = core.sum(iVIP, range);
svim = core.sum(iVIM, range);
satr = core.sum(iATR.DATA, range);
VIP[period] = svip / satr * 100;
VIM[period] = svim / satr * 100;
end
end
MT4/MQ4 Version.
viewtopic.php?f=38&t=64350