• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Scanning through an unknown list of stocks from an automated strategy

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Scanning through an unknown list of stocks from an automated strategy

    Hello,
    I am new to NT and am sorry if this was already covered in the forum, i searched and couldn't find anything.
    My question is - I am writing a ninja script strategy that i want to automatically post trades on any highly active stock that meet my conditions. Meaning i can't hard-code the list of stocks i want it to iterate through.
    I want to know if there is a way for me to get by code all the stocks being traded in NYSE and NASDAQ over a certain volume or with a daily change higher than X percent, and then automatically trade them from the same strategy.

    Thank you very much
    Dado

    #2
    Hello dadomil,

    Thank you for your inquiry and welcome to the NinjaTrader Support Forum!

    You would need to create a custom instrument list for the method provided below to work.

    You most certainly can iterate through an instrument list, add these instruments to your strategy, and provide logic to see if any of these instruments meet your criteria in order to trade.

    Here's an example of how to accomplish this:
    Code:
    protected override void Initialize()
    {
         NinjaTrader.Cbi.InstrumentList list = NinjaTrader.Cbi.InstrumentList.GetObject("instrument list name"); // you will want to change the "instrument list name" string to the name of your instrument list
         foreach (Instrument instrument in list.Instruments)
         {
              Add(instrument.FullName, .....);
         }
    }
    Please take a look at this section in the NinjaTrader help guide for further information about working with multiple instruments: http://ninjatrader.com/support/helpG...nstruments.htm

    Please, let us know if we may be of further assistance.
    Zachary G.NinjaTrader Customer Service

    Comment


      #3
      Hello Zachry,
      thank you very much for your quick response.
      This does help me start, but I am still not completely there. So i managed to get all the instruments from an instrument list like this:

      InstrumentList list = InstrumentList.GetObject("SP 500");

      foreach (Instrument instrument in list.Instruments)
      {
      Print(instrument.FullName);
      }

      but what I can't figure out is how do I call all the price and bars methods like PriorDayOHLC on each of those instruments?
      or in other words how do I turn an instrument into a DataSeries.
      I dont want to plot all of them on a chart.
      From all the documentation im reading I see that almost all of the very useful methods that NS provides, are in the context of the stock that the strategy is enabled on. so if I was to choose AAPL, I would enable a strategy on that chart, and all the methods I call will be implicitly on AAPL. but my strategy doesnt know at the beginning what stock is it going to trade, like I already explained.

      Thank you again!

      Comment


        #4
        Hello dadomil,

        It looks like you are just printing the instrument names in the foreach loop you have provided.

        In order to add them as Bars objects, you would need to use the Add() method call as I've provided an example for in my previous post. https://ninjatrader.com/support/help.../nt7/?add3.htm

        The Multi-Time Frame & Instruments section of the help guide provides further information on how to access Bars objects' data: https://ninjatrader.com/support/help...nstruments.htm

        Please, let us know if we may be of further assistance.
        Zachary G.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by brunoviveiros, Today, 04:26 AM
        0 responses
        1 view
        0 likes
        Last Post brunoviveiros  
        Started by Erhard, Today, 04:24 AM
        0 responses
        1 view
        0 likes
        Last Post Erhard
        by Erhard
         
        Started by StevenNelson, 11-19-2019, 05:39 AM
        3 responses
        16 views
        0 likes
        Last Post brucerobinson  
        Started by guidoisot, Today, 03:01 AM
        0 responses
        6 views
        0 likes
        Last Post guidoisot  
        Started by rontronimous, Yesterday, 05:55 PM
        0 responses
        10 views
        0 likes
        Last Post rontronimous  
        Working...
        X