logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
mstt  
#1 Posted : Friday, January 6, 2006 7:28:32 AM(UTC)
mstt

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 7/25/2005(UTC)
Posts: 1,042

Was thanked: 57 time(s) in 54 post(s)
The following Q Indicator has been sourced from the Equis website but with one small adjustment (see point 2 below). This code and the original B Indicator provide the model on which the revised indicators have been based. There are several points about the basic Q Indicator that are worthy of note, and these are listed and commented on below. {Q-indicator} m:=Input("% Scalar trend period",1,25,4); n:=Input("% Scalar noise period",1,500,250); cf:=Input("% Scalar correction factor",1,250,2); p1:=Input("First moving average periods",1,200,7); p2:=Input("Second moving average periods",1,200,15); rev:=Mov(C,p1,E)-Mov(C,p2,E); pds:=If(rev>0,1,-1); dc:=ROC(C,1,$); cpc:=If(pds<>Ref(pds,-1),0,(dc {*pds} )+PREV); trend:=If(pds<>Ref(pds,-1),0,(cpc*(1/m))+(PREV*(1-(1/m)))); dt:=cpc-trend; noise:=cf*Sqrt(Mov(dt*dt,n,S)); trend/noise; 1. The default "n" setting is 250 periods. 2. The "cpc" variable has had the "*pds" expression commented out. 3. The "cpc" variable contains a PREV function. 4. The "trend" variable also contains a PREV function. There are several implications arising from these points. The first is that this indicator will not plot any value with the current default settings unless 265 or more data bars are loaded. This requires more than 1 year of EOD data or 5 years of weekly data – a fact that makes it less than useful with many securities. For item 2 it can easily be demonstrated that Q fails to plot most trending-down values as negative unless the "pds" multiplier in the "cpc" variable is commented out or removed completely. The PREV functions noted in items 3 and 4 can (and do) seriously affect execution speed, particularly when exploring or testing large amounts of historical data. The "cpc" variable is simply a counter that can be replaced by code not requiring the PREV function. The "trend" variable is essentially a re-settable exponential moving average, and this can be replaced by an EMA generated by the Forum DLL. A modifier for the "trend" variable has been added to the non-PREV (NP) versions of B and Q, and its purpose is simply to ensure an exact match between PREV and non-PREV versions when plotted on the same data. With the same user settings. An "n" variable modifier has also been added, though currently disabled, and its purpose is to reduce the "n" parameter in the "noise" variable when otherwise insufficient data is loaded. This allows the indicator to return a legitimate value rather than an N/A value for many securities having less than the optimum amount of data. Results generated using a lesser amount of data might be less accurate than desirable, but a valid plot is probably of more use than an invalid one. I suggest that the default for the "n" variable be reduced to 100 for weekly data, whether or not the modifier is enabled. The Forum DLL exponential moving average permits an EMA to be reset or reseeded at appropriate times whereas the standard MetaStock Mov() function does not permit such an action. Note that some versions of the B and Q indicators in circulation use an exponential moving average in the "noise" variable, while other use a simple moving average. Check this if you have difficulty matching your B and Q indicators values to agree with the following formulas. {B Indicator NP} {Trend-Noise Balance} m:=Input("% Scalar trend period",2,25,4); n:=Input("% Scalar noise period",2,500,250); cf:=Input("% Scalar correction factor",1,250,2); p1:=Input("First moving average periods",1,200,7); p2:=Input("Second moving average periods",1,200,15); pds:=Mov(C,p1,E)>Mov(C,p2,E); pds:=pds<>ValueWhen(2,1,pds); dc:=ROC(C,1,$); init:=Cum(pds>-1)=1; cdc:=Cum(dc); cpc:=cdc-ValueWhen(1,init+pds,cdc); trend:=ExtFml("Forum.MOV",cpc,If(pds,1,2*m-1),E); trend:=If(Sum(trend,2)=Sum(trend,2),trend,trend); {adds an invalid bar} dt:=cpc-trend; {n:=LastValue(Min(Cum(1)-2*p2,n));} {adjusts "n" if not enough bars are loaded} noise:=Sqrt(Mov(dt*dt,n,S)); noise:=If(Abs(trend)+Abs(noise)=0,1,Abs(trend)+Abs(noise)); 100*Abs(trend)/noise; {Q Indicator NP} {Trend Quality} m:=Input("% Scalar trend period",2,25,4); n:=Input("% Scalar noise period",2,500,250); cf:=Input("% Scalar correction factor",1,250,2); p1:=Input("First moving average periods",1,200,7); p2:=Input("Second moving average periods",1,200,15); pds:=Mov(C,p1,E)>Mov(C,p2,E); pds:=pds<>ValueWhen(2,1,pds); dc:=ROC(C,1,$); init:=Cum(pds>-1)=1; cdc:=Cum(dc); cpc:=cdc-ValueWhen(1,init+pds,cdc); trend:=ExtFml("Forum.MOV",cpc,If(pds,1,2*m-1),E); trend:=If(Sum(trend,2)=Sum(trend,2),trend,trend); {adds an invalid bar} dt:=cpc-trend; {n:=LastValue(Min(Cum(1)-2*p2,n));} {adjusts "n" if not enough bars are loaded} noise:=cf*Sqrt(Mov(dt*dt,n,S)); trend/noise; Roy MetaStock Tips & Tools
billtrudeau  
#2 Posted : Friday, January 6, 2006 1:27:32 PM(UTC)
billtrudeau

