Platinum Customer
Joined: 3/31/2006 Posts: 3,207
|
Bruce,
I like to do a quick backscan and I am aware of some of the issues with the equity line in SF. This is nothing that I will be basing any major decisions on but I like to look at the equity line.
If I recall correctly the equity line buys an equal amount of all the stocks in the watchlist that meets the buy conditions. The problem with the equity line is that it divides the results by all of the stocks in watchlist so don't you think by multiplying the result back to the count of the stocks in the watch list we should get the same equity line as we had in 2.0?
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
I don't know if you would need to just multiply the results by the number of stocks in the WatchList or multiply the results by the number of stocks in the WatchList and then divide by the number of open positions to get the old number (but suspect the second).
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Platinum Customer
Joined: 3/31/2006 Posts: 3,207
|
Is it dividing it by the current num of stocks in the watchlist and what was the num over time.
what I mean let say you have a 100 stocks in the watchlist today but only 80 of those were around 3 years ago so is it dividing the value of the equity line 3 years ago by 80 or 100. I hope 80 since that's how many stocks we had available then.
How do I plot the num of the stocks obver time in the watchlist?
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
If I'm remembering correctly, it is the number of stocks with Bars at any given point in time and not the total number of symbols in the WatchList if they don't have a Bar at that point in time.
Create a Condition that always returns True (like If Price.Last = Price.Last Then Pass) and then create a Market Indicator to count them.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Platinum Customer
Joined: 3/31/2006 Posts: 3,207
|
Ok thanks
I need to plot the performance of NASDAQ & S&P on a % Chart. How do I do that?
it shows by what % the index is up or down from the begining of the test.
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
How are you setting the "beginning of the test"? If it is in BackScanner, why not just use a Symbol Buy & Hold Line (subtracting 100 will give you the Percent Change)?
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Platinum Customer
Joined: 3/31/2006 Posts: 3,207
|
I remember in 2.0 it would start from the date I picked to start the backtest.
It it's easier to it in the realcode i have to adjust it manually that's ok
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
RealCode doesn't know anything about BackScanner. It doesn't know when you are in or out of Trades or the date range of BackScanner.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Platinum Customer
Joined: 3/31/2006 Posts: 3,207
|
The Symbol Buy and Hold is not the performance of the Index but the performace of the stocks in the watchlist had you bought and held everyone
I need to plot the performance of NASDAQ and S&P as an Index.
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
The Symbol Buy & Hold Line will work on any symbol, not just stocks.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Platinum Customer
Joined: 3/31/2006 Posts: 3,207
|
I see
I just have to be on NASDAQ and S&P
thx
|
|
Platinum Customer
Joined: 3/31/2006 Posts: 3,207
|
Bruce,
On your Thursday, July 22, 2010 10:06:24 AM you said
I don't know if you would need to just multiply the results by the number of stocks in the WatchList or multiply the results by the number of stocks in the WatchList and then divide by the number of open positions to get the old number (but suspect the second)
From my testing it seems to be the later as well. We need to multiply by the Num of the stocks in the watchlist and then divide that by the num of the open positions.
Here is a video
http://www.screencast.com/t/NDk5NDE2Y
and I shared my Layout under My Equity Line in V4
Here is what I did
WEL is the Watchlist Equity Line from the backscanner
IC is a Custom Index on a Rule Price > 0 to plot teh Count of teh stocks in the watchlist
CT is Num of open positions from the backscanner
So this plot the Average Point Gain/Loss of the stocks that are in trade. All trades are doen at teh next days open.
'# WEL = indicator.WatchListEquityLine
'# IC = indicator.Index-MyRuleCount
'# CT = indicator.CountTrades
Static AA As Single
If isFirstBar Then
AA = 0
Else If WEL.Value(1) = 100 AndAlso _
CT.Value > 0 Then
AA = ((WEL.Value - 100) * IC.Value) / CT.Value
Else If CT.Value(1) = 0 AndAlso _
CT.Value > 1 Then
AA = ((WEL.Value - WEL.Value(1)) * IC.Value) / CT.Value
Else If CT.Value > 0 AndAlso _
CT.Value(1) > 0 AndAlso _
CT.Value >= CT.Value(1) Then
AA = ((WEL.Value - WEL.Value(1)) * IC.Value(1)) / CT.Value
Else If CT.Value > 0 AndAlso _
CT.Value(1) > 0 AndAlso _
CT.Value < CT.Value(1) Then
AA = ((WEL.Value - WEL.Value(1)) * IC.Value(1)) / CT.Value(1)
Else If CT.Value = 0 AndAlso _
CT.Value(1) > 0 Then
AA = ((WEL.Value - WEL.Value(1)) * IC.Value(1)) / CT.Value(1)
Else If CT.Value(1) = 0 Then
AA = 0
End If
Plot = AA
And below should plot the correct equity line
PC is teh above indicator
'# PC = indicator.AvgPChofStocksinTrade.2.3
'# CT = indicator.CountTrades
Static AA(1) As Single
If isFirstBar Then
AA(0) = 100 + PC.Value
Else If CT.Value > 0 Then
AA(1) = AA(0)
AA(0) = AA(1) + PC.Value
Else If CT.Value(1) > 0 Then
AA(1) = AA(0)
AA(0) = AA(1) + PC.Value
End If
Plot = AA(0)
Please let me know if I did everything correctly
thx
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
I had not thought about the possibility of needing to use yesterday's count instead of today's count in some circumstances (good catch). I wasn't able to find anything obvious wrong with your work.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Platinum Customer
Joined: 3/31/2006 Posts: 3,207
|
Bruce,
I've meant to create this and send it to you since August but I've been too busy
Watch this video and see if you can figure it out. I've shared my layout in V4 under Equity line issue.
I have no clue why the same strategy as simple as they are changes in relative performace when you change the start date. You have to watch the video to see what I am talking about.
The 1st two tests start on 1/1/2003 while the last two start in 1/1/1998. How is it that the relative performance of the RWQ (Buying the upper 20%) outperforms buying all stocks when the test starts on 1/1/2003 but when you start the test from 1/1/1998 the RWQ underperforms buying all stocks from 2003 tp 2007.
Technicaly no matter when the start date is, starting 1/1/2003 the 2nd and the 4th backscan (Yellow Equity lines, one starting in 98 and the other in 2003) should own the same exact stocks. The same for the 1st and the 3rd backscan (Green Equity lines one starting in 98 and the other in 2003) they both should own every stock that is part of the wacthlist.
So I am puzzeled how when you change the starting date the RWQ backscan goes from outperforming buying all stocks from 2003 to 2007 to underperforming it. You can clearly see this by looking at the Ratio indicators that I've plotted to show the relative performance of the 1st vs the 2nd test (those starting in 2003) and the 3rd vs the 4th (those starting in 1998). The Ratio line in the tests starting in 2003 is rising showing that the Yellow Equity Line is moving higher faster than the Green one while the Ratio line for the tests starting in 1998 starts to decline in 2003 through 2007 showing the the Yellow equity Line is underperforming the Green one.
This makes no sense since starting 2003 they should own the same exact stocks.
Let me know
Many thanks
http://www.screencast.com/t/R2dhMRLSJ2ed
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
After running a bunch of tests, it seems I should have stuck to position in Creating my own Equity Line that "I cannot figure out a way to construct a Watchlist Equity Line of the type you have outlined in the current version of StockFinder."
As Doug indicated, the WatchList Equity line is the ((Prior Equity Line Value) + (AVG Net Change of Equity Lines for each Symbol in WatchList)). This means it is essentially just an average of the Symbol Equity Lines of its components.
There is no way that I can figure out to extract the Percent Changes for each symbol or the Average Percent Changes for each symbol in the WatchList from the Average of the Net Changes of each symbol in the WatchList or the average of the Symbol Equity Lines.
So the WatchList Equity Line is being calculated as if you set aside $100 for each symbol in the WatchList at the start of the BackScan and are not allowed to transfer money from any one symbol to another symbol.
This means that if you start the BackScan in 2003, every symbol has $100 set aside for it. But if you start the BackScan in 1998, by the time you get to 2003, each symbol can have a different amount of money available. So the BackScan starting in 1998 and the BackScan starting in 2003 will be allocating money between symbols differently and get different results.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Platinum Customer
Joined: 3/31/2006 Posts: 3,207
|
Bruce
I see your point about the symbol equity lines having different values in 1998 vs 2003 which can cause different results.
I need to get a general sense of the Equity Line of my Relative Strength Strategy and I finished most of the work almost 2 years ago and I've been waiting for SF to fix the Equity line since so that I can finalize everything and I honestly can't wait anymore. I understand that a lot has changed from the Blocks 2.0 days. SF is a world of difference from Blocks but I have no idea how long it will take to fix the equity line issues. This is not a complain, I just wish they would fix the current version of the equity line so that we can at least work with something before they do all the other great things such as money management rules and etc.. that they plan on doing.
In my RS strategy I am buying an equal amount of each stock so here is another way that I thought I should be able to create an Equity Line that will give me a good sense of the trend of the strategy’s equity line. This is without the use of the backscanner.
I created an InTrade Count RC. The RC will plot the Count of the bars since the buy signal.
'# CC = condition.ScanCondition
'# VST = indicator.VolatilityStopLimit
Static InTrade As Single
Static Count As Single
If isFirstBar Then
InTrade = False
Count = Single.NaN
End If
If InTrade = True Then
Count += 1
Else If InTrade = False Then
Count = 0
End If
If InTrade = False AndAlso _
CC.Value = True Then
InTrade = True
Count = 0
End If
If InTrade = True AndAlso _
Price.Close(1) >= VST.Value(1) AndAlso _
Price.Close < VST.Value Then
InTrade = False
End If
Plot = Count
Then I created the RC below that plots the % CH (1 Day) of the stock if the stock is in a trade. If the stock is not in a trade it will plot Single.NaN. This is also adjusted for having the executions at the Next Days Open.
'# IC = indicator.InTradeCountNextDayOpen
Static SEC As Single
If isFirstBar Then
SEC = Single.NaN
End If
If IC.Value = 1 Then
SEC = (100 * ((Price.Close - Price.Open) / Price.Open))
Else If IC.Value > 1 Then
SEC = Price.PercentChange
Else If IC.Value(1) > 1 Then
SEC = (100 * ((Price.Open - Price.Close(1)) / Price.Close(1)))
End If
If IC.Value = 1 OrElse _
IC.Value(1) >= 1 Then
Plot = SEC
Else
Plot = Single.NaN
End If
Then I ran two Custom Indexs.
1) I created a Rule on the 1st RC. If InTradeCount > 0 Then Pass and a CI to plot the number of the stocks meeting the Rule. This will plot the Total Number of the stocks in a trade.
2) I also ran CI on the 2nd RC to plot the Avg % Ch of the stocks. Since the RC is plotting Single.NaN when the stock is not in a trade this CI only plots the Avg % CH of those stocks that are in a trade.
Finally I created the RC below to plot the Equity Line of the strategy.
This starts to plot from 1/1/1998. It’s as if the start date in the backscanner was set to 1/1/1998.
'# ITC = indicator.Index-InTradeCountNextDayOpen>0.00Count
'# AvgPC = indicator.Index-ROC%WhenInTradeNextDayOpenAvg
'# Year = UserInput.Integer = 1998
'# Month = UserInput.Integer = 1
'# Day = UserInput.integer = 1
Static SEC As Single
If isFirstBar Then
SEC = 100
End If
If Price.DateValue.Year = Year AndAlso _
Price.DateValue.Month = Month AndAlso _
Price.DateValue.Day = Day AndAlso _
ITC.Value >= 1 Then
SEC = 100 + AvgPC.Value
Else If Price.DateValue.Year >= Year AndAlso _
Price.DateValue.Month >= Month AndAlso _
Price.DateValue.Day >= Day AndAlso _
ITC.Value >= 1 Then
SEC = SEC + ((SEC * AvgPC.Value) / 100)
Else If Price.DateValue.Year >= Year AndAlso _
Price.DateValue.Month >= Month AndAlso _
Price.DateValue.Day >= Day AndAlso _
ITC.Value(1) >= 1 Then
SEC = SEC + ((SEC * AvgPC.Value) / 100)
End If
If ITC.Value > 1 OrElse _
ITC.Value(1) >= 1 Then
Plot = SEC
Else
Plot = SEC
End If
The only issue with this equity line that I am aware of is that it rebalances the portfolio everyday as if we put an equal dollar amount in every stock every day since it's averaging the % Changes every day. I just can’t think of a way to do it with having the rebalancing part.
You can copy and paste this Equity Line and change the start date to 1/1/2003 and then plot the ratio of the two Equity lines and you’ll see that since 1/1/2003 the ratio is flat since both equity line perform the same.
I shared chart in V4 under Equity Line InTrade ROC% if you like to use it.
I understand that you have spent hours on topics with equity line issues and it could be frustrating but I would certainly if you take a look at this and see if there is anything that you see wrong with it that I am not aware of.
Jas0501
You know a lot more than I do about RC and programming. Have you created any sort of equity lines to measure the performance of your strategies?
Many Thanks to all
|
|
Registered User Joined: 12/31/2005 Posts: 2,499
|
Here is one approach:
Calculate the equity line of each symbol and then create a market index of that indicator.
Rough sketch
'# TradeSize = userinput.single = 10000
Static shares as integer
static inTrade as boolean
static equity as single
dim gain as single
if isfirstbar then
inTrade = false
equity = 0
shares = 0
end if
if not inTrade andalso entryTrigger then
shares = TradeSize/Price.close
equity -= shares * price.open(-1)
end if
if inTrade then
gain = (entryPrice - price.close) * shares
if exitTrigger then
equity += price.close * shares
shares = 0
gain = 0
endif
end if
plot = equity + gain
The plot start at zero and plots the gain or loss as the case may be. It assumes fixed trade size. The logic for the triggers needs to be provided.
The market index of this plot will provide the performance of the strategy
|
|
Registered User Joined: 12/31/2005 Posts: 2,499
|
QUOTE (jas0501)
Here is one approach:
Calculate the equity line of each symbol and then create a market index of that indicator.
Rough sketch
'# TradeSize = userinput.single = 10000
Static shares as integer
static inTrade as boolean
static equity as single
dim gain as single
if isfirstbar then
inTrade = false
equity = 0
shares = 0
end if
if not inTrade andalso entryTrigger then
shares = TradeSize/Price.close
equity -= shares * price.open(-1)
inTrade = True
end if
if inTrade then
gain = (entryPrice - price.close) * shares
if exitTrigger then
equity += price.close * shares
shares = 0
gain = 0
inTrade = False
endif
end if
plot = equity + gain
The plot start at zero and plots the gain or loss as the case may be. It assumes fixed trade size. The logic for the triggers needs to be provided.
The market index of this plot will provide the performance of the strategy
I forgot to adjust the inTrade boolean. See adjustments above.
|
|
Registered User Joined: 12/31/2005 Posts: 2,499
|
QUOTE (jas0501) QUOTE (jas0501)
Here is one approach:
Calculate the equity line of each symbol and then create a market index of that indicator.
Rough sketch
'# TradeSize = userinput.single = 10000
Static shares as integer
static inTrade as boolean
static equity as single
static entryPrice as single
dim gain as single
if isfirstbar then
inTrade = false
equity = 0
shares = 0
end if
if not inTrade andalso entryTrigger then
shares = TradeSize/Price.close
entryPrice = price.open(-1)
equity -= shares * entryPrice
inTrade = True
end if
if inTrade then
gain = (entryPrice - price.close) * shares
if exitTrigger then
equity += price.close * shares
shares = 0
gain = 0
inTrade = False
endif
else
gain = 0
end if
plot = equity + gain
The plot start at zero and plots the gain or loss as the case may be. It assumes fixed trade size. The logic for the triggers needs to be provided.
The market index of this plot will provide the performance of the strategy
I forgot to adjust the inTrade boolean. See adjustments above.
Also forgot to record entryPrice.
You have been witness to Over-the-shoulder software development ;-}
|
|
Platinum Customer
Joined: 3/31/2006 Posts: 3,207
|
jas0501
I've actually done something like what you explained above. The issue with this especially on the RS strategy is I have to put in the trade size.
Assuming we are looking at 100 stocks, in the RS strategy I am buying an equal dollar amount of the top 20 at the start and then as stocks drop and new ones come through I put an Avg size of all the other stocks in the portfolio in the new stock.
So starting with a $100,000 account $5,000 dollars at the start is allocated in each stock therefore, they each have a 5% weight in the portfolio. When new stocks come in the Avg weighting of all the other stocks is what gets allocated to the new stock.
The problem with putting in a trade size of $5,000 is when the equity line grows to let say $200,000 even at a fully invested level with 20 stocks only $100,000 will be invested and the other half is in cash.
I wonder if I can put the trade size as 5% of the Equity Line so as the Equity Line rises or declines the amount that gets invested in each stock will change automatically.
I can create an Equity Line by adding and subtracting the values of the Market Indicator that plots the Avg Gain/Loss based on your RC above to yesterdays Value something like below
'# ITC = indicator.Index-InTradeCountNextDayOpen>0.00Count This is the Count of the stocks in a Trade
'# AvgPC = This will be the Market Indicator
'# Year = UserInput.Integer = 1998
'# Month = UserInput.Integer = 1
'# Day = UserInput.integer = 1
Static SEC As Single
If isFirstBar Then
SEC = 100
End If
If Price.DateValue.Year => Year AndAlso _
Price.DateValue.Month => Month AndAlso _
Price.DateValue.Day => Day AndAlso _
ITC.Value >= 1 Then
SEC = 100 + AvgPC.Value
Else If Price.DateValue.Year >= Year AndAlso _
Price.DateValue.Month >= Month AndAlso _
Price.DateValue.Day >= Day AndAlso _
ITC.Value(1) >= 1 Then
SEC = SEC + AvgPC.Value
End If
If ITC.Value > 1 OrElse _
ITC.Value(1) >= 1 Then
Plot = SEC
Else
Plot = SEC
End If
But I think if I drag and drop this equity line to your RC and for the TradeSize I'll say use 5% of the value of this equity line the software will carsh because in order for the equity line to get calculted 1st your RC has to get calculated the computer is gone run in circles waiting for one to get calculated so the other one can get calculated.
Do you have any solutions to this? Where we can have the RC use some % of the equity line as the trade size.
Many thanks
|
|
Platinum Customer
Joined: 3/31/2006 Posts: 3,207
|
The way I explained does pretty good job I think other than the fact that it rebalances every day.
The only other issue with it is that assumes a fully invested portfolio all the time even if only 1 stock meets the conditions. If we have only one stock in the portfolio and it drops 10% today this equity line assumes all the funds are invested in that one stock and drop by 10%.
So to adjust for that I drag the 2nd CI or Market Indicator in the RC below
If with 20 stocks we should be at a fully invested portfolio then the RC below will multiply the Avg % Ch of all stocks in a trade by the total num of the stocks in a trade and then divide that by 20. This way if we have less than 20 stocks come through let say 10 its as if the potfolio is in cash by 50%. If more than 20 is as if its on margin.
'# Num = UserInput.Integer = 20
'# ITC = indicator.Index-InTradeCountNextDayOpen>0.00Count
'# AvgPC = indicator.Index-ROC%WhenInTradeNextDayOpenAvg
Static Avg As Single
If isFirstBar Then
Avg = Single.NaN
End If
If ITC.Value >= 1 Then
Avg = (AVGPC.Value * ITC.Value) / Num
End If
If ITC.Value = 1 OrElse _
ITC.Value(1) >= 1 Then
Plot = Avg
Else
Plot = Single.NaN
End If
and then I use this in the final RC in my post on Wednesday, October 20, 2010 3:55:16 PM as the AvgPC.
Now if we have only 1 stock meeting the conditions and drops 10% for the day. (10 * 1) / 20 = 0.5
The equity line will only drop 0.5%
|
|
Platinum Customer
Joined: 3/31/2006 Posts: 3,207
|
QUOTE (thnkbigr)
The way I explained in my post on post this morning at 3:55 PM does pretty good job I think other than the fact that it rebalances every day.
The only other issue with it is that assumes a fully invested portfolio all the time even if only 1 stock meets the conditions. If we have only one stock in the portfolio and it drops 10% today this equity line assumes all the funds are invested in that one stock and drop by 10%.
So to adjust for that I drag the 2nd CI or Market Indicator in the RC below
If with 20 stocks we should be at a fully invested portfolio then the RC below will multiply the Avg % Ch of all stocks in a trade by the total num of the stocks in a trade and then divide that by 20. This way if we have less than 20 stocks come through let say 10 its as if the potfolio is in cash by 50%. If more than 20 is as if its on margin.
'# Num = UserInput.Integer = 20
'# ITC = indicator.Index-InTradeCountNextDayOpen>0.00Count
'# AvgPC = indicator.Index-ROC%WhenInTradeNextDayOpenAvg
Static Avg As Single
If isFirstBar Then
Avg = Single.NaN
End If
If ITC.Value >= 1 Then
Avg = (AVGPC.Value * ITC.Value) / Num
End If
If ITC.Value = 1 OrElse _
ITC.Value(1) >= 1 Then
Plot = Avg
Else
Plot = Single.NaN
End If
and then I use this in the final RC in my post on Wednesday, October 20, 2010 3:55:16 PM as the AvgPC.
Now if we have only 1 stock meeting the conditions and drops 10% for the day. (10 * 1) / 20 = 0.5
The equity line will only drop 0.5%
|
|
Registered User Joined: 12/31/2005 Posts: 2,499
|
You are expecting too much from StockFinder at this point. Your goal is a money management issue with a rotation system. Compounding is not in the cards at this point.
A simpler approach that would provide some indication of the potential would be to create a rank indicator for each stock. Use the rank as the trigger in my equity plot indicator. Enter when rank < 21 and exit when rank > 20. Then create a market indicator of the equity plot.
|
|
Platinum Customer
Joined: 3/31/2006 Posts: 3,207
|
Yea I know
I can't wait for them to fix it
Thx for everything
|
|
Registered User Joined: 12/31/2005 Posts: 2,499
|
By the way, once/IF money managment is available, I think doing compounding where the trade size is a % of the available equity is not the best way to go. Compounding in 5000 bar backtests yields unrealistic results for a couple reasons. I prefer doing fixed trade size as it provide a more reasonable picture.
The reasons to avoid compounding:
o eventualy the dollar value produced trade sizes that are unfillable
o survivorship bias already overstates the performance of long systems to some degree
o I prefer to understate the results to avoid getting seduced by unrealistic performance numbers
|
|
Guest-1 |