[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] seban Supertrend : plz help convert frm tradestation to amibroker



PureBytes Links

Trading Reference Links

hi , i found this script on tradestation that looks really good for 
stops and entries. it is from tradestation.can someone help to 
convert it?thanks



{HBKeltnerbandesPGI: Bandes Plus Haut Plus Bas et moyenne sur 
intervalle donne (type supertrend de Seban)
Type calcul=
1 moy arith sans seuil
2 moy arith avec seuil
3 moy expo sans seuil
4 moy expo avec seuil
5 moy pond sans seuil
6 moy pond avec seuil
 
BY041206 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX}

INPUTs: CorrGapJNouO(1);
	vars:Gap(0),GapJCumu(0),CC(C),HC(H),BC(L),OC(O);
	{Correction des  gaps }
	if CorrGapJNouO=1 then begin
		if Date<>Date[1] then begin
			Gap=Gap[1]+C-C[1];
		end;
		GapJCumu=Gap;
	end else GapJCumu=0;

	CC=C-GapJCumu;HC=H-GapJCumu;BC=L-GapJCumu;OC=L-GapJCumu;

Var: HBKTypPrxCentr(1),HBKTypPrxSort(2),HBKintrvp(1),klargeurSup
(2),klargeurInf(-2);
Input: Klargeur(3), HBKLisp(20), ColorSup(DarkGreen), ColorInf(Red);

KlargeurSup = Klargeur;
KlargeurInf =-Klargeur;
	
var: HBKPrxCentr(C),HBKPrxSort(C),HBKPlusH(0),HBKPlusB(0),HB
(0),AmplitudVrGIntHBK(0),
	 HBKAtr(0), HBKMoy(0),HBKH(0),HBKB(0),HBKHMoy(0),HBKBMoy
(0),HBKtendance(0),
	 HBKLisIntrvp(HBKLisp*HBKintrvp),Maxccant(HBKLisIntrvp);

HBKPlusH=HighestFC(HC,HBKintrvp);
HBKPlusB=LowestFC(BC,HBKintrvp);

	if HBKTypPrxCentr =1 then HBKPrxCentr=cc;
	if HBKTypPrxCentr =2 then HBKPrxCentr=(HBKPlusH+HBKPlusB)
*0.5;
	if HBKTypPrxCentr =3 then HBKPrxCentr=
(HBKPlusH+HBKPlusB+cc)/3;
	if HBKTypPrxCentr =4 then HBKPrxCentr=
(HBKPlusH+HBKPlusB+cc+OC[HBKintrvp-1])*0.25;
	if HBKTypPrxCentr =5 then HBKPrxCentr=(HBKPlusH+HBKPlusB+cc
[HBKintrvp])/3;
	if HBKTypPrxCentr =6 then HBKPrxCentr=(HBKPlusH+HBKPlusB+cc
[HBKintrvp]+OC[HBKintrvp-1])*0.25;

	if HBKTypPrxSort =1 then HBKPrxSort=cc;
	if HBKTypPrxSort =2 then HBKPrxSort=(HBKPlusH+HBKPlusB)*0.5;
	if HBKTypPrxSort =3 then HBKPrxSort=(HBKPlusH+HBKPlusB+cc)/3;
	if HBKTypPrxSort =4 then HBKPrxSort=(HBKPlusH+HBKPlusB+cc+OC
[HBKintrvp-1])*0.25;
	if HBKTypPrxSort =5 then HBKPrxSort=(HBKPlusH+HBKPlusB+cc
[HBKintrvp])/3;
	if HBKTypPrxSort =6 then HBKPrxSort=(HBKPlusH+HBKPlusB+cc
[HBKintrvp]+OC[HBKintrvp-1])*0.25;

		AmplitudVrGIntHBK=(maxlist(HBKPlusH,CC[HBKintrvp])-
minlist(HBKPlusB,CC[HBKintrvp]))*0.5;

Var:typeCalcul(6),GrafInfOuSup(1);
		if HBKLisp>1 then begin
			if typeCalcul=1 then begin
				HBKMoy=average
(HBKPrxCentr,HBKLisIntrvp);
				HBKAtr=average
(AmplitudVrGIntHBK,HBKLisIntrvp);
				HBKHMoy=HBkmoy+klargeurSup*HBKAtr;
				HBKBMoy=HBkmoy+klargeurInf*HBKAtr;
			end;
			if typeCalcul=2 then begin
				HBKMoy=average
