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

[amibroker] Re: problems with AmiBroker built-in stop capabilities



PureBytes Links

Trading Reference Links

--- In amibroker@xxxxxxxxxxxxxxx, "Tomasz Janeczko" <amibroker@xxxx>
wrote:
>
> > Why not use prior bar's High instead of relying on assumptions of
> > using current bar High?  Although you make an assumption (that seems
> > not risky), it still leads to postdictive errors and causes at times
> > to exit too early which can lead to both more profits AND less profits
> > depending on the situation.
> 
> The answer is simple: because it would be contradicory to 
> "ActivateStopsImmediatelly" = TRUE that you have set.
> 
> By setting "ActivateStopsImmediatelly" = TRUE you just exactly
instruct AB that 
> if current's bar High-Low range triggers stop it should be executed.
> 
True, and that's what I want.  However, my point is HOW you calculate
the stop value in the first place.  Do you understand what I mean?  I
think we are miscommunicating between each other.  The current
ApplyStop function seems to calculate the stop value for a current bar
via the High for long positions and via the Low for short positions.

I DO want to exit on day that current H-L value of current bar
TRIGGERS my stop value.  However, what I do NOT want the stop value
CALCULATION to rely on current High as it is impossible to know the
order of Lows and Highs as you admit.  Let me try and explain via some
pseudo logic below, with how I perceive AB ApplyStop calculates its
internal stop value (abStopValue) vs. how I would prefer it to
calculate it (myStopValue).

//Current Pseudo Logic for how AB works with 
//  ActivateStopsImmediatelly=TRUE
abStopValue = High - trailAmountGivenByUser;
if (Low < abStopValue) {
    if (Open < abStopValue) 
        SellPrice = Open
    else
        SellPrice = abStopValue
}

//Preferred Logic with ActivateStopsImmediatelly=TRUE
myStopValue = Ref(High, -1) - trailAmountGivenByUser
if (Low < myStopValue) {
    if (Open < myStopValue) 
        SellPrice = Open
    else
        SellPrice = myStopValue
}

> If you set it to FALSE - then it won't do that. In that case it will
exit
> on NEXT bar (based on previous H-L).
> 
True, and I agree.  It will exit on the next based on previous
High-Low comparison to the stop value.  However, it is the stop value
calculation that I have issue with as I pointed out above.

> There is no postdictive error here. And it does NOT lead to more profits
> - it always leads to less profit (as it assumes worst case that low
actually triggers stop). 
>
That is not always true.

Let's say a stock has the following 2 bars:

1st bar is a Buy:
Opens @ 180
Low of 180
High of 200
Closes @ 200

2nd bar:
Opens @ 190
Low of 182
High of 191
Closes @ 183

Via your logic, with a trail of 5 points as in my code, it would exit
1st bar because Low < abStopValue.  The abStopValue in this case is
High - trailAmount = 200 - 5 = 195.  Thus BuyPrice at 180, SellPrice
at 195 for a 15 point gain.

Via my logic, with a trail of 5 points as well, it would exit the 2nd
bar because 1st bar is bar of entry and thus trail doesn't get
evaluated.  The exit would happen at 190 because it gapped down below
stopValue calculated at 195 (myStopvalue = Ref(High, -1) - 5 = 200 -
5).  Thus, BuyPrice at 180, SellPrice at 190 for only a 10 point gain.

In this case above, the premature stop causes more profit than would
happen otherwise in real world of EOD trading.

Look at GOOG 2/3/2005 trailed stop @ 208.37 but should have sold @
206.47 with my code to see real world example.
 
Best,

JD





------------------------ 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/