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

converting a ninjascript from nt6.5 to nt7

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

    converting a ninjascript from nt6.5 to nt7

    I have a ninjascript that works in the nt6.5. I'm trying to convert it to nt7. I have it compiled successfully in nt7, but I cannot get it to display.

    I want to know whether some coding remain the same in nt7.

    For exemple, in nt6.5, the following piece of code would give me the price and size of the bid on the 3rd row of the market depth.

    if (e.MarketDataType == MarketDataType.Bid)
    {
    if (e.Position == 2)
    {
    b = e.Price;
    v = e.Volume;
    }
    ........

    I want to know whether this still works in nt7. If not, what are the new codes now?

    Thank you.

    #2
    gamevoodoo, do you get any errors in your log tab as you apply the code? There were some minor changes for NT7 for the related SampleMarketDepth sample - http://www.ninjatrader.com/support/f...ead.php?t=3478
    BertrandNinjaTrader Customer Service

    Comment


      #3
      By log tab, do you mean the little window under the codes that could appear after I click on "compile"? If so, no, as I said, I have it compiled successfully.

      I will compare the two "SampleMarketDepth" to see what have been changed. However, it would be great if you can tell directly me whether the piece of code in my 1st post still work, if not what's the new codes.

      I made the ninjascript based on the one issued by NinjaTrader_Bertrand in the following thread:



      But that version was for nt6.5, it would be if someone from the ninjatrader team can issue a newer version.

      Thank you.

      Comment


        #4
        gamevoodoo, that snippet looks ok to me - however the one you used as reference is not compatible for 6.5 and would not even compile, please refer to the one posted in my previous reply which contains an updated one for NT7, too.

        If you like you can post then then full script you have and I will take a look on my end.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          I just compare both SampleMarketDepth from nt6.5 and nt7.

          The only difference is that "int myVolume" is now "long myVolume". The rest of the codes are same.

          In my ninjascript, there's no int anything before the region for NinjaScript generated code.


          I also want to know whether nt6.5 will continue to work in the future, because I'm not sure whether the conversion is worth the effort. The ninjascripts I have now works fine under nt6.5. I'm not sure whether converting them to run on nt7 will make them faster or less resource demanding on the pc (this is very important).

          Thank you.
          Last edited by gamevoodoo; 07-28-2010, 10:18 AM.

          Comment


            #6
            Correct, the volume changed to long in the NT7 version, the other DepthReference you referred to previously has also parts that would need to be move to the new OnStartUp() method in NT7 in order to work with it.

            NT7 is generally is higher performing and features optimized handling of resources, so this will likely have a positive influence on your experienced NinjaScript performance as well.

            6.5 will still be available for a good amount of time, so there's no rush to convert over for you to continue using those scripts.
            BertrandNinjaTrader Customer Service

            Comment


              #7
              The new OnStartUp() method might be the reason why my ninjascript doesn't work in nt7 even it was compiled successfully.

              When you have time, please update the file you release in this thread: http://www.ninjatrader.com/support/f...eferenceSample

              Thank you.

              Comment


                #8
                Yes, then you should have seen an error in your log tab as you attempted to run it as you tried accessing the BarsArray in the Initialize(), pleaee just move this part then to OnStartUp like below -

                Code:
                 
                protected override void OnStartUp()
                {
                if (Bars != null && Bars.MarketData != null)
                {
                marketDepth = Bars.MarketData.Connection.MarketDepthStreams[Bars.Instrument];
                if (marketDepth != null) 
                marketDepth.MarketDepthItem += new MarketDepthItemEventHandler(OnMarketDepth);
                }
                }
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  After I change Initialize() to OnStartUp(), I cannot compile the script anymore.

                  It produces an error, when I click on the error, it simply points to the name of the indicator at public class "name" : Indicator.

                  If I changed it back to Initialize(), I can compile the script again, but nothing display on charts.

                  Thank you for your time.

                  Comment


                    #10
                    You would not change Initialize() to OnStartUp(), those are two independent methods - for example the correct methods of this script for NT7 would then look like this below -

                    Code:
                     
                    protected override void Initialize()
                    {
                    Add(new Plot(Color.Green, PlotStyle.Line, "AskVolume"));
                    Add(new Plot(Color.Red, PlotStyle.Line, "BidVolume"));
                    CalculateOnBarClose = false;
                    
                    }
                    
                    protected override void OnStartUp()
                    {
                    if (Bars != null && Bars.MarketData != null)
                    {
                    marketDepth = Bars.MarketData.Connection.MarketDepthStreams[Bars.Instrument];
                    if (marketDepth != null) 
                    marketDepth.MarketDepthItem += new MarketDepthItemEventHandler(OnMarketDepth);
                    }
                    }
                    BertrandNinjaTrader Customer Service

                    Comment


                      #11
                      Thank you very much!!!

                      It's working now!!!

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by GLFX005, Today, 03:23 AM
                      0 responses
                      1 view
                      0 likes
                      Last Post GLFX005
                      by GLFX005
                       
                      Started by XXtrader, Yesterday, 11:30 PM
                      2 responses
                      11 views
                      0 likes
                      Last Post XXtrader  
                      Started by Waxavi, Today, 02:10 AM
                      0 responses
                      6 views
                      0 likes
                      Last Post Waxavi
                      by Waxavi
                       
                      Started by TradeForge, Today, 02:09 AM
                      0 responses
                      14 views
                      0 likes
                      Last Post TradeForge  
                      Started by Waxavi, Today, 02:00 AM
                      0 responses
                      3 views
                      0 likes
                      Last Post Waxavi
                      by Waxavi
                       
                      Working...
                      X