Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Newbie Trending Question

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

    Newbie Trending Question

    I am an experienced C# developer, completely new to NinjaScript, and am looking to build my first strategy.

    How, for example, do I say (in Pseudocode):

    if the Ask price of IBM is trending up by .5% over the last 323 trading ticks AND the volume of the INDU is declining at .5% over the last 150 trading ticks THEN purchase MSFT at the current Market.


    I'm sure it's really easy, I'm just not real familiar with a lot of the terms mentioned in the docs.

    Thanks in advance -

    #2
    rymoore,

    It depends on what you mean by trending up by .5 percent.

    We do have multi-instrument strategies that are possible, and the examples are in Tools > Edit NinjaScript. Basically you would probably want to attach this strategy to a Microsoft chart, then add in the 2 data series for the IBM and INDU using the Add() method.

    BarsInProgress then can be checked for which data series is calling OnBarUpdate.

    A good place to start, is to use the Strategy Wizard to get some idea of the proper syntax.

    Please let me know if I may assist further.
    Adam P.NinjaTrader Customer Service

    Comment


      #3
      Thanks for the reply.

      OK, I think I have an idea of how to set up my strategy. Here are a few more extremely newbie questions:

      1) Where is a good place to read-up to understand basics, like the definition of a bar or a tick?

      2) How do I run any strategy (SampleMultiInstrument for example) against historical data? I've discovered the "backtest" function, but I get no results... do I have to subscribe to a data provider that provides minute-level data in order to effectively do any historical testing?

      3) I've discovered how to look up a "historic" price using:
      var b = BarsArray[0].GetBar(DateTime.Now.Subtract([some timespan here));
      var oldPrice = Close[b];


      let's say I want to look up the Ask price of a symbol N 15 minute intervals ago... how would I attempt that? (so I don't have to consider dates, times, etc).

      for example: "give me the price of MSFT 210 15 minute trading intervals ago"

      Thanks again

      Comment


        #4
        rymoore,

        1) Where is a good place to read-up to understand basics, like the definition of a bar or a tick?
        Investopedia is a good place related to defining trading terms, etc.

        2) How do I run any strategy (SampleMultiInstrument for example) against historical data? I've discovered the "backtest" function, but I get no results... do I have to subscribe to a data provider that provides minute-level data in order to effectively do any historical testing?
        Yes, you would need a data provider before you get data to test over.

        3) I've discovered how to look up a "historic" price using:
        var b = BarsArray[0].GetBar(DateTime.Now.Subtract([some timespan here));
        var oldPrice = Close[b];
        let's say I want to look up the Ask price of a symbol N 15 minute intervals ago... how would I attempt that? (so I don't have to consider dates, times, etc).
        If you use a 15 minute chart you can just look at Close[0] if calculate on bar close is set to true, or Close[1] if its false. As far as the Ask price, there is a way to add it as a data series.

        Add(string instrumentName, PeriodType periodType, int period, MarketDataType.Ask)

        I would suggest going through our tutorials and building some stuff yourself to see how it works.



        There are also reference samples in our forum.



        Please let me know if I may assist further.
        Adam P.NinjaTrader Customer Service

        Comment


          #5
          Does this look like it would accomplish the N-15 minute interval in the past "percent trend" that I was referring to?

          Code:
          private bool PriceIsTrending(Bars bars, int barsInPast, double target) {
          			var bar = CurrentBar - barsInPast;
          			var oldPrice = bars.GetClose(bar);
          			
          			if (target > 0) {
          				return (bars.CurrentAsk / oldPrice) > target;
          			}
          			else {
          				return (bars.CurrentAsk / oldPrice) < target;
          			}
          		}

          Comment


            #6
            rymoore,

            Looks like it would. It would be the ratio of new price to old price if my understanding is correct.


            Please let me know if I may assist further.
            Adam P.NinjaTrader Customer Service

            Comment


              #7
              Thanks - that seems to work great.

              Another question... is it possible to somehow access the market data that is being used for NinjaTrader? For example, when I set up a back-test for 2 years, 15 minute bars of a stock, is it possible for me to somehow access that data in .csv or other format so i can import it into another database for comparison/testing?

              Thanks

              Comment


                #8
                Yes, you could export the data via NT7's Historical Data Manager - http://www.ninjatrader.com/support/h.../exporting.htm

                Comment


                  #9
                  Good Day Bertrand

                  Originally posted by NinjaTrader_Bertrand View Post
                  Yes, you could export the data via NT7's Historical Data Manager - http://www.ninjatrader.com/support/h.../exporting.htm
                  I have a few statistical models that I developed and used on another platform. On that platform I could export open, high, low and close into a spreadsheet. On the spreadsheet I applied the statistical calcs to generate a price level for action.

                  Is that type of data export...open high low and close an option on NT?

                  What about other indicator based numerical values?

                  Thanks in advance if you care to reply.

                  Comment


                    #10
                    Hi wldman, for indicator value export this would need to be done in the script directly via for example File.IO : http://www.ninjatrader.com/support/f...ead.php?t=3477

                    For more performance you could look into StreamWriter / Reader from C#.

                    Comment


                      #11
                      Thank you for the response.

                      That might be great for guys that are adept with C# and are accomplished programmers....I am not one of those guys.

                      The platform/broker/product selection is a real quagmire. The prior reference is to a company that is also a B/D...and their markets are terrible in my opinion. NT has a very nice visual integration with my broker (best markets) but I am limited by my inability to code.

                      How receptive is NT to user suggestions AND is there any idea in the works to have company sponsored training. I'd be a first day sign up on that. Also, I would consider hiring a person for the necessary work.....does the company facilitate that?

                      Comment


                        #12
                        Originally posted by wldman View Post
                        I have a few statistical models that I developed and used on another platform. On that platform I could export open, high, low and close into a spreadsheet. On the spreadsheet I applied the statistical calcs to generate a price level for action.

                        Is that type of data export...open high low and close an option on NT?

                        What about other indicator based numerical values?

                        Thanks in advance if you care to reply.
                        That depends on the granularity that you seek. For Tick, 1-minute or daily data, the export from the Historical Data Manager is already in OHLC format, albeit you will have to dress it up to delete the volume column.

                        If you want any other granularity, you are probably going to have to use a StreamWriter to output what you want. ref: http://www.ninjatrader.com/support/f...ead.php?t=3475

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                        0 responses
                        647 views
                        0 likes
                        Last Post Geovanny Suaza  
                        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                        0 responses
                        369 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by Mindset, 02-09-2026, 11:44 AM
                        0 responses
                        108 views
                        0 likes
                        Last Post Mindset
                        by Mindset
                         
                        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                        0 responses
                        572 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by RFrosty, 01-28-2026, 06:49 PM
                        0 responses
                        573 views
                        1 like
                        Last Post RFrosty
                        by RFrosty
                         
                        Working...
                        X