Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Tick Data and Volume based Backtest

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

    #31
    Hello newworldguy,

    Is the backtest not working?

    Have you added any prints to your script that are not printing?


    Also, when it comes to backtesting, this is for orders. If you have an indicator, applying this to a chart with historical data is the exact same thing as what a backest would do and a strategy is not needed.

    Backtests are for strategies because strategies make orders. A regular backtest would be the same as simply adding the strategy to a chart and looking at the historical performance. The Strategy Analyzer is nice for strategies because you can optimize the parameters of the strategy to find the best performance of order making. This does not really apply to indicators.

    With an indicator, simply apply this to a chart with historical data and you are essentially backtesting the indicator.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #32
      i will work on this later today. r u around till late today?

      Comment


        #33
        newworldguy,

        I will be in the office today 4/23 until 6:00 PM Eastern.

        I will be in tomorrow at 9:00 AM Eastern.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #34
          Chelsea,

          I few questions before I proceed to verify the strategy.

          1) I noticed the statement
          Value.Set(CurrentBar);
          in the TickerTest that you sent me. is this settig the value for the Indicator at the current bar?

          2) When I use an indicator in a strategy, what is the Primary dataseries fed to the indicator? Is it the same as the one for the Strategy?

          I ask because i want to know when I access:
          protected override void OnBarUpdate()
          {
          double myVal = TickTest()[0];

          for example in the strategy, am I accessing the current bar of the indicator...

          3) What will statement such as the following mean inside an indicator that is running in the context of a strategy:

          if(Plot0[0] > 0)
          DrawTriangleUp("My triangle up" + CurrentBar, false, 0, High[0], Color.Black);

          Thanks

          Comment


            #35
            Hello newworldguy,

            I am using Value.Set(CurrentBar); just so that the value of the plot changes on every bar. This is just so that we can see the behavior of the script.
            Yes, this does set the indicator plot value to the current bar number.

            The primary data series passed to an indicator from a strategy will by default be the Close data series. When a dataseries is not passed to the indicator, Input is used by default. You can choose the dataseries passed to an indicator.

            To pass a secondary series:
            SMA(BarsArray[1], 10)[0];

            To pass the high instead of the close:
            SMA(High, 10)[0]);

            To pass another indicator as the data series:
            SMA(EMA(10), 10)[0];


            The code you are asking about:
            if(Plot0[0] > 0)
            DrawTriangleUp("My triangle up" + CurrentBar, false, 0, High[0], Color.Black);

            If the plot on the current bar is set and the value of this is greater than 0, then a dot will be drawn at the high of the current bar.

            If the plot is not set, this could cause an error.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #36
              Can an Indicator return anything other than a double value. i.e. maybe a string value? thanks

              Comment


                #37
                Hi newworldguy,

                An indicator can return any type of object. Plots, however, can only contain double values.

                If you would like to return a value that is not a double, add a public property that is not a double.

                Sample public string that does not show in parameters or overload properties:
                [Description("A returned string")]
                [XmlIgnore()]
                [Browsable(false)]
                public string MyString
                {
                get { return myString; }
                set { }
                }

                This would be called with IndicatorName().MyString
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #38
                  I am trying to import EBS data into NinjaTrader. They provide a quotes file that I was able to convert to NT format and import as bids and ask with no problem. They also provide trades files that has all the trades with timestamps, size price AND whether the trade was GIVEN or PAID from the EBS system perspective. While I can convert this file and import the trades into as LAST, this will lose valuable GIVEN/PAID information. And since NT timestamps are round to the nearest second it may be hard for me to derive this information back back in my model solely through Bid, Ask and Last data... Please advice what is the best way to incorporate the trade side information. Thanks

                  Comment


                    #39
                    Hi newworldguy,

                    I'm not quite sure what Given / Paid means. Is this Buy vs Sell?

                    Also, NinjaTrader will not accept any other data format other than what is outlined in our help guide on importing.
                    http://www.ninjatrader.com/support/h.../importing.htm
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #40
                      No problem. I will explore that further.

                      Now I am trying to run the strategy with the indicator. I notice every time there is a short signal it closes long positions, also it takes only i position at a time. I want to take multiple positions and close existing positions only when I explicity indicate so. please advice. thanks

                      Comment


                        #41
                        Hi newworldguy,

                        This is expected behavior. It is not possible to be in a short position and a long position in your brokerage and it is also not possible to be in a short position and a long position in a strategy.

                        If you are short and you call EnterLong(), NinjaTrader will place one order to exit your current position and another to enter your new position.

                        If you want to exit an order without entering a new position, use ExitShort() or ExitLong().

                        If you want to place a limit order or stop limit order that does not immediately switch the position use EnterLongLimit(), EnterShortLimit(), EnterLongStop(), EnterShortStop(), EnterLongStopLimit(), or EnterShortStopLimit().

                        These order types can be found in the help guide under NinjaScript -> Strategy -> Managed Approach.
                        Below is a link to EnterLongLimit().
                        http://www.ninjatrader.com/support/h...rlonglimit.htm

                        The amount of orders the strategy takes in a direction is controlled by the Entries per direction option in the parameters of the script as you add this to a chart or to the Strategies tab of the Control Center.

                        If Entries per direction is 2, then you can place 2 long order or 2 short orders.

                        Below is a link to the help guide on Running a NinjaScript Strategy from a Chart. This is mentioned in the section 'Understanding strategy properties'.
                        http://www.ninjatrader.com/support/h...t_strategy.htm
                        Chelsea B.NinjaTrader Customer Service

                        Comment


                          #42
                          all i want is if I have 2 long positions (as a result of 2 buy signals) and I get a sell signal , I just want to close 1 of my long positions, i.e. be long 1 position only. that you can do through a brokerage but wanted to know how I can do it in the strategy analyzer. thanks

                          Comment


                            #43
                            Can the following be done without resorting to custome order management:

                            all i want is if I have 2 long positions (as a result of 2 buy signals) and I get a sell signal , I just want to close 1 of my long positions, i.e. be long 1 position only. that you can do through a brokerage but wanted to know how I can do it in the strategy analyzer.

                            Thanks,

                            Comment


                              #44
                              Hi newworldguy,

                              Are you asking if this is possible to create with the Strategy Wizard?

                              If so, yes, you can create orders that use entry signals so that you are able to exit the orders independently.

                              However, this does not mean that you can have a short position and simultaneously have a long position.

                              Attached is a sample that shows how to use entry signals and from entry signals to enter 2 positions and exit only one of them.

                              You will need to run this script with Entries per direction set to 2. (Or instead, you can set the Entry handling to Unique entries as the two entries have unique names.)
                              Attached Files
                              Chelsea B.NinjaTrader Customer Service

                              Comment


                                #45
                                great. thanks. can i also know what is the total position size at any given poijt in time and take actions based on that?

                                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