Dynamic Trend Indicator

Here you can post and download custom indicators. PLEASE: Do not start topics unless you are posting your own indicator, they will be moved to appropriate section even if you do.

Moderator: admin

Dynamic Trend Indicator

Postby Alexander.Gettinger » Tue Aug 17, 2010 2:51 am

viewtopic.php?f=27&t=1693

DynamicTrend.png


Code: Select all
function Init()
    indicator:name("Dynamic Trend Indicator");
    indicator:description("Dynamic Trend Indicator");
    indicator:requiredSource(core.Bar);
    indicator:type(core.Indicator);
   
    indicator.parameters:addInteger("Percent", "Percent", "Percent", 1);
    indicator.parameters:addInteger("MaxPeriod", "MaxPeriod", "MaxPeriod", 14);

    indicator.parameters:addColor("clrLine", "Color of line", "Color of line", core.rgb(0, 255, 0));
    indicator.parameters:addColor("clrUP", "UP color", "UP color", core.rgb(255, 0, 0));
    indicator.parameters:addColor("clrDN", "DN color", "DN color", core.rgb(0, 0, 255));
end

local first;
local source = nil;
local Percent;
local MaxPeriod;

function Prepare()
    source = instance.source;
    Percent=instance.parameters.Percent;
    MaxPeriod=instance.parameters.MaxPeriod;
    first = source:first()+2;
    local name = profile:id() .. "(" .. source:name() .. ", " .. instance.parameters.Percent .. ", " .. instance.parameters.MaxPeriod .. ")";
    instance:name(name);
    LineBuff = instance:addStream("Line", core.Line, name .. ".Line", "Line", instance.parameters.clrLine, first);
    buffUp = instance:createTextOutput ("Up", "Up", "Wingdings", 10, core.H_Center, core.V_Center, instance.parameters.clrUP, first);
    buffDn = instance:createTextOutput ("Dn", "Dn", "Wingdings", 10, core.H_Center, core.V_Center, instance.parameters.clrDN, first);
end

function Update(period, mode)
    if (period>first+MaxPeriod) then
     if source.close[period]<LineBuff[period-1] then
      LineBuff[period]=core.max(source.close,core.rangeTo(period-1,MaxPeriod))-Percent*source:pipSize();
     else
      LineBuff[period]=core.min(source.close,core.rangeTo(period-1,MaxPeriod))+Percent*source:pipSize();
     end
     if source.close[period-3]>LineBuff[period-2] and source.close[period-2]<LineBuff[period-3] then
      buffUp:set(period, source.low[period]-10*source:pipSize(), "\225", "");
     end
     if source.close[period-2]<LineBuff[period-1] and source.close[period-2]>LineBuff[period-3] then
      buffDn:set(period, source.high[period]-10*source:pipSize(), "\226", "");
     end
    end
end

DynamicTrend.lua
(2.7 KiB) Downloaded 1815 times
Alexander.Gettinger
FXCodeBase: Confirmed User
 
Posts: 3785
Joined: Wed Mar 31, 2010 9:40 pm
Location: Russia, Omsk

Re: Dynamic Trend Indicator

Postby Hybrid » Tue Aug 17, 2010 11:55 am

Thank you for your work on this Indicator, Alexander.

Quick question:

Is this version a translation of the code I provided in my request, or the link to the trade-profit website?
Hybrid
 
Posts: 42
Joined: Fri Apr 02, 2010 7:52 am

Re: Dynamic Trend Indicator

Postby Alexander.Gettinger » Wed Aug 18, 2010 8:33 pm

This is a translation of the MT4 code.
Alexander.Gettinger
FXCodeBase: Confirmed User
 
Posts: 3785
Joined: Wed Mar 31, 2010 9:40 pm
Location: Russia, Omsk

Re: Dynamic Trend Indicator

Postby bonnevie » Sun Sep 19, 2010 7:25 pm

Alexander,

Is it possible to get a MTF version, so we can choose to have the indi show trend for a different TF than the chart it's on?

Thanks in advance,
bonnevie
bonnevie
 
Posts: 12
Joined: Mon Jun 07, 2010 2:15 am


Re: Dynamic Trend Indicator

Postby Apprentice » Mon Sep 20, 2010 5:38 am

Requested and the indicator can be found here.
viewtopic.php?f=17&t=2223
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36437
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: Dynamic Trend Indicator

Postby Apprentice » Fri Jan 20, 2017 6:53 am

Indicator was revised and updated.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36437
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: Dynamic Trend Indicator

Postby Apprentice » Mon Feb 05, 2018 8:19 am

The Indicator was revised and updated.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36437
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia


Return to Custom Indicators

Who is online

Users browsing this forum: No registered users and 138 guests