Rank: Advanced Member

Groups: Registered, Registered Users, Unverified Users
Joined: 4/27/2005(UTC)
Posts: 132
Location: Manchester, NH

Hi Roy, I don't know if you intentionally reworked the B-Indicator, but the last several lines of your code are not as indicated on the Equis website. The original code in Stocks & Commodities was wrong. The attached e-mail from equis contains the corrected code which is now reflected on the Equis website. Bill, I'm sorry this took so long, but I finally found and corrected the problem in the B-indicator. part of the reason it took so long was an oversight on my part. I was trying to match the chart in the article and had my formulas using a 7 and 15 period moving average, as was done on the Q-indicator chart. I could not figure out why my formulas was not matching and literally spent day and weeks going over the math. When I finally found the text in the article that said they were using 10 and 40 for that chart, everything immediately matched. I had the right answer for a couple of months buy did not realize it. Here is the correct MetaStock formula for the B-indicator: m:=Input("% Scalar trend period",1,25,4); n:=Input("% Scalar noise period",1,500,250); cf:=Input("% Scalar correction factor",1,250,2); p1:=Input("First moving average periods",1,200,7); p2:=Input("Second moving average periods",1,200,15); rev:=Mov(C,p1,E)-Mov(C,p2,E); pds:=If(rev>0,1,-1); dc:=ROC(C,1,$); cpc:=If(pds<>Ref(pds,-1),0,(dc*pds)+PREV); trend:=If(pds<>Ref(pds,-1),0,(cpc*(1/m))+(PREV*(1-(1/m)))); dt:=cpc-trend; noise:=cf*Sqrt(Mov(dt*dt,n,S)); temp:=If(Abs(trend)+Abs(noise)=0,1,Abs(trend)+Abs(noise)); (Abs(trend)/temp)*100; William Golson Equis Support
mstt  
#3 Posted : Friday, January 6, 2006 7:28:04 PM(UTC)
mstt

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 7/25/2005(UTC)
Posts: 1,042

Was thanked: 57 time(s) in 54 post(s)
Hi Bill In my non-PREV version of the B Indicator the "cf" multiplier was inadvertently omitted from the first definition of "noise". This was a mistake on my part which I did not pick up because my testing was done using a default value of 1 for "cf". Here is the corrected code. {B Indicator NP} {Trend-Noise Balance} m:=Input("% Scalar trend period",2,25,4); n:=Input("% Scalar noise period",2,500,250); cf:=Input("% Scalar correction factor",1,250,2); p1:=Input("First moving average periods",1,200,7); p2:=Input("Second moving average periods",1,200,15); pds:=Mov(C,p1,E)>Mov(C,p2,E); pds:=pds<>ValueWhen(2,1,pds); dc:=ROC(C,1,$); init:=Cum(pds>-1)=1; cdc:=Cum(dc); cpc:=cdc-ValueWhen(1,init+pds,cdc); trend:=ExtFml("Forum.MOV",cpc,If(pds,1,2*m-1),E); trend:=If(Sum(trend,2)=Sum(trend,2),trend,trend); {adds an invalid bar} dt:=cpc-trend; {n:=LastValue(Min(Cum(1)-2*p2,n));} {adjusts "n" if not enough bars are loaded} noise:=cf*Sqrt(Mov(dt*dt,n,S)); noise:=If(Abs(trend)+Abs(noise)=0,1,Abs(trend)+Abs(noise)); 100*Abs(trend)/noise; Other differences are deliberate. The use of "*pds" in the original "cpc" variable has no effect on the B Indicator but it does have an effect on the Q Indicator. That effect is that, for the most part, Q fails to plot negative values on down trends (its plot does not agree with that shown on the Equis website). Removing "*pds" solves the problem with Q, and that expression is redundant in B so, in or out, it makes no difference. Removing the first PREV required a reorganisation of the code making up the "cpc" variable, so the removal of "*pds" from "cpc" is not obvious in either of the non-PREV versions. The major changes from the Equis versions are that both PREVs have been removed. This means that explorations and sytem tests will run much faster. I am indebted to Patrick for the hard work he put in creating the Forum dll and adjusting the moving average function - the crucial element eliminating PREV from the "trend" variable. Roy MetaStock Tips & Tools
billtrudeau  
#4 Posted : Friday, January 6, 2006 7:38:46 PM(UTC)
billtrudeau

