0 registered members (),
975
guests, and 2
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
DominantPeriod,DominantPhase and HTTrendMode doubts...
#436878
02/04/14 18:34
02/04/14 18:34
|
Joined: Nov 2013
Posts: 123
Mithrandir77
OP
Member
|
OP
Member
Joined: Nov 2013
Posts: 123
|
After reading some of John Ehler's books I started to do some tests to know if I had grasped some of his concepts. But first I have some questions about some functions that I don't understand what the documentation means: 1)In DominantPeriod and DominantPhase where it says " Period gives the bar period of maximum sensibility" what does it mean by sensibility? Is it the most "likely" period a priori? Or is it some initial condition for the function? 2) In HTTrendMode, what should we use as data? I have used both the entire price series as well as the price series cut off by the dominant period/2 or should we use the LookBack as cutoff? Concerning the concepts I tested, in a nutshell, one of them is that the market mode can be simplified as being in trend mode or in cycle mode. Then in market mode you go short on a peak of the cycle phase and long on a valley. I would like to identify whether the market is in trend mode or cycle mode so I made this script:
function run()
{
BarPeriod = 240;//240
var LookBackPeriod = (1440/BarPeriod)*20;//20 days
LookBack = LookBackPeriod;
StartDate = 2012;
asset("EUR/USD");
set(PLOTNOW);
vars Price = series(price());
plot("Price",Price[0],MAIN,BLACK);
var sinDomPhase = sin(DominantPhase(Price,30));
plot("Phase",sinDomPhase,NEW,BLACK);
plot("Phase Lead",sin(DominantPhase(Price,30)+PI/4),0,RED);
var domperiod = DominantPeriod(Price,30);
plot("Dominant Period",domperiod,NEW,BLUE);
var market_mode = HTTrendMode(series(sinDomPhase,domperiod/2));
if (market_mode)
//plot 1 in blue for trend mode
plot("MarketMode",1,NEW,BLUE);
else
//plot 0 in red for cycle mode
plot("MarketMode",0,LINE,BLUE);
}
When I test it, I get a BADFREE2: SYS messagebox and I hit RETRY and it plots the graph, what does that error mean? Anyway, it always plots the market as being in cycle mode when for instance from may to june 2012 there was a downtrend. What's wrong with the code? Thanks for any help!
|
|
|
Re: DominantPeriod,DominantPhase and HTTrendMode doubts...
[Re: jcl]
#436940
02/05/14 22:46
02/05/14 22:46
|
Joined: Nov 2013
Posts: 123
Mithrandir77
OP
Member
|
OP
Member
Joined: Nov 2013
Posts: 123
|
Thanks dusktrader and jcl for your help! The problem with HTTrendMode is that it returns an int and I was assigning a var to the result thus when asking 1.0 == 1 it always returned false. My bad...I'm halway in my studies of computer engineering but it seems forex concepts are filling my head and I forgot the basics of programming This works:
int market_mode = HTTrendMode(series(price());
"Sensibility" means the bar period on which the DominantPhase function is most sensible. F.I when you only want to consider bar periods greater than 30 bars, give 40 or 50 here to make DominantPhase insensible for smaller bar periods.
jcl, your answer bring two more questions then: 1) So that period parameter is like a center of a right-skewed bell shape of dominant periods? ie: If I set it to 40 it will find more likely dominant periods of 30-60 bars and more unlikely of less than 30? Or is it like a minimum point from which it starts iterations (in ascending steps) to find the dominant period? 2) Anyway, if I want to find the dominant period as in Ehlers books, that is the dominant period of all periods how can I do it? According to what you said I should set Period to 1 to scan all periods greater than one bar. Is this correct?
Last edited by Mithrandir77; 02/05/14 22:50.
|
|
|
Re: DominantPeriod,DominantPhase and HTTrendMode doubts...
[Re: jcl]
#436978
02/06/14 21:08
02/06/14 21:08
|
Joined: Nov 2013
Posts: 123
Mithrandir77
OP
Member
|
OP
Member
Joined: Nov 2013
Posts: 123
|
You can see a similar shape in the "Highpass" filter curve in the "Filters" chapter. It's more a radish than a bell. Period 1 would probably pass too much noise and make the detection worthless - but you can experiment with different settings and see for yourself. Our systems normally use 20 or 30 for the period. Would it be ok to use optimize to find the best period or would it cause curve-fitting?
|
|
|
Re: DominantPeriod,DominantPhase and HTTrendMode doubts...
[Re: jcl]
#473969
09/04/18 09:51
09/04/18 09:51
|
Joined: Jan 2018
Posts: 18
Meini
Newbie
|
Newbie
Joined: Jan 2018
Posts: 18
|
"Sensibility" means the bar period on which the DominantPhase function is most sensible. F.I when you only want to consider bar periods greater than 30 bars, give 40 or 50 here to make DominantPhase insensible for smaller bar periods. I know this is an old thread, but it's also still like that in the help file.. ... do you mean sensitive as in responsive, or sensible as in realistic? I bet it's the first one....
|
|
|
|