Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Don't Segregate Indictors and Strategies in Ninjascript

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

    Don't Segregate Indictors and Strategies in Ninjascript

    This is another limitation you guys have chosen to adopt from Tradestation's Easylanguage. Why create an artificial barrier between indicators and strategies? We should be able to plot and draw on the screen and execute orders all from the same .cs file without having to jump through a bunch of hoops. Yes I've seen Josh's SampleStrategyPlot.

    Typically we will develop some magic algorithm. We would like to see the result of this algorithm on the screen as well as generate buys and sells. Why force spreading this across an indicator and strategy ie at least 2 .cs files?

    thanks,
    shawnj

    #2
    Thanks for taking the time post your comments.
    RayNinjaTrader Customer Service

    Comment


      #3
      Update:

      I've spent the better part of the long weekend getting up to speed with Multi-Market coding. There are some tricky synchronization issues to work through ie. which market's bar closed first .

      Fortunately, all the various Draw methods work from within Strategies but unfortunately the override Plot() method does not. I tried various C# hackery to try to expose Plot() from a Strategy (or the same .cs file) but so far nothing very satisfactory. If Strategies exposed Plot(), I think from now own I would just write Strategies (for the multi-market support) for everything.

      Concerning the subject of this thread, the way I would like to see this architecture would be to go away from the concept of a Strategy or an Indicator and instead just have generic code. Call it something neutral like "Code" or "Task". Then use C# Using Declarations to bias the code for a particular task. If the code needs to send orders then add "using NinjaTrader.Orders;" if the code needs to draw to the screen then add "using NinjaTrader.Draw;" if the code needs to access multi-markets then add "using NinjaTrader.MultiData". Then structure the help system around those "using Declarations" ie. Here are all the Methods, Properties and Events exposed by "using NinjaTrader.Orders".

      I guess I'm basically saying make it more like generic C# programming instead of targeted "script" coding. I realize you are trying to please a very wide range of customers who bring a very wide range of experiences, but after spending a few months of fairly intensive ramp-up coding in Ninjascript it is obvious (to me anyway) that a solid foundation in C# programming and Object Oriented Programming in general is essential if you want to write anything beyond a moving average line on the screen.

      After many years of being a loyal Tradestation customer (I bought version 3.01 way back when) , I have now finally and completely pulled the plug on Tradestation. I have converted all my holy grail easylanguage code into ninjascript and formally closed my tradestation account. Movin' on .

      thanks,
      shawnj

      Comment


        #4
        Thanks for sharing your thoughts. Some more info:
        - NT7 will address the "which market's bar closed first" issue (you basically don't have to care any longer)
        - NT7 will support multi series indicators

        Comment


          #5
          Thanks. Looking forward to Version 7.

          I spent the weekend coding up a multimarket Strategy which uses some Drawing methods which I planed on using basically as an Indicator. This morning I got a rude suprise when I tried to apply the strategy to my trading chart. I did all my developement work on a chart that did not have Chart Trader enabled. After a little trial and error I figured out that NT will not let you apply a Strategy to a chart that has Chart Trader enabled and visa-versa. Ugh.

          Looks like I'm back to trying to write an Indicator. In the Easylanguage world the way to address this is with a global variable. I hope I dont have to go that route. I'm hoping C# Events will do the job.

          I haven't thought it yet (probably a weekend project) but I'm thinking I could write 2 indicators. Apply the second indicator to the second market's chart. The second indicator would raise a custom event on each tick that would include perhaps the SymbolName, LastPrice, Volume. Apply the first indicator to my primary chart. The first indicator would have a custom event handler to handle the events from the second chart.

          thanks,
          shawnj

          Comment


            #6
            Just open second instance of the same chart, enable Chart Trader.
            RayNinjaTrader Customer Service

            Comment


              #7
              Well that's what I'm doing for now but I prefer to focus my trading attention on the trading chart.

              Comment


                #8
                Originally posted by shawnj View Post
                This is another limitation you guys have chosen to adopt from Tradestation's Easylanguage. Why create an artificial barrier between indicators and strategies? We should be able to plot and draw on the screen and execute orders all from the same .cs file without having to jump through a bunch of hoops. Yes I've seen Josh's SampleStrategyPlot.
                As a brand-new user of NinjaTrader attempting to migrate from TradeStation, I wondered about this myself. TradeStation actually has more barriers: functions (which can't plot but instead returns values), indicators (which can't return values, but can plot but not trade), and signals (which can trade but not plot). Further, there are barriers between the indicator types paintbar, showme, indicator, etc.

                NinjaTrader seems to have merged together indicators and functions into one category called "indicator". An indicator can be called as a function to return a value. An indicator can plot data, but doesn't have to (in which case it's identical to a TS function).

                Personally I have no problem separating the function/indicator from strategies, because it encourages modular programming and reusable code. However, I agree we shouldn't be forced to have them separate. And there's no reason I can comprehend why strategies can't draw things on a chart.

                In another thread, someone suggested a directory heirarchy for grouping indicators into various categories: oscillators, production, experimental, smoothers, etc. If such a thing is implemented, it would be trivial to have a subdirectory for strategies, simply as a category of code and not some wholly separate thing.

                Kudos to shawnj for migrating his Holy Grail TS code into NinjaTrader. I'm still figuring out how to do that. I'm well-versed in many programming languages including C++ and Java (not C#) and EasyLanguage, but I'm experiencing a steep learning curve trying to port my EasyLanguage stuff over to NinjaTrader.

                -Alex

                Comment


                  #9
                  <<<
                  TradeStation actually has more barriers: functions (which can't plot but instead returns values), indicators (which can't return values, but can plot but not trade), and signals (which can trade but not plot). Further, there are barriers between the indicator types paintbar, showme, indicator, etc.
                  >>>

                  Yep. That Paintbar, Showme and Indicator separation was always annoying. I think Mr. Cruz just liked touting those items (Paintbar and Showme) as Trademarked.

                  I'm still digesting the way Ninjascript seems to have merged the concept of a Function and an Indicator as you pointed out.

                  <<<
                  In another thread, someone suggested a directory hierarchy for grouping indicators into various categories: oscillators, production, experimental, smoothers, etc. If such a thing is implemented, it would be trivial to have a subdirectory for strategies, simply as a category of code and not some wholly separate thing.
                  >>>

                  Maybe if a few more folks will add support to my "Allow Indicators and Strategies to be Organized into Subcategories/Subdirectories" suggestion (as you have - thanks) Ray and company may give it a little more weight.

                  Here is a little tip that may help you (If you come up with a better concept let me know). This comes as a result of allot of trial and error and frustration coding in Ninjascript.

                  Realize when you write new indicator code in Ninjascript, that code is placed into the same namespace code as all the other indicators. This, to me anyway, is conceptually like a global space that all the indicator code resides in. If you have any "bad" code in any of your indicators, you will not be able to compile anything else till the "bad" code is dealt with.

                  This can be very annoying when you are ripping (speed coding) through some new ideas.

                  So here is my tip. In Windows Explorer, navigate to:
                  C:\Documents and Settings\You\My Documents\NinjaTrader 6.5\bin\Custom\Indicator and then drag and drop a shortcut to that directory onto your desktop.
                  Next, create a new directory in Custom and call it something like "IndictorsOffline".
                  Next, create a shortcut to the IndictorsOffline directory onto your desktop.

                  Now, you can treat the Custom\Indicator directory as you production code and Custom\IndictorsOffline as your work-in-progress code. Just drag and drop the .cs file between the directories via the shortcuts. Be aware that to load the .cs file into the Ninjascript editor (or a chart of course), the .cs file must be in Custom\Indicator.

                  thanks,
                  shawnj

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by DJ888, 04-16-2024, 06:09 PM
                  4 responses
                  12 views
                  0 likes
                  Last Post DJ888
                  by DJ888
                   
                  Started by terofs, Today, 04:18 PM
                  0 responses
                  7 views
                  0 likes
                  Last Post terofs
                  by terofs
                   
                  Started by nandhumca, Today, 03:41 PM
                  0 responses
                  6 views
                  0 likes
                  Last Post nandhumca  
                  Started by The_Sec, Today, 03:37 PM
                  0 responses
                  3 views
                  0 likes
                  Last Post The_Sec
                  by The_Sec
                   
                  Started by GwFutures1988, Today, 02:48 PM
                  1 response
                  9 views
                  0 likes
                  Last Post NinjaTrader_Clayton  
                  Working...
                  X