Value since condition |
Post Reply |
Author | |
matt
Newbie Joined: 30 Jun 2006 Posts: 4 |
Post Options
Quote Reply
Topic: Value since condition Posted: 30 Jun 2006 at 4:04pm |
Hi, Can anyone please help me with this? I would like to show only the first value since a condition and not subsequent values, which may be separated by variable time periods. Such a formula might be written as:
Unfortunately anytrue can only accept an interger as its second parameter. Is there anyway to return :
Thanks in advance. |
|
chart rider
Regular Joined: 25 Sep 2004 Location: Australia Posts: 96 |
Post Options Quote Reply Posted: 30 Jun 2006 at 8:29pm |
Matt When I read the first line of your post, I thought I understood the question, but then the next few lines confused me. Can you give an example of what you are trying to do. CR |
|
matt
Newbie Joined: 30 Jun 2006 Posts: 4 |
Post Options Quote Reply Posted: 03 Jul 2006 at 5:12pm |
CB, Basically I want to show a marker on the first value triggered by a set of criteria since a specific condition. The criteria (and therefore marker) may occur multiple times after the condition and at varying time periods, however i want to show only the first occurrence. Sorry for being unclear previously. Matt |
|
chart rider
Regular Joined: 25 Sep 2004 Location: Australia Posts: 96 |
Post Options Quote Reply Posted: 04 Jul 2006 at 5:27pm |
matt example: 1. The condition required: EMA 20 is above EMA 50 2. The criteria: Close crosses the EMA 10 The following code will identify the first time the criteria is met each time the condition is true: condition := ma(C, 20, E) > ma(C, 50, E); criteria := condition and cross(C, ma(C, 10, E)); criteriaSet := if(criteria, 1, max(prev and condition, 0)); criteriaMarker := criteriaSet and hist(criteriaSet,1)=0; [linestyle=bar; width=2] criteriaMarker; CR |
|
matt
Newbie Joined: 30 Jun 2006 Posts: 4 |
Post Options Quote Reply Posted: 04 Jul 2006 at 9:54pm |
Thanks CR but this will return the 1st marker only if the condition is met on consecutive bars. A condition (e.g. if the slope of a linear regression line over 3 bars[expr1] > 0 [cond2] and I wish to show only the first occurrence of this after crossing a moving average of 200 bars [cond1]) this might occur intermittently as the price varies up and down and triggering markers separated by variable no.s of bars. So the problem arises when using "hist(criteriaSet,n)=0, if condition2 occurs more than once after condition1 is met but not exactly n bars from its first occurrence then it will trigger another marker. If I could write; not anytrue(cond2,barssince(n,cond1,expr1)); then the problem should be solved, however anytrue only acccepts an integer as its second variable. Maybe the only way around this problem is for some BC staff wizard to rework the anytrue code. Anyway thanks for your time so far, if you can think of any other ideas I'd appreciate it. Regards, Matt
|
|
Post Reply |
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |