PureBytes Links
Trading Reference Links
|
The following code implements a half-on-loss strategy (chande, "beyond
technical analysis) with stocks. The risk depends on the outcome of
the previous trade (regardless long or short). If previous trade was a
winner then risk=6% of total equity. If previous trade was a loser
then risk=3% of total equity.
//-----------------------------------------------------//
e=Equity(1);
profit_l=ValueWhen(Sell,e)-ValueWhen(Ref(Buy,-1),e);
profit_s=ValueWhen(Cover,e)-ValueWhen(Ref(Short,-1),e);
longt= profit_l != Ref(profit_l,-1);
Shortt=profit_s != Ref(profit_s,-1);
profit=Flip(Longt,Shortt)*profit_l+Flip(Shortt,Longt)*profit_s;
Plot(profit_l,"ProfitL",colorBlue,styleLine);
Plot(profit_s,"ProfitS",colorGreen,styleLine);
Plot(profit,"Profit",colorBrown,styleLine);
rsk=IIf(profit>0,6,3);
Plot(rsk,"risk",colorRed,styleLine);
Risk = rsk*0.01* Equity(1);
Shares = risk/ATR(10);
PositionSize = shares * BuyPrice;
//------------------------------------------------------//
cheers
Oscar
------------------------ Yahoo! Groups Sponsor --------------------~-->
Try Online Currency Trading with GFT. Free 50K Demo. Trade
24 Hours. Commission-Free.
http://us.click.yahoo.com/RvFikB/9M2KAA/U1CZAA/GHeqlB/TM
--------------------------------------------------------------------~->
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 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/
<*> 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/
|