Correct my afl

#1
In this afl buying coming correctly but sell signal get delayed for 5 minutes and coming late please correct it...


_SECTION_BEGIN("RSI with AUTO SEC Version 1.2");
///RSI with AUTO SEC Version 1.2//
// v.1.0 Created By Kook 16 Nov 2005 //
// v.1.1 1st Update By Kook 17 Nov 2005 //
// v.1.2 2nd Update By Kook 20 Nov 2005 //Bug report by Mink(Last SEC,Title)

H=L=C=RSI(14);
//Plot( Close, "Close", colorYellow, 4 );
Heading="RSI with AUTO SEC Version 1.2";

SECUpColor=ParamColor("SEC-UpColor",colorBrightGreen);
SECDnColor=ParamColor("SEC-DownColor",colorRed);
SECLastColor=ParamColor("SEC-LastColor",colorWhite);
BckGndColor=ParamColor("BackGroundColor",colorBlack);
ZZSwitch=Param("ZZSwitch",0,0,1,1);
Sens=Param("Sens",35,0.5,100,0.5);

BarPK=BarsSince(Zig(C,Sens)==Peak(C,Sens));
BarTGH= BarsSince(Zig(C,Sens)==Trough(C,Sens));
Turnpoint=Min(BarPK,BarTGH);
x = Cum(1);
lastx = ValueWhen(Turnpoint==0,( x ));
Daysback = ValueWhen(Turnpoint==0,(Max(PeakBars(C,Sens,1),TroughBars(C,Sens,1))))+1;

aa =ValueWhen(Turnpoint==0,LinRegIntercept( Close, Daysback) );
bb =ValueWhen(Turnpoint==0,LinRegSlope( Close, Daysback));
y = Aa + bb * ( x - (Lastx - DaysBack+1) );

e= ValueWhen(Turnpoint==0,StdErr(C,Daysback));
eU= y + 2*e;
eL= y - 2*e;

Color=IIf(Cross(bb,0) OR Cross(0,bb),BckGndColor,IIf(bb<0,SECDnColor,SECUpColor));
Plot( IIf( x >= (lastx - Daysback), IIf( Ref(C,-1) <eU AND Ref(C,-1) >eL,y,Null) , -1e10 ) , "LinReg", color,4 );
Plot(IIf( x >= (lastx - Daysback), IIf( Ref(C,-1) <eU AND Ref(C,-1) >eL,eU,Null) , -1e10 ) ,"",color,4);
Plot(IIf( x >= (lastx - Daysback), IIf( Ref(C,-1) <eU AND Ref(C,-1) >eL,eL,Null) , -1e10 ) ,"",color,4);



PlotShapes(shapeUpArrow*Cross(C,eU),colorBlue,0,25,Offset=0);
PlotShapes(shapeDownArrow*Cross(eL,C),colorRed,0,75,Offset=0);


DaysbackL = LastValue(Min(PeakBars(C,Sens,1),TroughBars(C,Sens,1)));

//MIDDLE SEC//
Slope= ValueWhen(Turnpoint==0,bb,0);
Level= ValueWhen(Turnpoint==0,aa,0);
Err= ValueWhen(Turnpoint==0,e,0);

Mback= Level + slope*( Turnpoint) ;
Uback= MBack + 2*Err;
Lback= MBack - 2*Err;
color2=IIf(Cross(bb,0) OR Cross(0,bb),BckGndColor,IIf(bb<0,SECUpColor,SECDnColor));
Plot( IIf( (X>(LastValue(x)-DaysbackL) ),Null ,Mback) ,"",color2,4);
Plot( IIf( (X>(LastValue(x)-DaysbackL) ),Null ,Uback) ,"",color2,4);
Plot( IIf( (X>(LastValue(x)-DaysbackL) ),Null ,Lback) ,"",color2,4);



///////Last SEC///////////////////
x = Cum(1);
lastxL = LastValue( x );
DaysbackL = LastValue(Min(PeakBars(C,Sens,1),TroughBars(C,Sens,1)))+1;
Endbars = IIf(PeakBars(C,Sens,1)<TroughBars(C,Sens,1),LastValue(ValueWhen(C==LLV(C,DaysbackL),X)),LastValue(ValueWhen( C==HHV(C,DaysbackL),X)));
BarsL=Min(PeakBars(C,Sens,1),TroughBars(C,Sens,1)) ;

aaL = ValueWhen( Ref(Endbars,-1)!=Ref(x,-1) AND Endbars==x , LinRegIntercept( Close, DaysbackL-(LastValue(x)-Endbars)) );
bbL = ValueWhen( Ref(Endbars,-1)!=Ref(x,-1) AND Endbars==x , LinRegSlope( Close, DaysbackL-(LastValue(x)-Endbars)) );
eL= ValueWhen( Ref(Endbars,-1)!=Ref(x,-1) AND Endbars==x , StdErr(C,DaysbackL-(LastValue(x)-Endbars)) );
SlopeL= LastValue(bbL);
LevelL= LastValue(aaL);
ErrL= LastValue(eL);

