Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Simplest of questions.

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

    Simplest of questions.

    Just started working my way through NT tutorials. Never programmed before but thought I'd give it a shot. Was doing well until I hit multiple timeframes. Was trying to follow directions in "Multi-Time Frame & Instruments" in NinjaTrader Version 6 Help Guide and decided that it had enough information to simply plot the high of a different time frame (I decided on 3 min instead of making it variable to make things easy) in a 1 min chart.

    For some reason I'm stuck on the

    Add(PeriodType.Minute,
    3);

    part. When compiling, it says No overload for method 'Add' takes '2' arguments... not to mention the other errors.

    I've included a screen shot. Any help would be much appreciated. & my apologies also, it seems that nobody else has asked such an elementary question in the past that I can see the answer to.

    DK
    Attached Files

    #2
    You are in the middle of building a NinjaScript Indicator. Multi-time frame indicators are not currently supported which is why that syntax is not available. That syntax only works in a NinjaScript Strategy.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Oops... nevermind those last questions... managed to figure it out... I think.
      Last edited by 8DTK8; 07-01-2008, 02:08 PM.

      Comment


        #4
        Trying to Optimize

        Can someone tell me how I can make a variable a parameter that I can optimize? I can't seem to find any documentation or support board questions that help me.

        Specifically, I would like to be able to optimize the offset of a short entry order. It's currently set to 2 tics.

        {
        EnterShortLimit(DefaultQuantity, Highs[
        2][0] - 2 * TickSize, "SHORT!");
        }

        What script do I have to enter (& where... I'm quite new at this) so that I can declare the range that I want it to test in Strategy Analyzer?

        Thank you very kindly in advance,

        DK

        Comment


          #5
          To create an user definable parameter that can be optimized you go about it the same way you create any user definable parameter. To see example of this please check out any of the prebuilt indicators or even SampleMACrossOver strategy. Pay attention to the "Variables" and "Properties" regions of the code. That is where you create the parameters. Just mimic the code technique there with your own variables and you will be golden.
          Josh P.NinjaTrader Customer Service

          Comment


            #6
            Thank You!

            Josh,

            Sir, you are a prince. It worked! I raise my beer (which may have been the reason I couldn't figure it out on my own, but we'll never know) to you.

            I hope the long weekend treats you well.

            Regards,

            DTK

            Originally posted by Josh View Post
            To create an user definable parameter that can be optimized you go about it the same way you create any user definable parameter. To see example of this please check out any of the prebuilt indicators or even SampleMACrossOver strategy. Pay attention to the "Variables" and "Properties" regions of the code. That is where you create the parameters. Just mimic the code technique there with your own variables and you will be golden.

            Comment


              #7
              Optimizer

              I am happy to say that I have the optimizer up and running.

              Unfortunately I've discovered that there is a difference between the results that optimizer comes up with for particular combinations and the results that the backtest function comes up with when the parameters are entered manually.

              The attachments are as follows. The first is the top 3 optimized results. The first parameter was held constant at 2 and the last parameter was held constant at 8. The middle variable had a min of 5, max of 15 and increment of 5.

              The latter screen shots are of backtested results manually entering the combinations of 2,5,8 in the first case, 2,10,8 in the second and 2,15,8 in the third. The only one that matches up is the first 2,5,8 and although it's on the top, the optimizations were supposed to sort "max profit". According the the separate backtests over the same dates, it's not the one that generates the maximum profit at all.

              Any advice would be greatly appreciated.

              Thank you kindly,

              DK
              Attached Files

              Comment


                #8
                Please ensure you are backtesting and optimizing with the same algorithms and fill types. Check the Settings tab. They need to be 100% identical.
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  I can't tell if I can't get this to work because my script is wrong or because it's not something that can be done in optimizer. Can the range include zero and/or negative numbers?

                  Thanks,

                  DK

                  Comment


                    #10
                    Do you mean the parameter range to optimize? I believe it should with 0 and negative numbers too.

                    Comment


                      #11
                      BarsSinceEntry

                      Having a little trouble with BarsSinceEntry() on multi-time frame strategy (or maybe it's just a general problem... haven't tried it on single time frame yet).

                      While trying to debug a bigger problem I noticed that BarsSinceEntry() was always returning "0" when it was clearly supposed to be higher.

                      The code I used to find this is:

                      Print("Position is " + Position.MarketPosition +" with BSE "+ BarsSinceEntry(2,"SHORT!",0) +" at " + Time[0].ToString());

                      The barsInProgressIndex index is 2 which is 15 minutes.

                      The output window has everything correct except what I think the BarsSinceEntry should be.

                      Here is a sample output.

                      Position is Short with BSE 0 at 8/13/2008 8:00:00 AM
                      Position is Short with BSE 0 at 8/13/2008 8:15:00 AM
                      Position is Short with BSE 0 at 8/13/2008 8:30:00 AM
                      Position is Short with BSE 0 at 8/13/2008 8:45:00 AM
                      Position is Short with BSE 0 at 8/13/2008 9:00:00 AM
                      Position is Short with BSE 0 at 8/13/2008 9:15:00 AM
                      Position is Short with BSE 0 at 8/13/2008 9:30:00 AM
                      Position is Short with BSE 0 at 8/13/2008 9:45:00 AM
                      Position is Short with BSE 0 at 8/13/2008 10:00:00 AM
                      Position is Short with BSE 0 at 8/13/2008 10:15:00 AM

                      What should be the BarsSinceEntry variable is always "0".

                      I'm not sure what I'm doing wrong, but I would very much appreciate the help.

                      Thanks many in advance.

                      Comment


                        #12
                        In a multi-instrument/time strategy BarsSinceEntry() returns the bars on the FIRST series of the instrument. This is to be contrasted against the return of the number of bars in the secondary series for the instrument.
                        Josh P.NinjaTrader Customer Service

                        Comment


                          #13
                          I'm not sure if I fully understand.
                          Would you be so kind as to suggest a way for me to keep track of the number of bars that have gone by in a multi-time strategy?

                          This is what I currently have just to see if it's returning the value that I want.

                          if (BarsInProgress == 2 && Position.MarketPosition == MarketPosition.Short)
                          {
                          Print("Position is " + Position.MarketPosition +" with BSE "+BarsSinceEntry(2,"SHORT!",0) +" at " + Time[0].ToString());
                          }

                          Both the first series and the 3rd series of data are 15 min. I am assuming that this being the case whether the int barsInProgressIndex is "0" or "2" should return the same value since they are both 15 min bar series.

                          Thank you again for your prompt replies and excellent assistance.


                          Originally posted by NinjaTrader_Josh View Post
                          In a multi-instrument/time strategy BarsSinceEntry() returns the bars on the FIRST series of the instrument. This is to be contrasted against the return of the number of bars in the secondary series for the instrument.

                          Comment


                            #14
                            Are you saying the first series is exactly the same as the 3rd series? Same instrument same time frame?

                            BarsSinceEntry() will return on the first series of the particular instrument, not the first series in general.

                            Consider this:
                            BarsInProgress 0 = AAPL 5min
                            BarsInProgress 1 = MSFT 5min
                            BarsInProgress 2 = MSFT 15min

                            You run BarsSinceEntry() in BarsInProgress 2 you will get the bars since entry in relation to BarsInProgress 1 not 0.

                            To know it in terms of BarsInProgress 2, you will need to run math calculations and derive that from the BarsInProgress 1 value returned.
                            Josh P.NinjaTrader Customer Service

                            Comment


                              #15
                              Gotcha

                              I understand this now (sorry, it's been a long night of wanting to figure this out).

                              I now have BarsSinceEntry(1,"SHORT!",0) in BarsInProgress 1 and the "SHORT!" trade was also executed in BarsInProgress 1.

                              It seems that in a multi time frame strategy, there has to be the " 1,"SHORT!",0 " in the brackets because just "()" seems to crash although it compiles. Just to be sure, I matched the series that I wanted to the 1 spot like you showed me below. This all seems to conform to what the help page on BarsSinceEntry() tells me to do.

                              Unfortunately I still get all zeros for this value just the way it looked in my earlier output window that I cut and paste.

                              If there's anything else you can think of as to why all I get is 0s when there are trades that last as long as days and the first series is a 15 min period, I would love to hear it.

                              Thanks again.


                              Originally posted by NinjaTrader_Josh View Post
                              Are you saying the first series is exactly the same as the 3rd series? Same instrument same time frame?

                              BarsSinceEntry() will return on the first series of the particular instrument, not the first series in general.

                              Consider this:
                              BarsInProgress 0 = AAPL 5min
                              BarsInProgress 1 = MSFT 5min
                              BarsInProgress 2 = MSFT 15min

                              You run BarsSinceEntry() in BarsInProgress 2 you will get the bars since entry in relation to BarsInProgress 1 not 0.

                              To know it in terms of BarsInProgress 2, you will need to run math calculations and derive that from the BarsInProgress 1 value returned.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              648 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