PureBytes Links
Trading Reference Links
|
If you translating directly from the pseudo code below, i think you
can ignore the "if positionlong(Lastposition)". During backtesting,
AB will know when you have a long/short position open for that
symbol. Basically it won't let you close out a position you don't
have.
So you can change:
-----------
> if PositionLong(LastPosition) then
> if cond_B then
> SellAtStop...
> if PositionShort(LastPosition) then
> if cond_A < priceOpen(bar)) then
> CoverAtStop...
-----------
To this:
-----------
Sell = cond_b;
SellPrice = xyz; (optinal)
Cover = cond_A < 0;
CoverPrice = abc; (optional)
-----------
--- In amibroker@xxxxxxxxxxxxxxx, "bm_alp" <bm_alp@xxxx> wrote:
>
>
> Hi all,
>
> you might have realized it, the title comes from a Wealthlab code.
> Could anyone help me out to express the logic in Amibroker?
>
> Please have a look at the code below.
> buyAtStop types can be implemented using BuyPrice and a Buy=..
> statement. But what about about a condition like LastPositionActive?
>
> Your comments are much welcome.
> bm_alp
>
> begin
> if not LastPositionActive then
> begin
> if cond_A then
> buyAtStop...
> if cond_B then
> shortAtStop...
> end
> else
> begin
> if PositionLong(LastPosition) then
> if cond_B then
> SellAtStop...
> if PositionShort(LastPosition) then
> if cond_A < priceOpen(bar)) then
> CoverAtStop...
> end;
> end;
------------------------ Yahoo! Groups Sponsor --------------------~-->
$9.95 domain names from Yahoo!. Register anything.
http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/GHeqlB/TM
--------------------------------------------------------------------~->
Check AmiBroker web page at:
http://www.amibroker.com/
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.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/
|