Rank: Newbie
Groups: Registered, Registered Users Joined: 6/19/2005(UTC) Posts: 6 Location: Indianapolis,IN
|
Hello there,
First of all, I wanna say thank you to Patrick and everyone else who does great job of making this forum a useful tool. I have learned a lot from here. I have a qeustion about this formula I wrote:
Market := Security("c:\\MetaStock Data\\Indices & Indicators\\Us & Canadian Indices\\.dji",(H+L)/2);
Up := If(Market>Ref(Market,-1),abs(Market-Ref(Market,-1)),0);
Dn :=If(Market<Ref(Market,-1),abs(Market-Ref(Market,-1)),0);
Dt := Wilders(Dn,9);
RSIt := 100*((Wilders(Up,9))/((Wilders(Up,9))+Dt));
Mmup := BarsSince(RSIt>70);
Mmdown := BarsSince(RSIt<30);
{security trend}
Up := BarsSince(RSI(9)>70);
Down := BarsSince(RSI(9)<30);
{market trading range}
Trading := Mmup<Mmdown AND LLV(RSIt , Mmup)<40 AND RSIt>30
OR Mmdown<Mmup AND HHV(RSIt,Mmdown)>60 AND RSIt<70;
{market trending up}
Trendingup := Mmup<Mmdown AND LLV(RSIt,Mmup)>40;
{market trending down}
Trendingdown := Mmup>Mmdown AND HHV(RSIt,Mmdown)<60;
Test := trendingup OR trendingdown;
Everything works fine except HHV and LLV, Metastock explorer wont accept it because its saying "The variable or expression must contain only constant data". Mmup is a constant!!! I mean its a variable, but its value is Numeric. How do i make this work?
Thanks a bunch.
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Unverified Users Joined: 1/13/2005(UTC) Posts: 87 Location: perth australia
|
Try this
make your given formula as an indicator. Name in x in the indicator builder.
then go to the explorer and open a new exploration. enter fml("x") in the filter section. This should work.ust remember that after your last line of the indicator you gave us add TEST ie
Market := Security("c:\\MetaStock Data\\Indices & Indicators\\Us & Canadian Indices\\.dji",(H+L)/2);
Up := If(Market>Ref(Market,-1),abs(Market-Ref(Market,-1)),0);
Dn :=If(Market<Ref(Market,-1),abs(Market-Ref(Market,-1)),0);
Dt := Wilders(Dn,9);
RSIt := 100*((Wilders(Up,9))/((Wilders(Up,9))+Dt));
Mmup := BarsSince(RSIt>70);
Mmdown := BarsSince(RSIt<30);
{security trend}
Up := BarsSince(RSI(9)>70);
Down := BarsSince(RSI(9)<30);
{market trading range}
Trading := Mmup<Mmdown AND LLV(RSIt , Mmup)<40 AND RSIt>30
OR Mmdown<Mmup AND HHV(RSIt,Mmdown)>60 AND RSIt<70;
{market trending up}
Trendingup := Mmup<Mmdown AND LLV(RSIt,Mmup)>40;
{market trending down}
Trendingdown := Mmup>Mmdown AND HHV(RSIt,Mmdown)<60;
Test := trendingup OR trendingdown;
TEST
Cheers
Norman
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 1/19/2005(UTC) Posts: 1,065 Location: Koh Pha-Ngan, Earth
Was thanked: 2 time(s) in 2 post(s)
|
zalakinc wrote:Mmup is a constant!!!
Nope, Mmup is a variable - it changes from bar to bar. 8:-)
Try this:
[code:1:d7a99f72fc]
xHi:=Security("c:\\MetaStock Data\\Indices & Indicators\\Us & Canadian Indices\\.dji",H);
xLo:=Security("c:\\MetaStock Data\\Indices & Indicators\\Us & Canadian Indices\\.dji",L);
Market:=LastValue((xHi+xLo)/2+PREV-PREV);
Up:= If(Market>Ref(Market,-1),abs(Market-Ref(Market,-1)),0);
Dn:=If(Market<Ref(Market,-1),abs(Market-Ref(Market,-1)),0);
Dt:= Wilders(Dn,9);
RSIt:= 100*((Wilders(Up,9))/((Wilders(Up,9))+Dt));
Mmup:= BarsSince(RSIt>70);
Mmdown:= BarsSince(RSIt<30);
{security trend}
Up:= BarsSince(RSI(9)>70);
Down:= BarsSince(RSI(9)<30);
{market trading range}
Trading:= Mmup<Mmdown AND LLV(RSIt , Mmup)<40 AND RSIt>30
OR
Mmdown<Mmup AND HHV(RSIt,Mmdown)>60 AND RSIt<70;
{market trending up}
Trendingup := Mmup<Mmdown AND LLV(RSIt,Mmup)>40;
{market trending down}
Trendingdown := Mmup>Mmdown AND HHV(RSIt,Mmdown)<60;
Test := trendingup OR trendingdown;[/code:1:d7a99f72fc]
jose '-)
http://metastocktools.com/#metastock
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Unverified Users Joined: 1/13/2005(UTC) Posts: 87 Location: perth australia
|
Hi Jose,
Your formula still shows up the error message "This variable or expression must contain only constant data." referring to this part of your formula
LLV(RSIt , Mmup)
Cheers
Norman
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 1/19/2005(UTC) Posts: 1,065 Location: Koh Pha-Ngan, Earth
Was thanked: 2 time(s) in 2 post(s)
|
Sorry, Norman - coding MFL without MetaStock is not a good idea for me. :?
Oki, try this:
[code:1:d0b735545a]
xHi:=Security("c:\\MetaStock Data\\Indices & Indicators\\Us & Canadian Indices\\.dji",H);
xLo:=Security("c:\\MetaStock Data\\Indices & Indicators\\Us & Canadian Indices\\.dji",L);
Market:=(xHi+xLo)/2;
Up:= If(Market>Ref(Market,-1),abs(Market-Ref(Market,-1)),0);
Dn:=If(Market<Ref(Market,-1),abs(Market-Ref(Market,-1)),0);
Dt:= Wilders(Dn,9);
RSIt:= 100*((Wilders(Up,9))/((Wilders(Up,9))+Dt));
Mmup:= LastValue(BarsSince(RSIt>70)+PREV-PREV);
Mmdown:= LastValue(BarsSince(RSIt<30)+PREV-PREV);
{security trend}
Up:= BarsSince(RSI(9)>70);
Down:= BarsSince(RSI(9)<30);
{market trading range}
Trading:= Mmup<Mmdown AND LLV(RSIt , Mmup)<40 AND RSIt>30
OR
Mmdown<Mmup AND HHV(RSIt,Mmdown)>60 AND RSIt<70;
{market trending up}
Trendingup := Mmup<Mmdown AND LLV(RSIt,Mmup)>40;
{market trending down}
Trendingdown := Mmup>Mmdown AND HHV(RSIt,Mmdown)<60;
Test := trendingup OR trendingdown;[/code:1:d0b735545a]
jose '-)
http://metastocktools.com/#metastock
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Unverified Users Joined: 1/13/2005(UTC) Posts: 87 Location: perth australia
|
Problem still there Jose :shock:
|
|
|
|
Rank: Newbie
Groups: Registered, Registered Users Joined: 6/19/2005(UTC) Posts: 6 Location: Indianapolis,IN
|
Friends,
Thanks for replying but still the same exact error :cry:
|
|
|
|
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)
|
Maybe people ought to be geting back to the basics again?
Lets all refer back to the MS Users Manual, and look at the available functions, particularly the LowestSince() function.
Try:
--8<------------------------
prd:=9;
Market := Security("c:\\MetaStock Data\\Indices & Indicators\\Us & Canadian Indices\\.dji",(H+L)/2);
Up := If(Market>Ref(Market,-1),abs(Market-Ref(Market,-1)),0);
Dn :=If(Market<Ref(Market,-1),abs(Market-Ref(Market,-1)),0);
RSIt := 100*((Wilders(Up,prd))/((Wilders(Up,prd))+Wilders(Dn,prd)));
Mmup := BarsSince(RSIt>70);
Mmdown := BarsSince(RSIt<30);
{market trending up}
Trendingup := Mmup<Mmdown AND LowestSince(1,Mmup=0,RSIt)>40;
{market trending down}
Trendingdown := Mmup>Mmdown AND HighestSince(1,Mmdown=0,RSIt)<60;
trendingup-trendingdown;
--8<------------------------
wabbit :D
P.S. This post does not apply to Jose, unless in his I-am-off-on-holidays-bag he packed his copy of the MS Bible!
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 1/19/2005(UTC) Posts: 1,065 Location: Koh Pha-Ngan, Earth
Was thanked: 2 time(s) in 2 post(s)
|
Excellent coding, and all done without PREV functions! :wink:
jose '-)
|
|
|
|
Rank: Newbie
Groups: Registered, Registered Users Joined: 6/19/2005(UTC) Posts: 6 Location: Indianapolis,IN
|
Humm, Looked at the code, but it doesnt exactly achieve LLV. May be I am not smart enough to understand it. I thought of another way to do it though. I decided to just use AND and OR operators...e.g. LLV(A,B) < 40 replaced with A<40 or B<40. HHV(A,B) < 40 would be A<40 and B<40.
|
|
|
|
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.