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

Notification

Icon
Error

Options
Go to last post Go to first unread
gorachand  
#1 Posted : Thursday, January 1, 2015 5:07:20 PM(UTC)
gorachand

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 2/19/2012(UTC)
Posts: 106

Thanks: 1 times
Was thanked: 1 time(s) in 1 post(s)
De Mark qualifies a buy entry for his REI indicator thus(indicator will plot 1)
1)The TD ReI must be below -40 for six or fewer periods
2)An up close day
3)Opening price on trading day after up close day<= up close days high
4)Same trading day high must exceed previous trading day True High


I wrote the code thus

A:=BarsSince(Fml( "De Marks REI")<-40)<=6;
B:=BarsSince( Fml( "Up Close")=1);
D:=B+1;

Z:=ValueWhen(1,(B=1),H);

X:=Ref(O,-D)<=Z;
Q:=ValueWhen(1,(B+1), Fml( "True High"));
Y:=Ref(H,-D)>Q);

J:=A AND X AND Y;
{Plot}
J;

The Debugging Error Metastock gives is that it refuses to recognize a character instead of a numerical value in the Ref function---'This variable or expression must contain only constant data'

Can anybody help me?


Edited by user Thursday, January 1, 2015 5:08:20 PM(UTC)  | Reason: Not specified

MS Support  
#2 Posted : Friday, January 2, 2015 3:35:41 PM(UTC)
MS Support

Rank: Advanced Member

Groups: Moderators, Registered, Registered Users, Subscribers
Joined: 10/8/2010(UTC)
Posts: 1,960

Thanks: 92 times
Was thanked: 155 time(s) in 150 post(s)
There are a couple problems in the formula but the main problem I would expect to come from: "This variable or expression must contain only constant data." Sometimes you can get away with using the "LastValue" function around -D in your formula but you would want to check and make sure the formula is in fact still calculating correctly. You also have an extra right parentheses at the end of your "Y" line. X:=Ref(O,LastValue(-D))<=Z; Q:=ValueWhen(1,(B+1), Fml( "True High")); Y:=Ref(H,LastValue(-D))>Q;
mstt  
#3 Posted : Friday, January 2, 2015 9:09:55 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 gorachand MS Support is correct about sometimes being able to use LastValue(). However this is only useful if it's the last last value of D that you actually want for all bars. Nevertheless there is a trick from way back that allows you to convert D to all of the appropriate values. This is done by adding a "neutralized" PREV as shown below. X:=Ref(O,LastValue(-D))<=Z; Q:=ValueWhen(1,(B+1), Fml( "True High")); Y:=Ref(H,LastValue(-D+PREV-PREV))>Q; The use of PREV forces D to be recalculated for each bar, and +PREV-PREV generates a zero result. Adding and subtracting PREV does not change the value of D because -PREV negates +PREV. There's just one problem that you need to be aware of - this method sometimes produces a result that is "slightly off". A solution to fix the problem is to replace the "+PREV-PREV" expression with "+PREV*0". X:=Ref(O,LastValue(-D))<=Z; Q:=ValueWhen(1,(B+1), Fml( "True High")); Y:=Ref(H,LastValue(-D+PREV*0))>Q; Unfortunately the loss of one PREV does not speed up execution speed. This solution also works for all of the "PREV heavy" MS11 adaptive indicators that were first introduced with MetaStock version 11. Sadly those indicators have bigger problems than the use (or otherwise) of PREV, but this is not the place to expand on that theme. Roy
thanks 1 user thanked mstt for this useful post.
MS Support on 1/2/2015(UTC)
gorachand  
#4 Posted : Saturday, January 3, 2015 8:45:34 AM(UTC)
gorachand

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 2/19/2012(UTC)
Posts: 106

Thanks: 1 times
Was thanked: 1 time(s) in 1 post(s)

Dosn't seem to work. I am talking of the final signal.
I tried out both codes---both Mr.Roy's and MS Support---but the results are erratic.
De Mark is too experienced an analyst to come up with a faulty entry condition.
Obviously the code must be wrong somewhere.
Here are my custom indicators

De Marks REI (Copied from the net---more or less tested accurate)

TD1:= H-Ref(H,-2);
TD2:= L-Ref(L,-2);
TD3:= If((H>=Ref(L,-5) OR H>=Ref(L,-6)) AND (L<=Ref(H,-5) OR L<=Ref(H,-6)),1,0);
TD4:= If((Ref(H,-2)>=Ref(C,-7) OR Ref(H,-2)>=Ref(C,-8)) AND (Ref(L,-2)<=Ref(C,-7) OR Ref(L,-2)<=Ref(C,-8)),1,0);
TD6:= (TD1) + (TD2);
TD5:= If((TD3) + (TD4)>=1, (TD6), 0);
TD7:= Abs(TD1) + Abs(TD2);
TDREI:=((TD5) + Ref(TD5,-1) + Ref(TD5,-2) + Ref(TD5,-3) + Ref(TD5,-4))/ (TD7 + Ref(TD7,-1) + Ref(TD7,-2) + Ref(TD7,-3) + Ref(TD7,-4))*100;
TDREI;

True High

Max(H,Ref(C,-1))

Up Close

C>Ref(C,-1)

Here is the text from Jason Perls book on De Mark Indicators

To Initiate a Buy Signal:
1. The TD ReI must be below -40 for six or fewer periods;
2. There must be a lower close than the close of the prior price bar;
3. The open of the next price bar must be less than, or equal to, the two prior price
highs; and
4. The market must trade above the open and post a high above either one of the
prior two price highs

In De Marks own book --condition 3 is an Up Close instead of a down close. I have experimented with both---results still erratic
Users browsing this topic
Guest (Hidden)
Similar Topics
de marks combo (Formula Assistance)
by gorachand 7/17/2015 5:07:27 PM(UTC)
De Mark Count Down Buy (Formula Assistance)
by gorachand 12/30/2013 10:29:49 PM(UTC)
De Mark Count Down (General Chat)
by gorachand 12/22/2013 5:07:09 AM(UTC)
De Mark's Differential Indicator (Formula Assistance)
by gorachand 5/21/2013 4:29:01 AM(UTC)
De Marks Differential Indicator (Basic Coding Techniques)
by gorachand 5/20/2013 11:37:36 AM(UTC)
De Marker 2 (Formula Assistance)
by gorachand 11/17/2012 10:23:48 PM(UTC)
De Mark Supply line (Formula Assistance)
by gorachand 11/17/2012 10:19:12 PM(UTC)
De Mark's Seq Trading System (Advanced Coding Techniques)
by Asimov 1/24/2007 9:55:17 AM(UTC)
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.