MbackL= LevelL + slopeL*( BarsL) ;
UbackL= MBackL + 2*ErrL;
LbackL= MBackL - 2*ErrL;
WL=(UbackL-LbackL)/sqrt((SlopeL*SlopeL)+1);

Plot( IIf(X>(LastValue(x)-DaysbackL) ,MbackL,Null) ,"",SECLastColor,4+styleNoLabel);
Plot( IIf(X>(LastValue(x)-DaysbackL),UbackL,Null) ,"",SECLastColor,4+styleNoLabel);
Plot( IIf(X>(LastValue(x)-DaysbackL),LbackL,Null) ,"",SECLastColor,4+styleNoLabel);

PlotShapes( IIf(X>(LastValue(x)-DaysbackL),shapeHollowUpArrow*Cross(C,UbackL) ,Null),SECLastColor,0,25,Offset=-0);
PlotShapes( IIf(X>(LastValue(x)-DaysbackL),shapeHollowDownArrow*Cross(LbackL,C) ,Null),colorOrange,75,Offset=-0);

Plot( Close, "Close", colorViolet);//, 4 );
Plot(30,"",10 ,4+styleNoLabel);
// Plot(50,"",IIf(TEMA(RSI(14),14)>50,colorBrightGreen,colorRed) ,4+styleNoLabel);
Plot(70,"",10 ,4+styleNoLabel);
Plot(Zig(C,Sens),"",IIf(ZZSwitch==1,colorSkyblue,BckGndColor),8+styleNoLabel);

Change=C-Ref(C,-1);
Title=Name()+" "+Date()+" "+Heading+EncodeColor(colorRed)+" RSI(14) = "+C ;
_SECTION_END();
 
#2
in this afl buying coming correctly but sell signal get delayed for 5 minutes and coming late please correct it...


_section_begin("rsi with auto sec version 1.2");
///rsi with auto sec version 1.2//
// v.1.0 created by kook 16 nov 2005 //
// v.1.1 1st update by kook 17 nov 2005 //
// v.1.2 2nd update by kook 20 nov 2005 //bug report by mink(last sec,title)

h=l=c=rsi(14);
//plot( close, "close", coloryellow, 4 );
heading="rsi with auto sec version 1.2";

secupcolor=paramcolor("sec-upcolor",colorbrightgreen);
secdncolor=paramcolor("sec-downcolor",colorred);
seclastcolor=paramcolor("sec-lastcolor",colorwhite);
bckgndcolor=paramcolor("backgroundcolor",colorblack);
zzswitch=param("zzswitch",0,0,1,1);
sens=param("sens",35,0.5,100,0.5);

barpk=barssince(zig(c,sens)==peak(c,sens));
bartgh= barssince(zig(c,sens)==trough(c,sens));
turnpoint=min(barpk,bartgh);
x = cum(1);
lastx = valuewhen(turnpoint==0,( x ));
daysback = valuewhen(turnpoint==0,(max(peakbars(c,sens,1),troughbars(c,sens,1))))+1;

aa =valuewhen(turnpoint==0,linregintercept( close, daysback) );
bb =valuewhen(turnpoint==0,linregslope( close, daysback));
y = aa + bb * ( x - (lastx - daysback+1) );

e= valuewhen(turnpoint==0,stderr(c,daysback));
eu= y + 2*e;
el= y - 2*e;

color=iif(cross(bb,0) or cross(0,bb),bckgndcolor,iif(bb<0,secdncolor,secupcolor));
plot( iif( x >= (lastx - daysback), iif( ref(c,-1) <eu and ref(c,-1) >el,y,null) , -1e10 ) , "linreg", color,4 );
plot(iif( x >= (lastx - daysback), iif( ref(c,-1) <eu and ref(c,-1) >el,eu,null) , -1e10 ) ,"",color,4);
plot(iif( x >= (lastx - daysback), iif( ref(c,-1) <eu and ref(c,-1) >el,el,null) , -1e10 ) ,"",color,4);



plotshapes(shapeuparrow*cross(c,eu),colorblue,0,25,offset=0);
plotshapes(shapedownarrow*cross(el,c),colorred,0,75,offset=0);


daysbackl = lastvalue(min(peakbars(c,sens,1),troughbars(c,sens,1)));

//middle sec//
slope= valuewhen(turnpoint==0,bb,0);
level= valuewhen(turnpoint==0,aa,0);
err= valuewhen(turnpoint==0,e,0);

