Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Automated strategy that would use results of a scanner

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

    Automated strategy that would use results of a scanner

    Hello everyone,
    I was searching the forum to find answer to my problem but so far to no purpose.
    What I need to do is to develop a strategy that would run permanently, every night it would run a scanner on a predefined set of stock symbols, sort the results based on predefined criteria and then take top x stocks and create orders to open positions in these stocks. Also the scanner would identify whether there are conditions met to close any of currently open positions. The scanner would of course include several criteria, indicators and so on. Also after developing such strategy I would like to properly backtest it and optimize.
    My simple question is, whether this is feasible in Ninjatrader or if I need to look for a different solution.
    If my problem can be solved using Ninjatrader, could you please provide me with just a very high level design of such solution? I am capable of creating it, but it would help me to browse the forum looking for more clues how to do it.
    Thank you very much for your advice.
    LXM

    #2
    Hello traderlxm,

    Thank you for the post.

    This is possible by means of a multi-instrument strategy. There is a simple example of this in the platform by default called "@SampleMultiInstrument". This strategy uses AddDataSeries to add an additional instrument to the script. The script can be viewed from a NinjaScript editor. The primary data series is going to be whatever data series is running on the chart, or whatever data series you select in the strategies tab of the Control Center.

    Below are links to the material used to create multi-instrument scripts:

    AddDataSeries - Used to add additional time series and instrument series to your script.

    BarsArray - Used to access the various bars objects you have added

    BarsInProgress - Used to get the context for which series OnBarUpdate is being called for. For example, when BarsInProgress == 0, OnBarUpdate is being called for the primary bars series, so referencing a price variable, like Close[0] will get the latest close price for the primary series. If BarsInProgress == 1, OnBarUpdate is being called for the secondary series, and so on.

    You can also access the other series in your script regardless of what BarsInprogress is using the plural price data arrays such as Closes[][], Lows[][], and Highs[][], here are all of those price data series:

    https://ninjatrader.com/support/help...riceseries.htm

    Please let me know if I can assist further.
    Last edited by NinjaTrader_ChrisL; 12-12-2018, 03:02 PM.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Hi Chris,
      thanks for the reply.
      However I can’t see how I would use it for my purpose.
      I intend to scan thousands of stock symbols, so even if there was a way how to transfer results from the market analyzer to the strategy, which I am not aware of, correct me please if I am wrong, I would need to have all dataseries for all symbols scanned already added to the strategy. Would ninjatrader even handle such amount of dataseries? Or is there a way how to add and remove dataseries from a strategy dynamicaly based on the market analyzer results?
      Thanks
      LXM

      Comment


        #4
        Hello traderlxm,

        Thank you for the reply.

        Multiple thousands of stock symbols streaming data might cause performance problems at high volume. Consider narrowing down the list to add to a strategy. AddDataSeries() is called in State.Configure, which is a one-time setup state, so you must add the desired symbols at the beginning of the strategies initialization.

        Please let me know if you have any questions.
        Last edited by NinjaTrader_ChrisL; 12-15-2018, 03:57 PM.
        Chris L.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by maybeimnotrader, Today, 05:46 PM
        0 responses
        6 views
        0 likes
        Last Post maybeimnotrader  
        Started by quantismo, Today, 05:13 PM
        0 responses
        6 views
        0 likes
        Last Post quantismo  
        Started by AttiM, 02-14-2024, 05:20 PM
        8 responses
        166 views
        0 likes
        Last Post jeronymite  
        Started by cre8able, Today, 04:22 PM
        0 responses
        8 views
        0 likes
        Last Post cre8able  
        Started by RichStudent, Today, 04:21 PM
        0 responses
        5 views
        0 likes
        Last Post RichStudent  
        Working...
        X