why is TS II closed once i change any parameter?

Moderator: admin

why is TS II closed once i change any parameter?

Postby clodhoppes » Sat Jan 07, 2012 2:21 am

Can anyone help me?
I encountered a problem with TSII of the lastest version. I developed an indicator and it worked fine in the previous TS II. However, TSII will be closed right after I change any parameter of the indicator; moreover, the indicator does not update along with the coming period.
I appreciate any suggestions!
clodhoppes
 
Posts: 26
Joined: Sun Aug 15, 2010 8:11 pm

Re: why is TS II closed once i change any parameter?

Postby clodhoppes » Sat Jan 07, 2012 10:01 pm

I found a clue. Maybe I used too many text output streams( more than 30 ), so I guess if the updated TSII put an limit on the number of outstream?
clodhoppes
 
Posts: 26
Joined: Sun Aug 15, 2010 8:11 pm

Re: why is TS II closed once i change any parameter?

Postby sunshine » Sun Jan 08, 2012 11:47 pm

Please tell me the name of the indicator you use. If possible please provide the code or post a link to the code.
sunshine
 

Re: why is TS II closed once i change any parameter?

Postby clodhoppes » Mon Jan 09, 2012 5:13 pm

Thank you for your attention. The code is listed as follows:
function Init()
indicator:name("HHH");
indicator:description("HHH");
indicator:requiredSource(core.Bar);
indicator:type(core.Indicator);

indicator.parameters:addInteger("Ni", "Ni", "right limit",1,1,200000);
indicator.parameters:addInteger("limit", "limit", "left limit",20,2,2000);
indicator.parameters:addInteger("fgi", "fgi", "reveral number",6,1,8);
indicator.parameters:addInteger("NR", "NR", "left or right range",1,1,100);

indicator.parameters:addGroup("Style");
indicator.parameters:addColor("R_color", "Color of Red", "", core.rgb(255, 0, 0));
indicator.parameters:addColor("B_color", "Color of Blue", "", core.rgb(0, 0, 255));
indicator.parameters:addColor("G_color", "Color of Green", "", core.rgb(0, 128, 0));
indicator.parameters:addColor("D_color", "Color of black", "", core.rgb(0, 0, 0));
indicator.parameters:addColor("M_color", "Color of magenta", "", core.rgb(255, 0, 255));
indicator.parameters:addColor("C_color", "Color of cyan", "", core.rgb(128, 255, 255));
indicator.parameters:addColor("Y_color", "Color of yellow", "", core.rgb(255, 255, 0));
indicator.parameters:addColor("S_color", "Color of gray", "", core.rgb(128, 128, 128));

end
-- Parameters block
local Ni,limit,fgi,NR;

local pL;
local source = nil;
-- Streams block
local fr={};

local i;
local f={};local g={};
local Cen;
-- Routine
function Prepare()
Ni = instance.parameters.Ni;
limit = instance.parameters.limit;
fgi = instance.parameters.fgi;
NR = instance.parameters.NR;


source = instance.source;
pL=source:size()-Ni;

local name = profile:id();
instance:name(name);
fr[0]=0.191;fr[1]=0.236;fr[2]=0.382;fr[3]=0.5;
fr[4]=0.618;fr[5]=0.809;fr[6]=1;fr[7]=1.191;
fr[8]=1.236;fr[9]=0.382;fr[10]=1.5;fr[11]=1.618;
fr[12]=1.809;fr[13]=2;fr[14]=2.191;fr[15]=2.236;
fr[16]=2.382;fr[17]=2.5;fr[18]=2.618;fr[19]=2.809;
fr[20]=3;fr[21]=3.191;fr[22]=3.236;fr[23]=3.5;
fr[24]=3.618;fr[25]=3.809;fr[26]=4;fr[27]=4.191;
fr[28]=4.236;fr[29]=4.382;fr[30]=4.5;fr[31]=4.618;
Cen=instance:createTextOutput ("Cen", "Cen", "Arial", 6, core.H_Center, core.V_Top, instance.parameters.G_color, 0);
for i=1,4*fgi,1 do
f[i]=instance:createTextOutput ("f"..i, "f"..i, "Arial", 6, core.H_Center, core.V_Top, instance.parameters.B_color, 0);
g[i]=instance:createTextOutput ("g"..i, "g"..i, "Arial", 6, core.H_Center, core.V_Top, instance.parameters.R_color, 0);
end

