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

Notification

Icon
Error

Options
Go to last post Go to first unread
Ploufplouf  
#1 Posted : Thursday, July 8, 2010 3:16:02 PM(UTC)
Ploufplouf

Rank: Member

Groups: Registered, Registered Users, Subscribers
Joined: 9/19/2009(UTC)
Posts: 27

Is there a way to do a loop with an indicator...

For those who know C, I would like to do a such thing
for (i = 1; i <= 300; i++) {
Res += RSI(C, i);
}

Is it possible?
Is there a way to do a such loop?

Or I need to do dumb things like
Res += RSI(C, 1);
Res += RSI(C, 2);
Res += RSI(C, 3);...
With the MS buffer which is limited...
wabbit  
#2 Posted : Thursday, July 8, 2010 4:55:34 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)
vienna  
#3 Posted : Friday, July 9, 2010 1:33:51 AM(UTC)
vienna

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 12/14/2009(UTC)
Posts: 140
Location: Austria

I have tried to implement a loop with the help of the gv.dll (search forum for more information about this dll)

... but i get an error: "nested formula circular reference" - so i think it's not possible in metastock and you would have to programm the whole loop/indicator with msx...

i will post my code - maybe someone has an idea how to trick metastock to get over this circular reference...

formula wich starts the loop
formula: test_loop_start
{define loop settings}
start:=1;
end:=5;

{store variables}
ExtFml("gv.SetVar", "start", start);
ExtFml("gv.SetVar", "end", end);
ExtFml("gv.SetVar", "x", 0);

tmp:=Fml("test_loop"); {call loop}

x:=ExtFml("gv.GetVar", "x");
x
-
formula: test_loop

{get interator variable}
j:= ExtFml( "gv.GetVar", "start");
j:=j+1;

x:= ExtFml( "gv.GetVar", "x")+RSI(C, LastValue(j));
{store variable x - our result}
ExtFml("gv.SetVar", "x", x);
end:= ExtFml( "gv.GetVar", "end");
{if interator is less than end call loop again}
tmp:=If(j<end, Fml("test_loop_help"),0);

{store variable interator variable}
ExtFml("gv.SetVar", "start", j)
-
formula: test_loop_help
tmp:=Fml("test_loop");

Ploufplouf  
#4 Posted : Sunday, July 11, 2010 6:56:57 AM(UTC)
Ploufplouf

Rank: Member

Groups: Registered, Registered Users, Subscribers
Joined: 9/19/2009(UTC)
Posts: 27

Up!
Thanks vienna for your help! I will be looking for this dll and try it next week!

That's so sad to have a nice soft with complex formulas... but without a such basic feature....

:-(
wabbit  
#5 Posted : Sunday, July 11, 2010 7:08:29 AM(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)
MS uses fully evaluated system to execute the MSFL script, so loops cannot be achieved. Se http://forum.equis.com/forums/permalink/29634/29635/ShowThread.aspx#29635.


wabbit [:D]

Ploufplouf  
#6 Posted : Sunday, July 11, 2010 11:22:52 AM(UTC)
Ploufplouf

Rank: Member

Groups: Registered, Registered Users, Subscribers
Joined: 9/19/2009(UTC)
Posts: 27

Ok to use an external DLL with MSFL.

The problem is... that I don't think it's possible to call MS indicators from your external DLL...

That means you need to redevelop all the indicators you need.... that's not so easy with complex formulas...

For me it is an error of design, I am not even sure we will see a loop functionality in the next version of MS... Sad :'(




vienna  
#7 Posted : Monday, July 12, 2010 1:42:04 AM(UTC)
vienna

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 12/14/2009(UTC)
Posts: 140
Location: Austria

You can do something like the code below - but this is very inefficient and mad/sick ;-)
you have also to check if it's really doing what you want. (I have checked for an easy example - there it seemed to work - but who knows how metastock is parsing this code in background)

test_loop_call
start:=1;
end:=5;

tmp1:=ExtFml("gv.SetVar", "start", start);
tmp1:=ExtFml("gv.SetVar", "end", end);
tmp1:=ExtFml("gv.SetVar", "x", 0);

tmp:=Fml("test_loop_helper");

x:=ExtFml("gv.GetVar", "x");

x
--
test_loop_helper
tmp1:=Fml("test_loop");tmp1:=Fml("test_loop");tmp1:=Fml("test_loop");tmp1:=Fml("test_loop");tmp1:=Fml("test_loop");tmp1:=Fml("test_loop");tmp1:=Fml("test_loop");tmp1:=Fml("test_loop");tmp1:=Fml("test_loop");tmp1:=Fml("test_loop");tmp1:=Fml("test_loop");tmp1:=Fml("test_loop");tmp1:=Fml("test_loop");tmp1:=Fml("test_loop");tmp1:=Fml("test_loop");tmp1:=Fml("test_loop");tmp1:=Fml("test_loop");tmp1:=Fml("test_loop");tmp1:=Fml("test_loop");tmp1:=Fml("test_loop");tmp1:=Fml("test_loop");tmp1:=Fml("test_loop");tmp1:=Fml("test_loop");tmp1:=Fml("test_loop");tmp1:=Fml("test_loop");tmp1:=Fml("test_loop");tmp1:=Fml("test_loop");tmp1:=Fml("test_loop");tmp1:=Fml("test_loop");tmp1:=Fml("test_loop");tmp1:=Fml("test_loop");tmp1:=Fml("test_loop");tmp1:=Fml("test_loop");tmp1:=Fml("test_loop");tmp1:=Fml("test_loop");tmp1:=Fml("test_loop");tmp1:=Fml("test_loop");
--
test_loop
j:= ExtFml( "gv.GetVar", "start");
j:=j+1;

x1:= ExtFml( "gv.GetVar", "x");
x2:= x1+RSI(C, LastValue(j));

end:= ExtFml( "gv.GetVar", "end");
x:=If(j<=end, x2,x1);
tmp1:=ExtFml("gv.SetVar", "x", x);
tmp1:=ExtFml("gv.SetVar", "start", j)

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.