(HBKPrxCentr,HBKLisIntrvp);
				HBKAtr=average
(AmplitudVrGIntHBK,HBKLisIntrvp);
				HBKHMoy=HBkmoy+klargeurSup*HBKAtr;if 
HBKTendance=-1 then HBKHmoy=minlist(HBKHmoy,HBKHmoy[1]);
			
	HBKBMoy=HBkmoy+klargeurInf*HBKAtr;;if HBKTendance=1 then 
HBKBmoy=maxlist(HBKBmoy,HBKBmoy[1]);
			end;
			if typeCalcul=3 then begin
				HBKMoy=xaverage
(HBKPrxCentr,HBKLisIntrvp);
				HBKAtr=xaverage
(AmplitudVrGIntHBK,HBKLisIntrvp);
				HBKHMoy=HBkmoy+klargeurSup*HBKAtr;
				HBKBMoy=HBkmoy+klargeurInf*HBKAtr;
						end;
			if typeCalcul=4 then begin
				HBKMoy=Xaverage
(HBKPrxCentr,HBKLisIntrvp);
				HBKAtr=Xaverage
(AmplitudVrGIntHBK,HBKLisIntrvp);
				HBKHMoy=HBkmoy+klargeurSup*HBKAtr;if 
HBKTendance=-1 then HBKHmoy=minlist(HBKHmoy,HBKHmoy[1]);
			
	HBKBMoy=HBkmoy+klargeurInf*HBKAtr;;if HBKTendance=1 then 
HBKBmoy=maxlist(HBKBmoy,HBKBmoy[1]);
			end;
			if typeCalcul=5 then begin
				HBKMoy=Waverage
(HBKPrxCentr,HBKLisIntrvp);
				HBKAtr=Waverage
(AmplitudVrGIntHBK,HBKLisIntrvp);
				HBKHMoy=HBkmoy+klargeurSup*HBKAtr;
				HBKBMoy=HBkmoy+klargeurInf*HBKAtr;
						end;
			if typeCalcul=6 then begin
				HBKMoy=average
(HBKPrxCentr,HBKLisIntrvp);
				HBKAtr=Waverage
(AmplitudVrGIntHBK,HBKLisIntrvp);
				HBKHMoy=HBkmoy+klargeurSup*HBKAtr;if 
HBKTendance=-1 then HBKHmoy=minlist(HBKHmoy,HBKHmoy[1]);
			
	HBKBMoy=HBkmoy+klargeurInf*HBKAtr;;if HBKTendance=1 then 
HBKBmoy=maxlist(HBKBmoy,HBKBmoy[1]);
			end;
		end else begin
		
	HBKH=HBKPrxCentr+klargeurSup*AmplitudVrGIntHBK;
		
	HBKB=HBKPrxCentr+klargeurInf*AmplitudVrGIntHBK;
			HBKMoy=HBKPrxCentr;
			HBKHMoy=HBKH;
			HBKBMoy=HBKB;
		end;
	
	if HBKPrxSort>HBKHMoy then HBKtendance=1;
	if HBKPrxSort<HBKBMoy then HBKtendance=-1;

	if GrafInfouSup=1 then begin

		Plot1(HBKMoy+GapJcumu,"Moy HB");
		if klargeurSup>0 then begin 
			Plot2(HBKHMoy+GapJcumu,"Bande Sup");
			if HBKtendance>0 then setplotcolor
(3,Colorsup);
		end;
		if klargeuriNF<0 then begin
			if HBKtendance<0 then setplotcolor
(2,colorinf);
		end;
			Plot3(HBKBMoy+GapJcumu,"Bande Inf");
		if GrafInfouSup=3 then
			Plot4(oC,"Ouverture",yellow);

	end else begin
		if HBKtendance>0 then begin
						Plot2(HBKHMoy-
HBKMoy,"Bande Sup");
						setplotcolor
(2,BLACK);
		end;
		if HBKtendance<0 then begin
						Plot2(HBKBMoy-
HBKMoy,"Bande Sup");
						setplotcolor(2,red);
		end;
		pLOT1(0,"Moy HB",blue);
		if GrafInfouSup=2 then
			Plot4(oC-HBKMoy,"Ouverture",yellow);





Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html
 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/