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

[amibroker] Re: Questions about the Equity() function



PureBytes Links

Trading Reference Links


Al,
Finally back at it. A few comments on your comments:

(1) I did have my Buy trade delay set to 1 so that was okay. 
(2) I caught the ANDing with a boolean problem so I tried multiplying 
by the results of an IIF (with result = 0 if false).
(3) I didn't realize if your PositionScore result was 0, it took your 
trades alphabetically. I assumed it would just skip any stock with 
that value. This might explain some of my screwy results.
(4) The only reason I had risk set to .10 was to try to force some 
large positions. From my reading on volatility based sizing, I think 
results can actually start degrading with risks too large 
(> .03 or so).
(5) I didn't know you could sequentially refine something the way you 
did with PositionScore. That's a nice trick to know.
(6) I'm going to try your suggestions, but setting PositionSize AFTER 
your Buy and Sell rules seems like a chicken and egg situation to me 
(using equity when equity is dependent on positionsize). But we'll 
see what happens - it wouldn't be the first time AB worked 
differently than I expected.

I'll let you know what I find out.

Dan


--- In amibroker@xxxxxxxxxxxxxxx, Al Venosa <advenosa@xxxx> wrote:
> danielwardadams wrote:
> 
> >
> > Al,
> > Glad to see you're still interested. I tried several variations on
> > the following few statements but I'm still not any getting results
> > that make much sense. I won't be able to work on this for the next
> > several hours but will after that.
> >
> > VB_Based_PosSize = NumberOfShares*Open ;
> > Risk = .10 ;
> > PositionScore = ATR(5)/C * VB_Based_PosSize * IIf(VB_Based_PosSize
> > > .20*Equity(), 0, VB_Based_PosSize) ; //Note still has Equity in 
it.
> > PositionSize  = -Risk*Open/1.1*ATR(5)  ;
> > //PositionSize = -20 ;
> >
> > Dan
> 
> Dan:
> 
> I see a couple of things wrong with what you are doing:
> 
> First, be aware of looking into the future. You are multiplying 
ATR/C 
> (the C being the current close) by the VB term, which is using the 
open 
> of the same day. Is that what you want? If you are buying on 1-day 
> delays at the open tomorrow, Positionscore should be based on the 
bar 
> just before the open (i.e., the closing bar of the previous day). 
So, if 
> your SetTradeDelays is set to 0,0,0,0 (no delays), then your 
> positionscore statement should be ref'd back a day. If you are 
using 
> delays of 1,1,1,1, then your positionscore needs no reffing back. 
And 
> make sure you really meant the open in your VB statement to be the 
same 
> bar as the close in the ATR/C part of the positionscore statement.
> 
> I was in error when I told you to "AND" the qualifier in the 
> PositionScore statement. This would mix a Boolean with a non-
Boolean and 
> would not work in terms of ranking of the candidate stocks to 
trade. 
> Booleans get set to 0 when false or 1 when true. So, if the 
statement is 
> set to 0 (size > 0.2*Equity), then the entire positionscore becomes 
0, 
> and the ranking will be determined alphabetically. You don't want 
this. 
> Now, keeping in mind that I am not a whiz at AFL, I think perhaps 
one 
> could code this in the following way:
> 
> PositionScore = VB_Based_PosSize <= 0.20 * E; // gives a listing of 
all 
> stocks giving a true condition ranked first and all stocks giveing 
a 
> false condition ranked below those
> PositionScore = PositionScore > 0; //selects all stocks giving only 
a 
> true condition from the 1st line
> PositionScore =  PositionScore * ATR(5)/C * VB_Based_PosSize; // 1 
* 
> your actual ranking
> 
> I hope someone who knows AFL better than I will correct this if I'm 
> wrong. I'm totally guessing here.
> 
> Third, your positionsize statement is using a no-delay Open upon 
which 
> to base the size of the trade. In real life, you won't know how 
many 
> shares to order until after the open. Therefore, you should use the 
> previous bar's close to determine your positionsize.
> 
> Putting all this together, your code might look something like the 
> following:
> 
> SetTradeDelays(1,1,1,1);
> Buy = BuyCond1 AND BuyCond2;
> Sell = SellCond;
> E = Equity(1);
> VB_Based_PosSize = NumberOfShares*C;
> Risk = 0.10; // Are you sure you want to risk 10% per trade? That's 
> HUGE!! I think you meant 0.01, didn't you?
> PositionScore = VB_Based_PosSize <= 0.20 * E;
> PositionScore = PositionScore > 0;
> PositionScore =  PositionScore* ATR(5)/C * VB_Based_PosSize;
> 
> The only other thing is that I'm not sure you can use the Equity 
> function as above.
> 
> Let me know if this works.
> 
> Al Venosa





------------------------ Yahoo! Groups Sponsor --------------------~--> 
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/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/