end

function Update(period,mode)
local i,H,L,DH,DL,DHL,con,s;
local ps,price,px,n;
local p={}; local dp={}; local ip;

if period==pL-1 then
ps=source:pipSize();n=0;
core.host:execute("drawLabel", 1, source:date(period), source.high[period]+7*ps, "*");

for s=pL-1,pL-1-limit,-1 do
H=source.high[s-NR]; L=source.low[s-NR];
if H==mathex.max(source.high, core.rangeTo(s, 2*NR+1)) then n=n+1; p[n]=H; dp[n]=s-NR; end
if L==mathex.min(source.low, core.rangeTo(s,2*NR+1)) then n=n+1; p[n]=(-1)*L; dp[n]=s-NR; end
end

for s=1,n-1,1 do
con=0;
if p[s]>0 then
ip=0;
for i=s+1,n,1 do if p[i]<0 then ip=i; break; end end
if ip>0 then if (-1)*p[ip]<p[s]-3*ps then DH=p[s]; DL=-1*p[ip]; DHL=DH-DL; con=1; end end
elseif p[s]<0 then
ip=0;
for i=s+1,n,1 do if p[i]>0 then ip=i; break; end end
if ip>0 then if p[ip]>(-1)*p[s]+3*ps then DH=p[ip]; DL=-1*p[s]; DHL=DH-DL; con=2; end end
end

if con>=1 then
DH=0.5*(DH+DL+DHL); DL=DH-DHL;

price=math.ceil(0.5*(DH+DL)*10/ps); px=string.sub(price,-3); price=price*ps/10; Cen:set(dp[s],price,px);

for i=1,4*fgi,1 do
price=math.ceil((DH-DHL*fr[i-1])*10/ps); px=string.sub(price,-3); price=price*ps/10; f[i]:set(dp[s],price,px);
price=math.floor((DL+DHL*fr[i-1])*10/ps); px=string.sub(price,-3); price=price*ps/10; g[i]:set(dp[s],price,px);
end

end
--for s=
end

--if period=
end
--function
end
clodhoppes
 
Posts: 26
Joined: Sun Aug 15, 2010 8:11 pm

Re: why is TS II closed once i change any parameter?

Postby sunshine » Tue Jan 10, 2012 4:49 am

I have forwarded your report to Trading Station developers and they have confirmed that this is an issue in the platform. It will be fixed in one of the next update of the platform.

Thank you for reporting the problem.
I do apologize for any inconvenience this causes you.
sunshine
 

Re: why is TS II closed once i change any parameter?

Postby clodhoppes » Sun Jan 29, 2012 8:01 pm

After yesterday's update, TS II will not be closed when I change any parameter, but I wonder why this indicator can not update when a new period comes. Please help me.
clodhoppes
 
Posts: 26
Joined: Sun Aug 15, 2010 8:11 pm

Re: why is TS II closed once i change any parameter?

Postby sunshine » Mon Jan 30, 2012 7:11 am

The indicator is not updated when a new period comes according to the code:

Code: Select all
function Prepare()
    ...
    pL=source:size()-Ni;
    ...
end

function Update(period,mode)
    ...
    if period==pL-1 then
    -- draw indicator
    end
    ...
end


The indicator is not updated because of condition "if period==pL-1...". The variable pL is calculated in the Prepare function which is called only once (when indicator creation).
sunshine
 

Re: why is TS II closed once i change any parameter?

Postby clodhoppes » Mon Jan 30, 2012 2:08 pm

According to your advice, I have solved the problem. Thank you!
clodhoppes
 
Posts: 26
Joined: Sun Aug 15, 2010 8:11 pm


Return to Indicator Development

Who is online

Users browsing this forum: No registered users and 41 guests