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

Position functions



PureBytes Links

Trading Reference Links

Let me start by saying I realize I am spoiled by the large toolbox of 
functions in TradeStation. However some of them are really quite 
useful. I will try to explain why along with my questions.

While I am focusing on TS functions there may be a way to do these 
things in AB and I may not understand how to apply the AB code. 
Please help me out if that is the case.

1. MarketPosition: -1 short, zero out, +1 long This test is used to 
determine how your exit or stop will be applied. ie: if long and 
exit condition = true, then sell at market/stop...but, if you were 
short you want to buy instead.

2. EntryPrice: when the trading system buys or shorts you want to 
set stops based on this price. I have seen some of the workarounds 
the MetaStocks guys have to use...ugly 

3. EntryDate: when the trading system buys or shorts you may want to 
be able to exit based on the number of days in the trade. Also the 
entry date is important for exit tests...see below

4. BarsSinceEntry: There is a BarsSince Fn in AB that might work for 
this if I also know the entry date, but this Fn is a cleaner 
solution. example: if I want to exit X% or Y ATRs down from a recent 
high it works much better to apply this test only if I have a 
position in the stock. If the stock is in a slow decline the 
lookback period may need to be a few months long.

Without the BarsSinceEntry function, if I set the lookback period for 
50-100 bars it is possible to have the desired exit, then a 
legitimate new entry followed by a false exit caused by the condition 
that initiated the first exit, maybe 70 days ago, that should have no 
valid impact on this new trade.

Testing for a period of BarsSinceEntry completely solves that problem.

I am sure I'll have some more of these soon as I continue to explore 
AB. BTW, the reason I am working in AB is the portfolio backtesting 
capability which TS does not have. :)

Cheers
Trader


PS: different topic: Can the default field width for entry/exit dates 
in the backtester results panel be made wider to display mm/dd/yyyy 
properly?

PPS: Peter Carr, thanks for the repost of your correlation Fn.