Rank: Advanced Member

Groups: Registered, Registered Users, Unverified Users
Joined: 4/27/2005(UTC)
Posts: 132
Location: Manchester, NH

So, I guess that it is valid to reuse the noise label in successive statements, as you did, when using the MetaStock Formula Language, versus using the temp label as Equis did?
mstt  
#5 Posted : Friday, January 6, 2006 8:17:35 PM(UTC)
mstt

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 7/25/2005(UTC)
Posts: 1,042

Was thanked: 57 time(s) in 54 post(s)
Hi Bill Yes, a variable name can be reused when modifying a previous definition, and if a previous definition is no longer needed (in the flow of the formula) then the variable name can be used for a completely different purpose. It makes sense (to me at least) to use only one variable name when building up expression by stages, as with "noise". The reuse of variables names is the key to breaking through the 20-variable restriction. You can have as many variables as space will allow providing you do not use more than 20 names. As long as you don't reuse (overwrite) a name before you're finshed using it there's not a problem. Roy MetaStock Tips & Tools
kingsley29  
#6 Posted : Friday, January 6, 2006 11:37:44 PM(UTC)
kingsley29

Rank: Member

Groups: Registered, Registered Users, Subscribers
Joined: 10/30/2005(UTC)
Posts: 14

Dear Roy, Thank you very much for email me the B and Q indicators. Since the beginning, I told Gordon of Equis that the indicators were errors. It took him awhile to correct these. Now, it is better because you remove the PREV. Thanks again.
FXLearning  
#7 Posted : Saturday, January 7, 2006 3:54:45 PM(UTC)
FXLearning

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 1/1/2006(UTC)
Posts: 39

Roy, I just tried your version of the Q & the B. Very nice. :) These are probably among some of the best indicators that I know. Would you happen to know of any other indicators that deal with lag, noise, or time cycles? Regards, FXLearning PS Patrick I tried these indicators with the forum dll, and they appear to be working ok; however, I am nobody to judge.
Patrick  
#8 Posted : Saturday, January 7, 2006 4:20:38 PM(UTC)
Patrick

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 9/8/2004(UTC)
Posts: 2,266

Was thanked: 1 time(s) in 1 post(s)
Quote:
Patrick I tried these indicators with the forum dll, and they appear to be working ok; however, I am nobody to judge.
Thanks for the feedback ;) You have every right to judge as a forum member ... Patrick :mrgreen:
FXLearning  
#9 Posted : Saturday, January 7, 2006 5:05:53 PM(UTC)
FXLearning

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 1/1/2006(UTC)
Posts: 39

Does anyone know if it is possible to use these indicators from a lower time frame into a higher time frame or the other way (from a higher time frame into a lower time frame)? For instance, on the daily charts I can have several days or weeks with a buy or sell signal. I would presume that a confirmation signal in the same direction as the daily chart from a lower time frame would help in narrowing the the entry or exit of a position. Regards, FXLearning
mstt  
#10 Posted : Sunday, January 8, 2006 7:41:42 PM(UTC)
mstt

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 7/25/2005(UTC)
Posts: 1,042

Was thanked: 57 time(s) in 54 post(s)
FXLearning I imagine it's possible to plot B and Q as weekly indicators on EOD charts but I don't think that anyone has done so as yet. It's not on my list of "things to do". Roy MetaStock Tips & Tools
FXLearning  
#11 Posted : Monday, January 9, 2006 9:04:10 AM(UTC)
FXLearning

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 1/1/2006(UTC)
Posts: 39

mstt wrote:
FXLearning I imagine it's possible to plot B and Q as weekly indicators on EOD charts but I don't think that anyone has done so as yet. It's not on my list of "things to do". Roy MetaStock Tips & Tools
Roy, Thank you. Do you have a way of filtering signals in intraday time charts? I get several false signals with it. Perhaps, I am not using it correctly. Regards, FXLearnin
mstt  
#12 Posted : Monday, January 9, 2006 6:50:43 PM(UTC)
mstt

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 7/25/2005(UTC)
Posts: 1,042

