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...
|
|
|
|
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)
|
|
|
|
|
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");
|
|
|
|
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....
:-(
|
|
|
|
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)
|
|
|
|
|
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 :'(
|
|
|
|
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.