NexusFi: Find Your Edge


Home Menu

 





type of stock screening for NT - code + suggestions


Discussion in NinjaTrader

Updated
    1. trending_up 1,517 views
    2. thumb_up 2 thanks given
    3. group 2 followers
    1. forum 3 posts
    2. attach_file 0 attachments




 
Search this Thread

type of stock screening for NT - code + suggestions

  #1 (permalink)
 drolles 
London, UK
 
Experience: Beginner
Platform: TradeLink, OpenQuant, considering anything that works...
Trading: if it trades...
Posts: 94 since Oct 2010
Thanks Given: 24
Thanks Received: 39

Just looking to bounce something off some of the futures.io (formerly BMT) members. I’d appreciate any input.

NT doesn’t have a stock screener (silly, I agree).

So I’m looking to validate some of this papers findings 108 Years of [AUTOLINK]Momentum[/AUTOLINK] Profits by Elroy Dimson, Paul Marsh, Mike Staunton :: SSRN

This will involve getting the past performance (monthly) of the stocks, working out those that have performed the best. This is a classic role of a stock screener; NT doesn’t have one, so I’m going to implement a simple version myself.

My solution was to create an object called StockReturn:
 
Code
        internal class StockReturn
        {
            public int StockNumber { get; set; }
            public Instrument Stock { get; set; }
            public double Return { get; set; }
            
        }

Create a custom compare method:
 
Code
        private int CompareReturns(StockReturn x, StockReturn y)
        {
            if (x == null)
            {
                return -1;

            } else if (x.Return == y.Return) {

                //return x.Stock.CompareTo(y.Stock);
                return 0;

            }
            else if (x.Return > y.Return)
            {

                return 1;
            }
            else
            {
                return -1;

            }

        }

Calculate the returns, then stuff a list with them, sorting the list with our custom compare method.

 
Code
foreach (Instrument x in this.Instruments)
                {

                    double stockreturn = (Closes[counter][0] - Closes[counter][dayReturn]) / Closes[counter][0];

                    StockReturnList.Add( new StockReturn() {StockNumber=counter, Stock=x, Return=stockreturn});

                    counter++;
                }

                StockReturnList.Sort(CompareReturns);



Any views on more efficient methods or approaches?

Cheers,

drolles

Started this thread Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
Footprint for strategy Builder
NinjaTrader
Trade idea based off three indicators.
Traders Hideout
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
What broker to use for trading palladium futures
Commodities
Cheap historycal L1 data for stocks
Stocks and ETFs
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Funded Trader platforms
49 thanks
Just another trading journal: PA, Wyckoff & Trends
21 thanks
Trading with Intuition
18 thanks
Self sabotage reframed
15 thanks
ApexTraderFunding.com experience and review
8 thanks
  #2 (permalink)
 drolles 
London, UK
 
Experience: Beginner
Platform: TradeLink, OpenQuant, considering anything that works...
Trading: if it trades...
Posts: 94 since Oct 2010
Thanks Given: 24
Thanks Received: 39

Any thoughts on a testing harness for a solution like this?

Unlike the usual visual trading system (e.g. Bollinger Band Breakouts) one can’t do the usual:

1. Check for the outlaying trades
2. Visually inspect that chart in the strategy analyser to confirm correct trading

The only thing I can think of is to export data from a small sample of the stock universe, consolidate the monthly returns, then confirm that stocks traded are the best and worst performers.

Cheers,

drolles

Started this thread Reply With Quote
  #3 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,103



drolles View Post
Any thoughts on a testing harness for a solution like this?

Unlike the usual visual trading system (e.g. Bollinger Band Breakouts) one can’t do the usual:

1. Check for the outlaying trades
2. Visually inspect that chart in the strategy analyser to confirm correct trading

The only thing I can think of is to export data from a small sample of the stock universe, consolidate the monthly returns, then confirm that stocks traded are the best and worst performers.

Cheers,

drolles

You could proceed as follows:

(1) Create a stock list containing all the stocks that you wish to examine
(2) Add that list to the market analyzer
(3) Then add a new column with the ROC[dayReturn] to the market analyzer.

You will now see the returns of all stocls over the selected lookback period.

If you wish to have a look at the monthly returns, you could write a small strategy and run that through the strategy analyzer.

Reply With Quote
Thanked by:
  #4 (permalink)
 drolles 
London, UK
 
Experience: Beginner
Platform: TradeLink, OpenQuant, considering anything that works...
Trading: if it trades...
Posts: 94 since Oct 2010
Thanks Given: 24
Thanks Received: 39

Hi,

As you know, I’m trying to test this against the S&P500.

I use IQFeed as a data provider; therefore the back history you can get on the S&P500 shares varies. NT is testing only once it has data from the instruments in the strategy.

Does anyone know to either:

1. How to hit NT’s database so to determine the instruments where I have a long history?
2. Force NT to start testing on the data it has?

Cheers,

drolles

Started this thread Reply With Quote




Last Updated on May 30, 2013


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts