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

Notification

Icon
Error

Options
Go to last post Go to first unread
samjohn  
#1 Posted : Tuesday, September 11, 2012 7:53:05 AM(UTC)
samjohn

Rank: Member

Groups: Registered, Registered Users
Joined: 8/30/2012(UTC)
Posts: 11

Documentation says that speed will improve if formulas are saved into variable, but practically. script 1 runs slower than scrip2. It gets worse if you use fmlvar. any remedy? {script1} r1 := MOV(C,12,E); r2 := MOV(C,26,E); r3 := r1 - r2; r3; r4 := mov(r3,9,E); ============= {script2} MOV(C,12,E) - MOV(C,26,E); mov((MOV(C,12,E) - MOV(C,26,E)),9,E);
MS Support  
#2 Posted : Tuesday, September 11, 2012 2:56:09 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)
Using a variable does not automatically make the code faster but used properly, it does help, a lot.

I my opionion, a variable should be used:
- where a value is used through out a formula, like a number of periods. The variable makes it easy to keep the code consistent and allows quick edits

- for key sections of complex code. By breaking the code into sections, the logic of the formula is easier to read. for example:

Code:

con1:= Stoch(16,8) - Mov(Stoch(16,8),8,S) > 0;
con2:= (RSI(7) + RSI(14) + RSI(21))/3 > 70;
con3:= MACD() - Mov(MACD(),9,E) > 0;
con4:= Cross( C, Mov(MP(), 40, S) );
con5:= Cross( Mov(typical(), 20, E), C);
if(con1 AND con2 AND con4, 1, if( con3 and con5, -1, prev))


That formula is contrived and not meant as a valid signal but it does show how messy code can get. The last line, without variables could be confusing to read and sort out.

- variables can be used for Security(), Fml(), and FmlVar() function calls. These slow down the calculation of formulas. I have also seen odd results when they are used in the middle of a formula. However, if they are called once at the top of a formula and the the variable used as needed, the calcualtion runs much smoother
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.