Help in changing my codes from series to matrix
Posted: Mon Mar 19, 2018 9:21 am
Hi,
Can anyone help me out to optimise my code?
I have been using series, but I found out that as the number of elements in the list get higher, it take hours to run this code.
I would like to use matrix. Any help will be greatly appreciated.
My code that I would like to change from using series to using matrix.
string clist = " lists" - up to 40 elements
string curlist = "Currency" - up to 2 elements
string list_eq = "gsd" - up to 21 elements
string certain = "CN" - up to 34 currencies
string scenario = "BB00 CC00 DD00 EE00 FF00 B00 BB25 CC25 DD25 EE25 FF25 B25 BB50 CC50 DD50 EE50 FF50 B50 BB75 CC75 DD75 EE75 FF75 B75 BB_75 CC_75 DD_75 EE_75 FF_75 BB_50 CC_50 DD_50 EE_50 FF_50 BB_25 CC_25 DD_25 EE_25 FF_25 L00 NN00 PP00 QQ00 RR00 SS00 L25 NN25 PP25 QQ25 RR25 SS25 L50 NN50 PP50 QQ50 RR50 SS50 L75 NN75 PP75 QQ75 RR75 SS75 "
for %a {scenario}
for %c {clist}
for %u {curlist}
for %x {list_eq}
for %i {certain}
if @isobject("zsc_"+%c+"_"+%u+"_"+%x+"_"+%i) then
smpl 1970w1 @now
series signal_{%a}_{%c}_{%u}_{%x}_{%i} = 0
scalar obs= @obs(signal_{%a}_{%c}_{%u}_{%x}_{%i})
smpl if zsc_{%c}_{%u}_{%x}_{%i} <> na
for !j=2 to obs
' when z > 2, go 100% short
if zsc_{%c}_{%u}_{%x}_{%i}(!j)>=!a_200 then signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j) = -!e_100
'when 1.75>Z<2 , stay in the original position or enter into a new 75% short position
else if (zsc_{%c}_{%u}_{%x}_{%i}(!j) < !a_200 and zsc_{%c}_{%u}_{%x}_{%i}(!j) >=!a_175 and signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j - 1) < -!e_75 ) then signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j) = signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j-1)
else if (zsc_{%c}_{%u}_{%x}_{%i}(!j) < !a_200 and zsc_{%c}_{%u}_{%x}_{%i}(!j) >=!a_175 and signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j - 1) >= -!e_75) then signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j) = -!e_75
'when 1.50>Z<1.75 , stay in the original position or enter into a new 50% short position
else if (zsc_{%c}_{%u}_{%x}_{%i}(!j) < !a_175 and zsc_{%c}_{%u}_{%x}_{%i}(!j) >=!a_150 and signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j - 1) < -!e_50) then signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j) = signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j-1)
else if (zsc_{%c}_{%u}_{%x}_{%i}(!j) < !a_175 and zsc_{%c}_{%u}_{%x}_{%i}(!j) >=!a_150 and signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j - 1) >= -!e_50) then signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j) = -!e_50
'when 1.4>Z<1.5 , stay in the original position or enter into a new 40% short position
else if (zsc_{%c}_{%u}_{%x}_{%i}(!j) < !a_150 and zsc_{%c}_{%u}_{%x}_{%i}(!j) >=!a_140 and signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j - 1) < -!e_40) then signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j) = signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j-1)
else if (zsc_{%c}_{%u}_{%x}_{%i}(!j) < !a_150 and zsc_{%c}_{%u}_{%x}_{%i}(!j) >=!a_140 and signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j - 1) >= -!e_40) then signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j) = -!e_40
'when 1.3>Z<1.4 , stay in the original position or enter into a new 30% short position
else if (zsc_{%c}_{%u}_{%x}_{%i}(!j) < !a_140 and zsc_{%c}_{%u}_{%x}_{%i}(!j) >=!a_130 and signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j - 1) < -!e_30) then signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j) = signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j-1)
else if (zsc_{%c}_{%u}_{%x}_{%i}(!j) < !a_140 and zsc_{%c}_{%u}_{%x}_{%i}(!j) >=!a_130 and signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j - 1) >= -!e_30) then signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j) = -!e_30
'when 1.25>Z<1.3 , stay in the original position or enter into a new 25% short position
else if (zsc_{%c}_{%u}_{%x}_{%i}(!j) < !a_130 and zsc_{%c}_{%u}_{%x}_{%i}(!j) >=!a_125 and signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j - 1) < -!e_25) then signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j) = signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j-1)
else if (zsc_{%c}_{%u}_{%x}_{%i}(!j) < !a_130 and zsc_{%c}_{%u}_{%x}_{%i}(!j) >=!a_125 and signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j - 1) >= -!e_25) then signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j) = -!e_25
'when 1>Z<1.25 stay in the original position or enter into a new 25% short position
else if (zsc_{%c}_{%u}_{%x}_{%i}(!j) < !a_125 and zsc_{%c}_{%u}_{%x}_{%i}(!j) >= !a_100 and signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j - 1) < -!e_00) then signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j) = signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j-1)
else if (zsc_{%c}_{%u}_{%x}_{%i}(!j) < !a_125 and zsc_{%c}_{%u}_{%x}_{%i}(!j) >= !a_100 and signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j - 1) >= -!e_00) then signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j) = -!e_00
'when 0.5>Z<1 and was in a short position, stay in the position otherwise zero position
else if (zsc_{%c}_{%u}_{%x}_{%i}(!j) < !a_100 and zsc_{%c}_{%u}_{%x}_{%i}(!j) >= s0 and signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j - 1) < 0) then signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j) = signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j-1)
else if (zsc_{%c}_{%u}_{%x}_{%i}(!j) < !a_100 and zsc_{%c}_{%u}_{%x}_{%i}(!j) >= s0 and signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j - 1) >= 0) then signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j) = 0
'when -0.5>Z<0.5 , don't enter into any position
else if (zsc_{%c}_{%u}_{%x}_{%i}(!j) < s0 and zsc_{%c}_{%u}_{%x}_{%i}(!j) > -s0) then signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j) = 0
'when -1.00 >Z<-0.5 and was in a long position, stay in that position, otherwise zero position
else if (zsc_{%c}_{%u}_{%x}_{%i}(!j) <=-s0 and zsc_{%c}_{%u}_{%x}_{%i}(!j) > - !a_100 and signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j - 1) > 0 ) then signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j) = signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j-1)
else if (zsc_{%c}_{%u}_{%x}_{%i}(!j) <= -s0 and zsc_{%c}_{%u}_{%x}_{%i}(!j) >- !a_100 and signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j - 1) <= 0) then signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j) = 0
'when -1.25>Z<-1.00, stay in that position or enter a % long position
else if (zsc_{%c}_{%u}_{%x}_{%i}(!j) <= -!a_100 and zsc_{%c}_{%u}_{%x}_{%i}(!j) >- !a_125 and signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j - 1) > !e_00) then signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j) = signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j-1)
else if (zsc_{%c}_{%u}_{%x}_{%i}(!j) <= -!a_100 and zsc_{%c}_{%u}_{%x}_{%i}(!j) >- !a_125 and signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j - 1) <= !e_00) then signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j) = !e_00
'when -1.30>Z<-1.25, stay in that position or enter at 25 % long position
else if (zsc_{%c}_{%u}_{%x}_{%i}(!j) <= -!a_125 and zsc_{%c}_{%u}_{%x}_{%i}(!j) > -!a_130 and signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j - 1) > !e_25 ) then signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j) = signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j-1)
else if (zsc_{%c}_{%u}_{%x}_{%i}(!j) <= -!a_125 and zsc_{%c}_{%u}_{%x}_{%i}(!j) > -!a_130 and signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j - 1) <= !e_25 ) then signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j) = !e_25
'when -1.30>Z<-1.25, stay in that position or enter at 30% long position
else if (zsc_{%c}_{%u}_{%x}_{%i}(!j) <= -!a_130 and zsc_{%c}_{%u}_{%x}_{%i}(!j) > -!a_140 and signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j - 1) > !e_30) then signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j) = signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j-1)
else if (zsc_{%c}_{%u}_{%x}_{%i}(!j) <= -!a_130 and zsc_{%c}_{%u}_{%x}_{%i}(!j) > -!a_140 and signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j - 1) <= !e_30) then signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j) = !e_30
'when -1.50>Z<-1.40, stay in that position or enter at 40% long position
else if (zsc_{%c}_{%u}_{%x}_{%i}(!j) <= -!a_140 and zsc_{%c}_{%u}_{%x}_{%i}(!j) > -!a_150 and signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j - 1) > !e_40 ) then signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j) = signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j-1)
else if (zsc_{%c}_{%u}_{%x}_{%i}(!j) <= -!a_140 and zsc_{%c}_{%u}_{%x}_{%i}(!j) > -!a_150 and signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j - 1) <= !e_40 ) then signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j) = !e_40
'when -1.75>Z<-1.50, stay in that position or enter at 50% long position
else if (zsc_{%c}_{%u}_{%x}_{%i}(!j) <= -!a_150 and zsc_{%c}_{%u}_{%x}_{%i}(!j) > -!a_175 and signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j - 1) > !e_50 ) then signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j) = signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j-1)
else if (zsc_{%c}_{%u}_{%x}_{%i}(!j) <= -!a_150 and zsc_{%c}_{%u}_{%x}_{%i}(!j) > -!a_175 and signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j - 1) <= !e_50 ) then signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j) = !e_50
'when -2>Z<-1.75, stay in that position or enter at 75% long position
else if (zsc_{%c}_{%u}_{%x}_{%i}(!j) <= -!a_175 and zsc_{%c}_{%u}_{%x}_{%i}(!j) > -!a_200 and signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j - 1) > !e_75) then signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j) = signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j-1)
else if (zsc_{%c}_{%u}_{%x}_{%i}(!j) <= -!a_175 and zsc_{%c}_{%u}_{%x}_{%i}(!j) > -!a_200 and signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j - 1) <= !e_75) then signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j) = !e_75
'when Z<-2 and was not in a long position, enter into a long position
else if zsc_{%c}_{%u}_{%x}_{%i}(!j)<=-!a_200 then signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j) = !e_100
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
next
endif
next
next
next
next
next
Can anyone help me out to optimise my code?
I have been using series, but I found out that as the number of elements in the list get higher, it take hours to run this code.
I would like to use matrix. Any help will be greatly appreciated.
My code that I would like to change from using series to using matrix.
string clist = " lists" - up to 40 elements
string curlist = "Currency" - up to 2 elements
string list_eq = "gsd" - up to 21 elements
string certain = "CN" - up to 34 currencies
string scenario = "BB00 CC00 DD00 EE00 FF00 B00 BB25 CC25 DD25 EE25 FF25 B25 BB50 CC50 DD50 EE50 FF50 B50 BB75 CC75 DD75 EE75 FF75 B75 BB_75 CC_75 DD_75 EE_75 FF_75 BB_50 CC_50 DD_50 EE_50 FF_50 BB_25 CC_25 DD_25 EE_25 FF_25 L00 NN00 PP00 QQ00 RR00 SS00 L25 NN25 PP25 QQ25 RR25 SS25 L50 NN50 PP50 QQ50 RR50 SS50 L75 NN75 PP75 QQ75 RR75 SS75 "
for %a {scenario}
for %c {clist}
for %u {curlist}
for %x {list_eq}
for %i {certain}
if @isobject("zsc_"+%c+"_"+%u+"_"+%x+"_"+%i) then
smpl 1970w1 @now
series signal_{%a}_{%c}_{%u}_{%x}_{%i} = 0
scalar obs= @obs(signal_{%a}_{%c}_{%u}_{%x}_{%i})
smpl if zsc_{%c}_{%u}_{%x}_{%i} <> na
for !j=2 to obs
' when z > 2, go 100% short
if zsc_{%c}_{%u}_{%x}_{%i}(!j)>=!a_200 then signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j) = -!e_100
'when 1.75>Z<2 , stay in the original position or enter into a new 75% short position
else if (zsc_{%c}_{%u}_{%x}_{%i}(!j) < !a_200 and zsc_{%c}_{%u}_{%x}_{%i}(!j) >=!a_175 and signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j - 1) < -!e_75 ) then signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j) = signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j-1)
else if (zsc_{%c}_{%u}_{%x}_{%i}(!j) < !a_200 and zsc_{%c}_{%u}_{%x}_{%i}(!j) >=!a_175 and signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j - 1) >= -!e_75) then signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j) = -!e_75
'when 1.50>Z<1.75 , stay in the original position or enter into a new 50% short position
else if (zsc_{%c}_{%u}_{%x}_{%i}(!j) < !a_175 and zsc_{%c}_{%u}_{%x}_{%i}(!j) >=!a_150 and signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j - 1) < -!e_50) then signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j) = signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j-1)
else if (zsc_{%c}_{%u}_{%x}_{%i}(!j) < !a_175 and zsc_{%c}_{%u}_{%x}_{%i}(!j) >=!a_150 and signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j - 1) >= -!e_50) then signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j) = -!e_50
'when 1.4>Z<1.5 , stay in the original position or enter into a new 40% short position
else if (zsc_{%c}_{%u}_{%x}_{%i}(!j) < !a_150 and zsc_{%c}_{%u}_{%x}_{%i}(!j) >=!a_140 and signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j - 1) < -!e_40) then signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j) = signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j-1)
else if (zsc_{%c}_{%u}_{%x}_{%i}(!j) < !a_150 and zsc_{%c}_{%u}_{%x}_{%i}(!j) >=!a_140 and signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j - 1) >= -!e_40) then signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j) = -!e_40
'when 1.3>Z<1.4 , stay in the original position or enter into a new 30% short position
else if (zsc_{%c}_{%u}_{%x}_{%i}(!j) < !a_140 and zsc_{%c}_{%u}_{%x}_{%i}(!j) >=!a_130 and signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j - 1) < -!e_30) then signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j) = signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j-1)
else if (zsc_{%c}_{%u}_{%x}_{%i}(!j) < !a_140 and zsc_{%c}_{%u}_{%x}_{%i}(!j) >=!a_130 and signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j - 1) >= -!e_30) then signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j) = -!e_30
'when 1.25>Z<1.3 , stay in the original position or enter into a new 25% short position
else if (zsc_{%c}_{%u}_{%x}_{%i}(!j) < !a_130 and zsc_{%c}_{%u}_{%x}_{%i}(!j) >=!a_125 and signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j - 1) < -!e_25) then signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j) = signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j-1)
else if (zsc_{%c}_{%u}_{%x}_{%i}(!j) < !a_130 and zsc_{%c}_{%u}_{%x}_{%i}(!j) >=!a_125 and signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j - 1) >= -!e_25) then signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j) = -!e_25
'when 1>Z<1.25 stay in the original position or enter into a new 25% short position
else if (zsc_{%c}_{%u}_{%x}_{%i}(!j) < !a_125 and zsc_{%c}_{%u}_{%x}_{%i}(!j) >= !a_100 and signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j - 1) < -!e_00) then signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j) = signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j-1)
else if (zsc_{%c}_{%u}_{%x}_{%i}(!j) < !a_125 and zsc_{%c}_{%u}_{%x}_{%i}(!j) >= !a_100 and signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j - 1) >= -!e_00) then signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j) = -!e_00
'when 0.5>Z<1 and was in a short position, stay in the position otherwise zero position
else if (zsc_{%c}_{%u}_{%x}_{%i}(!j) < !a_100 and zsc_{%c}_{%u}_{%x}_{%i}(!j) >= s0 and signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j - 1) < 0) then signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j) = signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j-1)
else if (zsc_{%c}_{%u}_{%x}_{%i}(!j) < !a_100 and zsc_{%c}_{%u}_{%x}_{%i}(!j) >= s0 and signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j - 1) >= 0) then signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j) = 0
'when -0.5>Z<0.5 , don't enter into any position
else if (zsc_{%c}_{%u}_{%x}_{%i}(!j) < s0 and zsc_{%c}_{%u}_{%x}_{%i}(!j) > -s0) then signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j) = 0
'when -1.00 >Z<-0.5 and was in a long position, stay in that position, otherwise zero position
else if (zsc_{%c}_{%u}_{%x}_{%i}(!j) <=-s0 and zsc_{%c}_{%u}_{%x}_{%i}(!j) > - !a_100 and signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j - 1) > 0 ) then signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j) = signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j-1)
else if (zsc_{%c}_{%u}_{%x}_{%i}(!j) <= -s0 and zsc_{%c}_{%u}_{%x}_{%i}(!j) >- !a_100 and signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j - 1) <= 0) then signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j) = 0
'when -1.25>Z<-1.00, stay in that position or enter a % long position
else if (zsc_{%c}_{%u}_{%x}_{%i}(!j) <= -!a_100 and zsc_{%c}_{%u}_{%x}_{%i}(!j) >- !a_125 and signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j - 1) > !e_00) then signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j) = signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j-1)
else if (zsc_{%c}_{%u}_{%x}_{%i}(!j) <= -!a_100 and zsc_{%c}_{%u}_{%x}_{%i}(!j) >- !a_125 and signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j - 1) <= !e_00) then signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j) = !e_00
'when -1.30>Z<-1.25, stay in that position or enter at 25 % long position
else if (zsc_{%c}_{%u}_{%x}_{%i}(!j) <= -!a_125 and zsc_{%c}_{%u}_{%x}_{%i}(!j) > -!a_130 and signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j - 1) > !e_25 ) then signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j) = signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j-1)
else if (zsc_{%c}_{%u}_{%x}_{%i}(!j) <= -!a_125 and zsc_{%c}_{%u}_{%x}_{%i}(!j) > -!a_130 and signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j - 1) <= !e_25 ) then signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j) = !e_25
'when -1.30>Z<-1.25, stay in that position or enter at 30% long position
else if (zsc_{%c}_{%u}_{%x}_{%i}(!j) <= -!a_130 and zsc_{%c}_{%u}_{%x}_{%i}(!j) > -!a_140 and signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j - 1) > !e_30) then signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j) = signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j-1)
else if (zsc_{%c}_{%u}_{%x}_{%i}(!j) <= -!a_130 and zsc_{%c}_{%u}_{%x}_{%i}(!j) > -!a_140 and signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j - 1) <= !e_30) then signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j) = !e_30
'when -1.50>Z<-1.40, stay in that position or enter at 40% long position
else if (zsc_{%c}_{%u}_{%x}_{%i}(!j) <= -!a_140 and zsc_{%c}_{%u}_{%x}_{%i}(!j) > -!a_150 and signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j - 1) > !e_40 ) then signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j) = signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j-1)
else if (zsc_{%c}_{%u}_{%x}_{%i}(!j) <= -!a_140 and zsc_{%c}_{%u}_{%x}_{%i}(!j) > -!a_150 and signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j - 1) <= !e_40 ) then signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j) = !e_40
'when -1.75>Z<-1.50, stay in that position or enter at 50% long position
else if (zsc_{%c}_{%u}_{%x}_{%i}(!j) <= -!a_150 and zsc_{%c}_{%u}_{%x}_{%i}(!j) > -!a_175 and signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j - 1) > !e_50 ) then signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j) = signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j-1)
else if (zsc_{%c}_{%u}_{%x}_{%i}(!j) <= -!a_150 and zsc_{%c}_{%u}_{%x}_{%i}(!j) > -!a_175 and signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j - 1) <= !e_50 ) then signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j) = !e_50
'when -2>Z<-1.75, stay in that position or enter at 75% long position
else if (zsc_{%c}_{%u}_{%x}_{%i}(!j) <= -!a_175 and zsc_{%c}_{%u}_{%x}_{%i}(!j) > -!a_200 and signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j - 1) > !e_75) then signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j) = signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j-1)
else if (zsc_{%c}_{%u}_{%x}_{%i}(!j) <= -!a_175 and zsc_{%c}_{%u}_{%x}_{%i}(!j) > -!a_200 and signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j - 1) <= !e_75) then signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j) = !e_75
'when Z<-2 and was not in a long position, enter into a long position
else if zsc_{%c}_{%u}_{%x}_{%i}(!j)<=-!a_200 then signal_{%a}_{%c}_{%u}_{%x}_{%i}(!j) = !e_100
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
endif
next
endif
next
next
next
next
next