PureBytes Links
Trading Reference Links
|
the following is a SAR based trading system. Both SAR parameters can be optimized for each security.
Regards,
Dima.
PS: I am not able to follow this group on daily basis, so if you have any questions, please send/cc it to rasnitsyn@xxxx
=======================================================
// Enter/Exit using Stops on signal price
accel =
IIf (Name() == "BRO", 0.02,
IIf (Name() == "HCA", 0.00, //0.07,
IIf (Name() == "LLL", 0.00,
IIf (Name() == "PDCO", 0.01,
IIf (Name() == "POOL", 0.00,
IIf (Name() == "SONC", 0.00,
IIf (Name() == "THC", 0.01,
IIf (Name() == "UNH", 0.05,
IIf (Name() == "ACS", 0.00,
IIf (Name() == "", 0.03,
IIf (Name() == "", 0.03,
IIf (Name() == "", 0.03,
0.03))))))))))));
accel = LastValue (accel);
accel = Optimize ("Accel", accel, 0.01, 0.1, 0.01);
maxS =
IIf (Name() == "BRO", 0.3,//0.2,
IIf (Name() == "HCA", 0.3,//0.2,
IIf (Name() == "LLL", 0.2,
IIf (Name() == "PDCO", 0.1,
IIf (Name() == "POOL", 0.2,
IIf (Name() == "SONC", 0.2,
IIf (Name() == "THC", 0.3,
IIf (Name() == "UNH", 0.5,
IIf (Name() == "", 0.2,
IIf (Name() == "", 0.2,
IIf (Name() == "", 0.2,
IIf (Name() == "", 0.2,
0.2))))))))))));
maxS = LastValue (maxS);
maxS = Optimize ("Max", maxS, 0.1, 0.6, 0.1);
s = SAR (accel, maxS);
signalPrice = IIf (accel > 0, Ref (s, -1) ,1000);
// Buy on break of yesterday SAR stop, or on open tomorrow if crossed todaySAR STOP
BuyBreak = Cross (H, signalPrice) and accel > 0 ;
buySignal = Cross (H, s) and accel > 0 ;
SellBreak = Cross (signalPrice, L);
sellSignal = Cross (s, L);
BuyPrice = IIf ( BuyBreak , Max (Open, signalPrice), Ref (Open, 1));
SellPrice = IIf ( SellBreak , Min (Open, signalPrice), Ref (Open, 1));
Buy = BuyBreak OR BuySignal;
Sell = SellBreak OR SellSignal;
Buy = ExRem (Buy, Sell);
Sell = ExRem (Sell,Buy);
// !! SETTINGS MUST POINT FOR TODAY (i.e. no offset)
//BuyPrice = IIf (IsTrue(NOT Buy and Ref (Buy, -1) and not buySignal), Ref (BuyPrice, -1), BuyPrice);
//SellPrice = IIf (IsTrue(NOT Sell and Ref (Sell, -1) and not buySignal),Ref (SellPrice, -1), SellPrice);
inTrade = Flip (Buy, Sell);
MaxGraph=5;
Graph0 = Close;
Graph0BarColor = IIf (inTrade, 5, 1);
Graph0Style = 64;
Graph1 = s;
Graph1Style = 24;
"TOMORROW " + WriteIf (buySignal AND NOT BuyBreak, " Buy on Open ", WriteIf(sellSignal AND NOT SellBreak, " Sell on Open ", WriteIf (inTrade, " Exit Stop Loss: ", " Entry Stop Price: ") + WriteVal (s)));
"Today Signal price was: " + WriteVal (signalPrice) + " ; SAR price: " + WriteVal (s);
"By the end of day should be " + WriteIf (inTrade, " In Trade ", " Out ");
WriteIf (Buy, " TODAY HAD TO ENTER THE TRADE ", WriteIf (Sell, " TODAY HAD TO EXIT THE TRADE ", " "));
"Buy Price: " + WriteVal (BuyPrice) + " ; Sell Price: " + WriteVal (SellPrice);
"\n";
Title = "SAR trading system. SAR: " + WriteVal (s) +" ; Signal price: " + WriteVal (signalPrice);
// Price slippage
// BuyPrice = 1.005*BuyPrice;
// SellPrice = 0.995*SellPrice;
=======================================================
----- Original Message -----
From: Panos Boufardeas
To: amibroker@xxxxxxxxxxxxxxx
Sent: Tuesday, November 13, 2001 6:13 PM
Subject: Re: [amibroker] Valid code for SAR?
HI : Keith B few days ago Tomasz answer
--- In amibroker@xxxx, "Tomasz Janeczko" <amibroker@xxxx> wrote:
> Hello,
>
> Please note that the notation = 0.02 means default values
> of parameters (used if no arguments are supplied) so
>
> SAR() is equivalent to SAR( 0.02, 0.2 )
>
> If you want to pass the parameters use the following
>
> accel = 0.02;
> maxaccel = 0.2;
>
> buy = cross( close, sar( accel, maxaccel ) );
>
>
> Best regards,
> Tomasz Janeczko
> ===============
----- Original Message -----
From: <kbennett@xxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Tuesday, November 13, 2001 2:43 AM
Subject: [amibroker] Valid code for SAR?
>
> Please could someone confirm that this sample of code is valid:
>
> Buy=Exrem(C>SAR(),C<SAR());
> Sell=Exrem(C<SAR(),C>SAR());
>
> How do I change acceleration and maximum accelaration in code?
>
> Keith B
>
>
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
------=_NextPart_001_0115_01C16D5D.3440E9A0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2600.0" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Keith,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>the following is a SAR based trading system. Both
SAR parameters can be optimized for each security. </FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Regards,</FONT></DIV>
<DIV><FONT face=Arial size=2>Dima.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>PS: I am not able to follow this group on daily
basis, so if you have any questions, please send/cc it to <A
href="mailto:rasnitsyn@xxxx">rasnitsyn@xxxx</A></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial
size=2>=======================================================</FONT></DIV>
<DIV><FONT face=Arial size=2>// Enter/Exit using Stops on signal price<BR>accel
= <BR> IIf (Name() == "BRO", 0.02,<BR> IIf
(Name() == "HCA", 0.00, //0.07, <BR> IIf (Name() == "LLL",
0.00, <BR> IIf (Name() == "PDCO", 0.01, <BR>
IIf (Name() == "POOL", 0.00, <BR> IIf (Name() == "SONC", 0.00,
<BR> IIf (Name() == "THC", 0.01,<BR> IIf
(Name() == "UNH", 0.05, <BR> IIf (Name() == "ACS", 0.00,
<BR> IIf (Name() == "", 0.03, <BR> IIf
(Name() == "", 0.03, <BR> IIf (Name() == "", 0.03,
<BR>
0.03))))))))))));</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>accel = LastValue (accel);<BR>accel = Optimize
("Accel", accel, 0.01, 0.1, 0.01);</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>maxS = <BR> IIf (Name() == "BRO",
0.3,//0.2,<BR> IIf (Name() == "HCA", 0.3,//0.2,
<BR> IIf (Name() == "LLL", 0.2, <BR> IIf
(Name() == "PDCO", 0.1, <BR> IIf (Name() == "POOL", 0.2,
<BR> IIf (Name() == "SONC", 0.2, <BR> IIf
(Name() == "THC", 0.3,<BR> IIf (Name() == "UNH", 0.5,
<BR> IIf (Name() == "", 0.2, <BR> IIf
(Name() == "", 0.2, <BR> IIf (Name() == "", 0.2,
<BR> IIf (Name() == "", 0.2,
<BR>
0.2))))))))))));</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>maxS = LastValue (maxS);<BR>maxS = Optimize ("Max",
maxS, 0.1, 0.6, 0.1);<BR>s = SAR (accel, maxS);</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>signalPrice = IIf (accel > 0, Ref (s,-1)
,1000);</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>// Buy on break of yesterday SAR stop, or on open
tomorrow if crossed today SAR STOP<BR>BuyBreak = Cross (H, signalPrice)
and accel > 0 ;<BR>buySignal = Cross (H, s) and accel > 0 ;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>SellBreak = Cross (signalPrice, L);<BR>sellSignal =
Cross (s, L);</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>BuyPrice = IIf ( BuyBreak , Max (Open,
signalPrice), Ref (Open, 1));<BR>SellPrice = IIf ( SellBreak , Min
(Open, signalPrice), Ref (Open, 1));</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>Buy = BuyBreak OR BuySignal;<BR>Sell =SellBreak OR
SellSignal;<BR>Buy = ExRem (Buy, Sell);<BR>Sell = ExRem (Sell,Buy);</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>// !! SETTINGS MUST POINT FOR TODAY (i.e. no
offset)<BR>//BuyPrice = IIf (IsTrue(NOT Buy and Ref (Buy, -1) and not
buySignal), Ref (BuyPrice, -1), BuyPrice);<BR>//SellPrice = IIf (IsTrue(NOT Sell
and Ref (Sell, -1) and not buySignal), Ref (SellPrice, -1),
SellPrice);</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>inTrade = Flip (Buy,
Sell);<BR>MaxGraph=5;<BR>Graph0 = Close;<BR>Graph0BarColor = IIf (inTrade, 5,
1);<BR>Graph0Style = 64;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>Graph1 = s;<BR>Graph1Style = 24;<BR>"TOMORROW " +
WriteIf (buySignal AND NOT BuyBreak, " Buy on Open ", WriteIf (sellSignal AND
NOT SellBreak, " Sell on Open ", WriteIf (inTrade, " Exit Stop Loss: ", " Entry
Stop Price: ") + WriteVal (s)));<BR>"Today Signal price was: " + WriteVal
(signalPrice) + " ; SAR price: " + WriteVal (s);<BR>"By the end of day should be
" + WriteIf (inTrade, " In Trade ", " Out ");<BR>WriteIf (Buy, " TODAY HAD TO
ENTER THE TRADE ", WriteIf (Sell, " TODAY HAD TO EXIT THE TRADE ", "
"));</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>"Buy Price: " + WriteVal (BuyPrice) + " ;
Sell Price: " + WriteVal (SellPrice);<BR>"\n";<BR>Title = "SAR trading system.
SAR: " + WriteVal (s) +" ; Signal price: " + WriteVal
(signalPrice);</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>// Price slippage<BR>// BuyPrice =
1.005*BuyPrice;<BR>// SellPrice = 0.995*SellPrice;</FONT></DIV>
<DIV><FONT face=Arial
size=2>=======================================================</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
Panos Boufardeas
</DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A title=amibroker@xxxxxxxxxx
href="mailto:amibroker@xxxxxxxxxxxxxxx">amibroker@xxxxxxxxxxxxxxx</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Tuesday, November 13, 2001 6:13
PM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> Re: [amibroker] Valid code for
SAR?</DIV>
<DIV><BR></DIV><TT>HI : Keith B few days ago Tomasz
answer<BR><BR>--- In amibroker@xxxx..., "Tomasz
Janeczko" <amibroker@xxxx...>
wrote:<BR>> Hello,<BR>><BR>> Please note that the notation = 0.02
means default values<BR>> of parameters (used if no arguments are supplied)
so<BR>><BR>> SAR() is equivalent to SAR( 0.02, 0.2 )<BR>><BR>> If
you want to pass the parameters use the following<BR>><BR>> accel =
0.02;<BR>> maxaccel = 0.2;<BR>><BR>> buy = cross( close, sar( accel,
maxaccel ) );<BR>><BR>><BR>> Best regards,<BR>> Tomasz
Janeczko<BR>> ===============<BR><BR>----- Original Message -----<BR>From:
<kbennett@xxxx><BR>To: <amibroker@xxxxxxxxxxxxxxx><BR>Sent:
Tuesday, November 13, 2001 2:43 AM<BR>Subject: [amibroker] Valid code for
SAR?<BR><BR><BR>><BR>> Please could someone confirm that this sample of
code is valid:<BR>><BR>>
Buy=Exrem(C>SAR(),C<SAR());<BR>>
Sell=Exrem(C<SAR(),C>SAR());<BR>><BR>> How do I change
acceleration and maximum accelaration in code?<BR>><BR>> Keith
B<BR>><BR>><BR>><BR>><BR>><BR>> Your use of Yahoo! Groups is
subject to <A
href="http://docs.yahoo.com/info/terms/">http://docs.yahoo.com/info/terms/</A><BR>><BR>><BR>><BR><BR><BR></TT><BR><TT>Your
use of Yahoo! Groups is subject to the <A
href="http://docs.yahoo.com/info/terms/">Yahoo! Terms of Service</A>.</TT>
<BR></BLOCKQUOTE></BODY></HTML>
------=_NextPart_001_0115_01C16D5D.3440E9A0--
Attachment:
Attachment:
Description: "Description: Binary data"
|