How do I modify this code to draw a large timeframeset line ?many thanks

#1
Dear Sir,

I am a beginner to amibroker .
I need to draw this line in 15min timeframeset.
Could you plz tell me how to do it?
(Draw trace is ok ,but draw trace15min is not appear ?)

Many thanks!

_SECTION_BEGIN("trace");

n = Param("periods",10);
trace=Null;
MA10=MA(C,10);
d1=(StDev(C,10))^2;
trace[10]=MA10[10];

for(i=n+1; i<BarCount;i++){
d2=(trace[i-1]-MA10)^2;
t=IIf(d2<d1,0,1-d1/d2);
trace=trace[i-1]+t*(MA10[i-1]-trace[i-1]);
}

Plot(trace,"trace",colorRed,styleLine);
_SECTION_END();

_SECTION_BEGIN("trace_15min");
TimeFrameSet(in15Minute);

n = Param("periods",10);
trace=Null;
MA10=MA(C,10);
d1=(StDev(C,10))^2;
trace[10]=MA10[10];

for(i=n+1; i<BarCount;i++){
d2=(trace[i-1]-MA10)^2;
t=IIf(d2<d1,0,1-d1/d2);
trace=trace[i-1]+t*(MA10[i-1]-trace[i-1]);
}
TimeFrameRestore();

Plot(TimeFrameExpand(trace,in15Minute,expandFirst),"trace15min",colorRed,styleLine);

_SECTION_END();
 

casoni

Well-Known Member
#2
Dear Sir,

I am a beginner to amibroker .
I need to draw this line in 15min timeframeset.
Could you plz tell me how to do it?
(Draw trace is ok ,but draw trace15min is not appear ?)

Many thanks!

_SECTION_BEGIN("trace");

n = Param("periods",10);
trace=Null;
MA10=MA(C,10);
d1=(StDev(C,10))^2;
trace[10]=MA10[10];

for(i=n+1; i<BarCount;i++){
d2=(trace[i-1]-MA10)^2;
t=IIf(d2<d1,0,1-d1/d2);
trace=trace[i-1]+t*(MA10[i-1]-trace[i-1]);
}

Plot(trace,"trace",colorRed,styleLine);
_SECTION_END();

_SECTION_BEGIN("trace_15min");
TimeFrameSet(in15Minute);

n = Param("periods",10);
trace=Null;
MA10=MA(C,10);
d1=(StDev(C,10))^2;
trace[10]=MA10[10];

for(i=n+1; i<BarCount;i++){
d2=(trace[i-1]-MA10)^2;
t=IIf(d2<d1,0,1-d1/d2);
trace=trace[i-1]+t*(MA10[i-1]-trace[i-1]);
}
TimeFrameRestore();

Plot(TimeFrameExpand(trace,in15Minute,expandFirst),"trace15min",colorRed,styleLine);

_SECTION_END();


Hello ,
Try this , Hope this helps

_SECTION_BEGIN("trace");

n = Param("periods",10);
trace=Null;
MA10=MA(C,10);
d1=(StDev(C,10))^2;
trace=MA10;

for(i=n+1; i<BarCount;i++)
{
d2=(trace[i-1]-MA10)^2;
t=IIf(d2<d1,0,1-d1/d2);
trace=trace[i-1]+t*(MA10[i-1]-trace[i-1]);
}

Plot(trace,"trace",colorRed,styleLine);
_SECTION_END();

_SECTION_BEGIN("trace_15min");
TimeFrameSet(in15Minute);
trace2=trace;
TimeFrameRestore();
Plot(TimeFrameExpand(trace2,in15Minute,expandFirst) ,"trace15min",colorBlue,styleLine);
_SECTION_END();

Thank you
* click on chart .. to display indicator
Thanks
 
#3
Hello ,
Try this , Hope this helps
_SECTION_BEGIN("trace_15min");
TimeFrameSet(in15Minute);
trace2=trace;
TimeFrameRestore();
Plot(TimeFrameExpand(trace2,in15Minute,expandFirst) ,"trace15min",colorBlue,styleLine);
_SECTION_END();
Thank you
* click on chart .. to display indicator
Thanks

yeah,it draws a blue line.
however,when i move the chart from right to the left.
this blue line also changes its position.

So....can we return to this code,where is the problem?:confused:

_SECTION_BEGIN("trace_15min");
TimeFrameSet(in15Minute);

n = Param("periods",10);
trace=Null;
MA10=MA(C,10);
d1=(StDev(C,10))^2;
trace[10]=MA10[10];

for(i=n+1; i<BarCount;i++){
d2=(trace[i-1]-MA10)^2;
t=IIf(d2<d1,0,1-d1/d2);
trace=trace[i-1]+t*(MA10[i-1]-trace[i-1]);
}
TimeFrameRestore();

Plot(TimeFrameExpand(trace,in15Minute,expandFirst) ,"trace15min",colorRed,styleLine);

_SECTION_END();
 

casoni

Well-Known Member
#4
yeah,it draws a blue line.
however,when i move the chart from right to the left.
this blue line also changes its position.

So....can we return to this code,where is the problem?:confused:

_SECTION_BEGIN("trace_15min");
TimeFrameSet(in15Minute);

n = Param("periods",10);
trace=Null;
MA10=MA(C,10);
d1=(StDev(C,10))^2;
trace[10]=MA10[10];

for(i=n+1; i<BarCount;i++){
d2=(trace[i-1]-MA10)^2;
t=IIf(d2<d1,0,1-d1/d2);
trace=trace[i-1]+t*(MA10[i-1]-trace[i-1]);
}
TimeFrameRestore();

Plot(TimeFrameExpand(trace,in15Minute,expandFirst) ,"trace15min",colorRed,styleLine);

_SECTION_END();


Hello,
check this images, values / line dosn't change at my end !!
 
Last edited:
#5
Hello,
check this images, values / line dosn't change at my end !!
ok,i have seen the image.
Two question:
if only using this code,is there any line appeared in your system??
_SECTION_BEGIN("trace_15min");
TimeFrameSet(in15Minute);
n = Param("periods",10);
trace=Null;
MA10=MA(C,10);
d1=(StDev(C,10))^2;
trace[10]=MA10[10];
for(i=n+1; i<BarCount;i++){
d2=(trace[i-1]-MA10)^2;
t=IIf(d2<d1,0,1-d1/d2);
trace=trace[i-1]+t*(MA10[i-1]-trace[i-1]);
}
TimeFrameRestore();
Plot(TimeFrameExpand(trace,in15Minute,expandFirst) ,"trace15min",colorRed,styleLine);
_SECTION_END();


second question,i saw there are two lines red and green at 5min interval in your system.
could you check tools->bar replay and run for a period of time.
Will you see red line is stable but green line is jumping up and down .
The goal of mine is letting green line as stable as red line.
But i dont know how ?:confused:

Thank you ,sir :)