Output Rotation results to Debug window
Author: asurapan
Creation Date: 7/3/2009 2:45 AM
profile picture

asurapan

#1
so I was playing around with the pre-loaded RSI Rotation script. Made some changes to make it a ROC Rotation script. I would like to export the ROC values for all the symbols in the dataset.

this is the line I want to use, but I am having difficulties incorporating it into my ROC Rotation code.

CODE:
Please log in to see this code.


how do I get the above line to work in the code below?

CODE:
Please log in to see this code.
profile picture

Eugene

#2
Which difficulties are you having with that line?

What exactly does not work as you would like (how)?
profile picture

asurapan

#3
I know the line is correct, I just don't know where to put it in the code. It seems to output the results for each symbol muliple times. I created the following script which seems to work properly, but I ultimately want to incorporate this script below with the one above.

CODE:
Please log in to see this code.

profile picture

Eugene

#4
QUOTE:
It seems to output the results for each symbol muliple times.

That's right: you've programmed it to execute it DataSetSymbols times * on each bar.

Add the following line on top of your commented PrintDebug command in the first strategy:
CODE:
Please log in to see this code.
profile picture

asurapan

#5
thanks Eugene. one follow up question. I am expecting both a buy and sell on the same day. I am essentially always holding the top 3 symbols, so when one symbol is sold on 6/30/09 I would also expect a different symbol to be bought on 6/30/09. Any idea why this sometimes happens and sometimes does not happen?
profile picture

Cone

#6
It's probably because the position is rejected due to sizing constraints due to its basis price. (See User Guide: Strategy Window > Backtesting Strategies > 100% of Equity Sizing.)


You'll need a little leeway in your sizing to make sure all trades are executed, so don't use 33.33% sizing. Instead :

1. Use Raw Profit mode, or,
2. Use some amount of margin, like 1.05 to 1, or,
3. Reduce Portfolio Simulation sizing to 32% of equity or less.

However, neither 2 or 3 cannot guarantee that a position won't be rejected.
profile picture

asurapan

#7
yes, I tried already. In raw profit mode, it still has a few times where it does not buy and sell on the same day, although it is much more consistent than options 2 and 3 above. Shouldn't it be perfect in raw profit mode?
profile picture

Cone

#8
Only if the sizing is such that at least 1 share is able to be sized. If the sizing is $1000, then any symbol that trades over $1000/share will be rejected even in RP mode.

Look at the bottom of the Trades list to be sure. It will tell you how many "Trades not included due to insufficient simulated capital."
profile picture

asurapan

#9
sorry to eat up all your time Cone, but can you look at the following code? Trades not included due to insufficient capital are 0. Even when I do raw profit mode using 1 share I still get the same issue. I think there is an issue with my code but cannot seem to figure it out.

CODE:
Please log in to see this code.
profile picture

asurapan

#10
any explanation why trade dates aren't accurate? still cannot seem to figure this out.
profile picture

Cone

#11
Okay, we can take a look. Give us your:
WatchList symbols, and the exact symbol that you click on when you run the script,
data provider, (Y!, Fidelity, ..)
Settings for:
. Scale
. Data Range
. Position Size and margin factor,
. Preference settings (F12)
- commissions
- slippage and round lot settings, (activated?)
- backtest settings

and finally, identify the trades that you're questioning.
profile picture

asurapan

#12
watchlist symbols = XLB XLE XLF XLI XLK XLP XLU XLV XLY
exact symbol clicked = XLB
provider = Fidelity
scale = monthly
data range = 12/31/98 to 06/30/09
position size = raw profit mode of 10,000
margin factor = 1 to 1
settings = slippage, commissions, and backtesting are all deactivated (unchecked)

the trade list shows
entry on 4/30 for XLB
entry on 4/30 for XLK
entry on 5/29 for XLY

exit on 5/29 for XLV
exit on 4/30 for XLP
exit on 3/31 for XLU

I would expect exit dates and entry dates to match. Specifically, if I exited XLU on 3/31, I would epect to be buying something on 3/31 too.
profile picture

Eugene

#13
By the way, your strategy peeks ahead. You simply can not calculate these ROC series using the closing price and execute a trade at open of the same bar.
profile picture

asurapan

#14
ok, but if I use "bar+1" for the buys and sells, I still run into the same issue.
profile picture

Cone

#15
Maybe you've solved this, but I've just spent a good amount of time looking at this and cannot determine why the trades show up as they do. Each iteration through the loop ends with 3 active positions, yet the Trades list and Open Trade plot (right click Equity curve) show that some bars hold 2 or 4 positions. Please create a ticket so we don't overlook something here.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).