Download software Tutorial videos
Subscription & data-feed pricing Class schedule


New account application Trading resources
Margin rates Stock & option commissions

Attention: Discussion forums are read-only for extended maintenance until further notice.
Welcome Guest, please sign in to participate in a discussion. Search | Active Topics |

Programmatically select a set of tickers Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
eweave
Posted : Friday, April 5, 2013 10:58:20 AM
Registered User
Joined: 4/5/2013
Posts: 2

Every month, I have a new set of tickers which form my watchlist.  I would like to programmatically select a set of tickers depending on the date which is being evaluated.

 

In Wealth-Lab, I would use a switch and just hardcode the appropriate tickers for a particular date range.

 

Is there a method I can employ in StockFinder which will give me similar results?

Bruce_L
Posted : Friday, April 5, 2013 11:50:54 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138

It is theoretically possible to hardcode both dates:

% from a specific date

And tickers into a RealCode Indicator:

Symbol specific indicators

That said, without knowing the specifics of what you want to do, I could not say if your particular application is possible.



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
eweave
Posted : Sunday, April 7, 2013 10:12:00 AM
Registered User
Joined: 4/5/2013
Posts: 2

Thank you for your reply Bruce.  From reading your attached URLs, it looks like I can accomplish my goal.

 

Below are the specifics of what I need to accomplish:

 

I would like to do a 5 year backtest on an equity trading system.  Every month, I have a set (from as few as 0, to as many as 10) of stock tickers, and these tickers can vary every month.  During the backtest, once the backtest reaches the first of the month, an entry indicator is applied to the symbols for that month.  If there is an entry, then an exit indicator is applied to the current position.  Time is not an exit criterion, so this position may be held into the following month, even if its ticker is not part of that new month’s list of tickers.

 

I have a csv formatted set of my past monthly tickers, basically a std::vector <std::vector> which is 60 x 10.  If appropriate, I can write a ruby script to quickly generate the necessary if / else if statements, using date as the conditional and then load the correct tickers for that timeframe.

 

Do you have code, or pseudo code, suggestions?

 

Many thanks,

Evan

jas0501
Posted : Monday, April 8, 2013 5:14:10 AM
Registered User
Joined: 12/31/2005
Posts: 2,499

It would seem that you could produce a trade indicator from your dated sequences.

Based on :

on entry date:symbol increment indicator by 1

on exist date:symbol decrement indicator by 1

otherwise  it is equal yesterday's value

       indicator = indicator(1) 

 

Then the backtest wound

   enter if indicate > indicator(1)

and

   exit if indicator < indicator(1)

---------------------------------------

The general approach would be on the firstbar of the first symbol load in all the symbol:date information into collection indexed by symbol.

Then on the first bar of a each symbol determine if the symbol is going to be traded and construct the symbol entry-exit date collection indexed by date with a value of +1 or -1 for entry and exit.

This would permit a shortcircuit on first bar  knowing  the symbol can be skipped.

 

symbol:    value of entrydate:exitdate:entrydate:exitdate...ect.

 

If there are transactions, on first bar construct a collection by date +1 or -1 for entry and exit. Then if there are trades, each day to check the collection by date for a value and apply it if present.

This limits the  pocessing to first bar determination of potential trading and  optimizes the process.

--------------------------------

Possible optimizations.

1. If symbol is traded on first bar store the date to look for  and the value and avoid having to do collection lookup.

2. when the date is reached apply the +1 or -1 value and set up the next date to look for and value

3. when there is no next date you can avoid looking any further.

 

 

Users browsing this topic
Guest-1

Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.