Units in mathex.lregSlope

Section for discussions related to indicators, use of indicators, and building of trading stategies using indicators.

Moderator: admin

Units in mathex.lregSlope

Postby Loggy48 » Wed Apr 27, 2016 12:05 pm

I am trying to use the lregSlope function to evaluate the slope over a short interval from a 1 minute bar, using source.close.

I am trying to work out what are the units in the various mathex routines, specifically lregSlope. This is not specified in the routine definition.

Copying (for example) the time in days at the end of the bar, and the price in whatever units into R I get completely different answers, but rather closer if I work in pips. It could be the time that I am using, which is actually from the corresponding tick trace at the end of the bar, but a consistent error in time would not actually change the slope as that slope is deltaY/deltaX. Equally the routine only returns the slope so the intercept does not matter.

I don't know what the lreg function does at all. What is a "linear regression value" when it's out? A simple y=Ax+B should return the intercept and slope - it would be useful to return an adjusted R-squared as well. Is there a reference for mathex? I can't find one on the web although there are other mathex libraries.
Loggy48
 
Posts: 89
Joined: Tue Jun 24, 2014 8:39 am
Location: Manchester, UK

Re: Units in mathex.lregSlope

Postby Julia CJ » Thu Apr 28, 2016 6:07 am

Hi Loggy48,

Please read the information about "mathex.lregSlope " here:
http://www.fxcodebase.com/bin/beta/Indi ... Slope.html
There you can see the examples of its using.
Julia CJ
 

Re: Units in mathex.lregSlope

Postby Loggy48 » Thu Apr 28, 2016 8:32 am

Julia

Yes I saw that of course.

But it doesn't say what units it is in and my calculations don't tie up with it at all. For example the following extract has 4 columns: Day, Value (EUR/USD), 10000*calculated value from lregSlope (ie pips/day) and a simple Excel slope calculation (R gives the same result) and the ratio of column 3/column 4, all using the most recent 10 pairs of {time,value}. If it were pips/hour or minute than the ratio would be constant but it's all over the place.

The routines are useful in principle because they should be a lot faster than using Lua code, Lua being rather thin on numerical libraries unless you want to use Torch 5, which is a bit of an overkill I think!

42487.395833333 1.13099
42487.396527778 1.13117
42487.397233796 1.13116
42487.397916667 1.13142
42487.398611111 1.13114
42487.399317130 1.13150
42487.400000000 1.13186
42487.400706019 1.13198
42487.401388889 1.13204
42487.402083333 1.13212
42487.402777778 1.13220 1.3315 0.1923 6.9236
42487.403472222 1.13177 1.0661 0.1918 5.5572
42487.404178241 1.13162 0.6394 0.1537 4.1599
42487.404861111 1.13177 0.4121 0.0920 4.4815
42487.405555556 1.13159 -0.1424 0.0593 -2.4020
42487.406250000 1.13172 -0.4406 -0.0207 21.3130


See what I mean?
Loggy48
 
Posts: 89
Joined: Tue Jun 24, 2014 8:39 am
Location: Manchester, UK

Re: Units in mathex.lregSlope

Postby Apprentice » Sun May 01, 2016 9:29 am

Try this indicator.
viewtopic.php?f=17&t=63431

Use source:pipSize() if you want to express value in pips.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36341
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia


Return to Discussions

Who is online

Users browsing this forum: No registered users and 3 guests