Was thanked: 57 time(s) in 54 post(s)
FXLearning I can't help you with "filtering" but you could experiment with different default settings. The B and Q indicators normally reset when 7 and 15 period EMAs cross over so it's hardly surprising that ther are some false signals. The PREV versions should give the same false signals so the changes I made should not be at issue. Roy MetaStock Tips & Tools
FXLearning  
#13 Posted : Tuesday, January 10, 2006 8:19:10 AM(UTC)
FXLearning

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 1/1/2006(UTC)
Posts: 39

Roy, Thank you. What I meant is that perhaps the trigger values that I am using are not the right ones. I wouldn't know about the programming part. For instance, The Trend Quality Indicator (Q-Indicator) is an assessment tool that estimates Trend in relation to Noise. The approach allows to reveal trending and ranging periods of the price movement, and to focus on the most important trends, evaluating their strength in the process. The Q-Indicator is a centered oscillator that fluctuates around a zero line with no upper or lower limits. The greater is the Q-factor, the less is the risk of trading with a trend, and the more reliable is the trading opportunity. To determine the strength of a trend the following benchmarks are used. In the range of values from (-1) to (+1) we have a non-trending zone. The range from (+1) to (+2), or from (-1) to (-2) may be treated as zone of weak trending. Readings in the range from (+2) to (+5), or from (-2) to (-5), can indicate moderate trending, and readings above Q = +5, or below Q = -5, - strong trending. http://www.alticom.com/i...s/riskreturn.html#rr.tqi As you can see, this gives something like (-1 to 1, 1 to 2, -1 to -2, 2 to 5, and -2 to -5) five different zones for trading. I have been trying to figure out how to incorporate this together with the indicator. I, also, found the following: The Trend-Noise Balance Indicator (BQ-Indicator) relates trend to noise in a banded oscillator format. If the Q-Indicator fluctuates around a zero line with no upper or lower limits, BQ-Indicator is bounded with (+1) and (-1) levels. Its zero line suggests that the trend and noise are in equilibrium (trend is equal to noise). In the range of the indicator values from (- 0.5) to (+ 0.5) the trend is buried under noise and it is preferable to stay out of this zone. Levels (- 0.65, + 0.65) and (- 0.8, + 0.8) can be used, correspondingly, as moderate and strong trending benchmarks. The Q-Indicator and the BQ-Indicator both estimate the strength of a trend, but the BQ-Indicator better identifies overbought and oversold conditions. Another distinctive feature is that in BQ-Indicator a different algorithm for noise determination is employed. The latter is based on volatility and not on “price-trend” deviation approach I thought there was a discussion on this forum regarding this BQ-indicator; however, when I searched for it again, I was not able to find it. Regards, FXLearning
Baileydog  
#14 Posted : Friday, February 6, 2009 10:56:38 AM(UTC)
Baileydog

Rank: Newbie

Groups: Registered, Registered Users
Joined: 1/26/2009(UTC)
Posts: 6
Location: Canada

Hi,

When I tried to create this indicators at the bottom of your sheet, I got the following error.

This DLL does not exist in the MSX DLL folder.

What am I doing wrong? I am using EOD version 10.1.

Thanks

Baileydog

wabbit  
#15 Posted: : Friday, February 6, 2009 5:53:19 PM(UTC)
wabbit

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 10/28/2004(UTC)
Posts: 3,111
Location: Perth, Western Australia

Was thanked: 16 time(s) in 16 post(s)
Download the free forum.dll from the files section; there are instructions there in what folder the file must reside and how to use the library of functions.

wabbit [:D]

Baileydog  
#16 Posted : Saturday, February 7, 2009 4:15:41 PM(UTC)
Baileydog

Rank: Newbie

Groups: Registered, Registered Users
Joined: 1/26/2009(UTC)
Posts: 6
Location: Canada

OK..thanks..I'll see if I can figure out how to do this!

kmonteiro  
#17 Posted : Thursday, April 4, 2013 8:21:44 AM(UTC)
kmonteiro

Rank: Newbie

Groups: Registered, Registered Users, Subscribers
Joined: 4/4/2013(UTC)
Posts: 1

mstt

hi, i'm new in the forum. could someone share the indicator or the complete code? i'm trying to program, but i can not. i'm still learning to program.

thanks
Users browsing this topic
Guest (Hidden)
Forum Jump  
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.