Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/24/24 20:04
M1 Oversampling
by Petra. 04/24/24 10:34
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Data from CSV not parsed correctly
by EternallyCurious. 04/20/24 21:39
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (howardR, sleakz), 706 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
DominantPeriod,DominantPhase and HTTrendMode doubts... #436878
02/04/14 18:34
02/04/14 18:34
Joined: Nov 2013
Posts: 123
Mithrandir77 Offline OP
Member
Mithrandir77  Offline 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:

Code:
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: Mithrandir77] #436881
02/04/14 21:50
02/04/14 21:50
Joined: Jul 2013
Posts: 522
D
dusktrader Offline
User
dusktrader  Offline
User
D

Joined: Jul 2013
Posts: 522
I can't help you with the code part... but in my experience "BADFREE" usually means there is something wrong with LookBack (like not enough).

You can try commenting-out the LookBack and sometimes Zorro will assign it what it thinks it needs (that doesn't always work but worth a try).

Also LookBack should be an int, not var, I believe.

Re: DominantPeriod,DominantPhase and HTTrendMode doubts... [Re: dusktrader] #436895
02/05/14 08:48
02/05/14 08:48
Joined: Jul 2000
Posts: 27,982
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,982
Frankfurt
That is not the problem here, but a series must have a fixed number of elements. It can not change its number of elements from call to call, as you do with the series to HTTrendMode.

"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 don't know in detail what HTTrendmode does, as we did not program this function. But I suppose you normally want to know the trend of the price, so you give a price series here.

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 Offline OP
Member
Mithrandir77  Offline 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 wink This works:

Code:
int market_mode = HTTrendMode(series(price());



Originally Posted By: jcl

"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: Mithrandir77] #436961
02/06/14 15:44
02/06/14 15:44
Joined: Jul 2000
Posts: 27,982
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,982
Frankfurt
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.

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 Offline OP
Member
Mithrandir77  Offline OP
Member

Joined: Nov 2013
Posts: 123
Originally Posted By: jcl
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
M
Meini Offline
Newbie
Meini  Offline
Newbie
M

Joined: Jan 2018
Posts: 18
Quote:
"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....


Moderated by  Petra 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1