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

Coding Question

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

    Coding Question

    Hello,
    On the CCI Indicator I am trying to say:
    If the CCI(14)[0]>50;
    do something
    and if the CCI(14)[0]<-50;
    do something
    I tried using the "private int" like this:
    private int period = 14;
    private int ccimax = 50;
    private int ccimin = -50;
    and I also put these under "Properties".
    The problem is when I'm in the Indicator settings, it won't accept a negative number, like -50...if I enter in the number -50 it always returns to the number 1. When entering the positive number 50...it works ok.
    Should I be using something other that "private int"?
    or what can I use to allow indicator setting to accept a negative number like -50 to reflect the -50 line of the CCI?

    Thanks

    #2
    Check your "minimum" setting in the properties dialog. The default is 1.

    Comment


      #3
      Thanks for your help.

      Got it now.

      Thanks

      Comment


        #4
        Same issue here. This is what I've done:

        Code:
        private int vleveldown = 10; // Default setting for Vleveldown
        private int vlevelup = 90; // Default setting for Vlevelup
        
        [...]        
        
        [Description("")]
        [GridCategory("Parameters")]
        public int Vleveldown
        {
                    get { return vleveldown; }
                    set { vleveldown = Math.Max(-100, value); }
        }
        
        [Description("")]
        [GridCategory("Parameters")]
        public int Vlevelup
        {
                    get { return vlevelup; }
                    set { vlevelup = Math.Max(-100, value); }
        }
        In the backtest window both parameters won't accept negative values. Even if I set it up as the default value.

        Any ideas?
        Many thanks for the help,

        Chris

        Comment


          #5
          Chris, are you sure you compiled those change in and then tested on a new strategy instance?
          BertrandNinjaTrader Customer Service

          Comment


            #6
            Good morning Bertrand,

            You're right, there's something NT does not like anymore in my strategy.

            It compiles OK (no errors) but when I select it in the backtest window it keeps the parameters of the previous strategy I had selected on the list. Strange.

            I now have many // in my custom code, could it be the issue?

            Comment


              #7
              Did you save a parameter template for the strategy at one point in time?
              BertrandNinjaTrader Customer Service

              Comment


                #8
                Sorry what is a "parameter template". In my strategy there is no "session template" under time frame. Is this what you mean?

                I know NT crashed this AM because of exception due to DMIndex (I do not know why). It could be related or not?

                Comment


                  #9
                  No, if you right click in your parameters section you could set a default here so your settings would be remembered next time you use the strategy. You can double-check this by shutting NT down and going to the Documents\NinjaTrader 7\templates\Strategy folder > you would then see a template listed here for your strategy, remove it and restart NT and recheck if your changed parameter properties would now show the desired effect.
                  BertrandNinjaTrader Customer Service

                  Comment


                    #10
                    You're right, I used default values a lot. I've deleted the template and re-started NT but the strategy won't load in the backtest window.

                    Comment


                      #11
                      Great, any error in your log tab then shown?
                      BertrandNinjaTrader Customer Service

                      Comment


                        #12
                        Just that after compiling the strategy.

                        15/11/2011 12:06:12|3|128|Failed to call method 'Initialize' for strategy 'sy20111110MA/fdbeff33546d4e03bf414c5e52da057a': Index was outside the bounds of the array.

                        BTW after compiling the backtest window loads another strategy.

                        Comment


                          #13
                          Yes, you would need to look into this specific strategies Initialize() and debug why index out of bounds is thrown - as the Initialize() is run across all strategies it can impact running your other strategies as well.
                          BertrandNinjaTrader Customer Service

                          Comment


                            #14
                            Thank you Bertrand, there is something NT does not like in:

                            Code:
                            WilliamsR(Close, Vperiodin).Panel = 1;
                            WilliamsR(Close, Vperiodin).Lines[0].Value = Vleveldown;
                            WilliamsR(Close, Vperiodin).Lines[1].Value = Vlevelup;
                            WilliamsR(Close, Vperiodin).Plots[1].Pen.Color = Color.Transparent;
                            Add(WilliamsR(Close, Vperiodin));
                            WilliamsR(Close, Vperiodout).Panel = 1;
                            WilliamsR(Close, Vperiodout).Lines[0].Value = Vleveldown;
                            WilliamsR(Close, Vperiodout).Lines[1].Value = Vlevelup;
                            WilliamsR(Close, Vperiodout).Plots[0].Pen.Color = Color.DarkOrange;
                            WilliamsR(Close, Vperiodout).Plots[1].Pen.Color = Color.Transparent;
                            Add(WilliamsR(Close, Vperiodout));
                            Do you see something I obviously don't?

                            Comment


                              #15
                              Best would be to comment out parts of it and then rechecking to circle in the area with the issue.

                              I don't really see anything from here, but are you sure the plot #'s and line #'s are all fitting?
                              BertrandNinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by kujista, Today, 06:23 AM
                              5 responses
                              15 views
                              0 likes
                              Last Post kujista
                              by kujista
                               
                              Started by f.saeidi, Today, 10:19 AM
                              0 responses
                              2 views
                              0 likes
                              Last Post f.saeidi  
                              Started by traderqz, Yesterday, 09:06 AM
                              2 responses
                              16 views
                              0 likes
                              Last Post traderqz  
                              Started by traderqz, Today, 12:06 AM
                              3 responses
                              6 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Started by RideMe, 04-07-2024, 04:54 PM
                              5 responses
                              28 views
                              0 likes
                              Last Post NinjaTrader_BrandonH  
                              Working...
                              X