mback= level + slope*( turnpoint) ;
uback= mback + 2*err;
lback= mback - 2*err;
color2=iif(cross(bb,0) or cross(0,bb),bckgndcolor,iif(bb<0,secupcolor,secdncolor));
plot( iif( (x>(lastvalue(x)-daysbackl) ),null ,mback) ,"",color2,4);
plot( iif( (x>(lastvalue(x)-daysbackl) ),null ,uback) ,"",color2,4);
plot( iif( (x>(lastvalue(x)-daysbackl) ),null ,lback) ,"",color2,4);



///////last sec///////////////////
x = cum(1);
lastxl = lastvalue( x );
daysbackl = lastvalue(min(peakbars(c,sens,1),troughbars(c,sens,1)))+1;
endbars = iif(peakbars(c,sens,1)<troughbars(c,sens,1),lastvalue(valuewhen(c==llv(c,daysbackl),x)),lastvalue(valuewhen( c==hhv(c,daysbackl),x)));
barsl=min(peakbars(c,sens,1),troughbars(c,sens,1)) ;

aal = valuewhen( ref(endbars,-1)!=ref(x,-1) and endbars==x , linregintercept( close, daysbackl-(lastvalue(x)-endbars)) );
bbl = valuewhen( ref(endbars,-1)!=ref(x,-1) and endbars==x , linregslope( close, daysbackl-(lastvalue(x)-endbars)) );
el= valuewhen( ref(endbars,-1)!=ref(x,-1) and endbars==x , stderr(c,daysbackl-(lastvalue(x)-endbars)) );
slopel= lastvalue(bbl);
levell= lastvalue(aal);
errl= lastvalue(el);

mbackl= levell + slopel*( barsl) ;
ubackl= mbackl + 2*errl;
lbackl= mbackl - 2*errl;
wl=(ubackl-lbackl)/sqrt((slopel*slopel)+1);

plot( iif(x>(lastvalue(x)-daysbackl) ,mbackl,null) ,"",seclastcolor,4+stylenolabel);
plot( iif(x>(lastvalue(x)-daysbackl),ubackl,null) ,"",seclastcolor,4+stylenolabel);
plot( iif(x>(lastvalue(x)-daysbackl),lbackl,null) ,"",seclastcolor,4+stylenolabel);

plotshapes( iif(x>(lastvalue(x)-daysbackl),shapehollowuparrow*cross(c,ubackl) ,null),seclastcolor,0,25,offset=-0);
plotshapes( iif(x>(lastvalue(x)-daysbackl),shapehollowdownarrow*cross(lbackl,c) ,null),colororange,75,offset=-0);

plot( close, "close", colorviolet);//, 4 );
plot(30,"",10 ,4+stylenolabel);
// plot(50,"",iif(tema(rsi(14),14)>50,colorbrightgreen,colorred) ,4+stylenolabel);
plot(70,"",10 ,4+stylenolabel);
plot(zig(c,sens),"",iif(zzswitch==1,colorskyblue,bckgndcolor),8+stylenolabel);

change=c-ref(c,-1);
title=name()+" "+date()+" "+heading+encodecolor(colorred)+" rsi(14) = "+c ;
_section_end();


just remove space from every error..u get.


Well its very old afl, this afl looks into future.

When u look at old data,it may look gr8 but when u trade in real time- Its totally future one.

Thanx you


regards
 
#7
This is the errors some errors corrected but please help me to solve this errors...

PlotShapes(shapeDownArrow*Cross(el,C),colorRed,0,7,5,offset=0);
(errror: Ln:41,col:62:error 16:too many arguments)

Plot(Zig(C,sens),"",IIf(zzswitch==1,colorSkyblue,backgroundcolor),8+styleNoLabel);
(error: Ln:91,col:66:error :29 variable background color' used without having been initialized.)
 
#8
This is the errors some errors corrected but please help me to solve this errors...

PlotShapes(shapeDownArrow*Cross(el,C),colorRed,0,7,5,offset=0);
(errror: Ln:41,col:62:error 16:too many arguments)

Plot(Zig(C,sens),"",IIf(zzswitch==1,colorSkyblue,backgroundcolor),8+styleNoLabel);
(error: Ln:91,col:66:error :29 variable background color' used without having been initialized.)


No such errors found in Amibroker 5.60


Well avoid using this formula.. not good for trading..

It looks into future.
 
#9
This is the errors some errors corrected but please help me to solve this errors...

PlotShapes(shapeDownArrow*Cross(el,C),colorRed,0,7 ,5,offset=0);
(errror: Ln:41,col:62:error 16:too many arguments)

Plot(Zig(C,sens),"",IIf(zzswitch==1,colorSkyblue,b ackgroundcolor),8+styleNoLabel);
(error: Ln:91,col:66:error :29 variable background color' used without having been initialized.)
 

Similar threads