Variations of the Hurst Exponent over time

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

Variations of the Hurst Exponent over time

Postby Alexander.Gettinger » Thu Jun 03, 2010 10:20 pm

This indicator is based on the assumption that the price variations follow a multi-fractal model. From there, the Hurst exponent can be easily computed from the fractal dimension (as obtained in viewtopic.php?f=17&t=1250). The variations of this Hurst exponent can actually be seen as predicting the variations of the volatility, and they therefore provide a time for entering into a trade (whenever this variation is positive), in order to profit from the high volatility period.

It must be noticed however, that this indicator doesn't give any information as to the direction of the trade, for that a directional indicator must be used.

Hurst_Difference.png


Code: Select all
function Init()
    indicator:name("Hurst Difference");
    indicator:description("Hurst Difference");
    indicator:requiredSource(core.Bar);
    indicator:type(core.Oscillator);
   
    indicator.parameters:addInteger("Period", "Period", "Period", 30);
    indicator.parameters:addString("app_price", "app_price", "", "close");
    indicator.parameters:addStringAlternative("app_price", "close", "", "close");
    indicator.parameters:addStringAlternative("app_price", "open", "", "open");
    indicator.parameters:addStringAlternative("app_price", "high", "", "high");
    indicator.parameters:addStringAlternative("app_price", "low", "", "low");
    indicator.parameters:addStringAlternative("app_price", "median", "", "median");
    indicator.parameters:addStringAlternative("app_price", "typical", "", "typical");
    indicator.parameters:addStringAlternative("app_price", "weighted", "", "weighted");

    indicator.parameters:addColor("clr_Line", "Color of Line", "Color of Line", core.rgb(255, 255, 0));
end

local first;
local source = nil;
local Period;
local app_price;
local Price;
local fdi;
local HurstBuff=nil;

function Prepare()
    source = instance.source;
    Period=instance.parameters.Period;
    app_price=instance.parameters.app_price;
    first = source:first()+2;
    local name = profile:id() .. "(" .. source:name() .. ", " .. instance.parameters.Period .. ", " .. instance.parameters.app_price .. ")";
    instance:name(name);
    Price = instance:addInternalStream(0, 0);
    fdi = instance:addInternalStream(0, 0);
    HurstBuff = instance:addStream("HurstBuff", core.Line, name .. ".HurstBuff", "HurstBuff", instance.parameters.clr_Line, first);
    HurstBuff:addLevel(0);
end

function Update(period, mode)
    if app_price=="close" then
     Price[period]=source.close[period];
    elseif app_price=="open" then
     Price[period]=source.open[period];
    elseif app_price=="high" then
     Price[period]=source.high[period];
    elseif app_price=="low" then
     Price[period]=source.low[period];
    elseif app_price=="median" then
     Price[period]=(source.high[period]+source.low[period])/2.;
    elseif app_price=="typical" then
     Price[period]=(source.high[period]+source.low[period]+source.close[period])/3.;
    else
     Price[period]=(source.high[period]+source.low[period]+2.*source.close[period])/4.;
    end
     
    if (period>first+Period) then

     local priceMax=core.max(Price,core.rangeTo(period,Period));
     local priceMin=core.min(Price,core.rangeTo(period,Period));
     local length=0.;
     local priorDiff=0.;
     local sum=0.;
     
     for i=period-Period+1,period,1 do
      if priceMax-priceMin>0. then
       diff=(Price[i]-priceMin)/(priceMax-priceMin);
       if i>period-Period+1 then
        length=length+math.sqrt(math.pow(diff-priorDiff,2)+(1./math.pow(Period,2)));
       end
       priorDiff=diff;
      end
     end
     
     if length>0. then
      fdi[period]=1.+(math.log(length)+math.log(2.))/math.log(2.*(Period-1))
     else
      fdi[period]=0.;
     end
     
     HurstBuff[period]=fdi[period-1]-fdi[period];

    end
end


Hurst_Difference.lua
(3.13 KiB) Downloaded 1339 times

Tick Hurst_Difference.lua
(5.15 KiB) Downloaded 393 times

Mq4/MT4 version.
viewtopic.php?f=38&t=63898
Alexander.Gettinger
FXCodeBase: Confirmed User
 
Posts: 3785
Joined: Wed Mar 31, 2010 9:40 pm
Location: Russia, Omsk

Re: Variations of the Hurst Exponent over time

Postby boursicoton » Thu Aug 19, 2010 7:20 am

hust worked on cycle of price,10,20,40,18-80,200-220 weeks
possible on marketscope ?
boursicoton
FXCodeBase: Confirmed User
 
Posts: 78
Joined: Sat Feb 06, 2010 1:33 pm

Re: Variations of the Hurst Exponent over time

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

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

Re: Variations of the Hurst Exponent over time

Postby mayk01 » Sun Sep 03, 2023 4:46 am

Hi Apprentice,

Is it possible to use this Fractal Dimension Index to calculate the Hurst Exponent? :
https://fxcodebase.com/code/viewtopic.p ... ex#p152254

That indicator shows the changes of the Fractal Dimension differently and this Hurst Exponent does not fit, because it is not based on that calculation.
M.
mayk01
 
Posts: 28
Joined: Tue Nov 14, 2017 3:38 pm

Re: Variations of the Hurst Exponent over time

Postby Apprentice » Sun Sep 10, 2023 3:15 pm

We have added your request to the development list.
Development reference 836.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36341
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: Variations of the Hurst Exponent over time

Postby Apprentice » Mon Sep 11, 2023 9:31 am

EURUSD m1 (09-11-2023 1629).png

Fractal Dimension Index Hurst_Difference.lua
(5.71 KiB) Downloaded 396 times


It is also possible to use Tick Hurst_Difference.lua
Use the Fractal Dimension Index.lua as a source for it.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36341
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: Variations of the Hurst Exponent over time

Postby mayk01 » Tue Sep 12, 2023 6:57 am

That's great :)

M.
mayk01
 
Posts: 28
Joined: Tue Nov 14, 2017 3:38 pm


Return to Custom Indicators

Who is online

Users browsing this forum: Google [Bot] and 46 guests