Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

LiveUntilCancelled switch issue

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

    #16
    Hi Austin,

    I ran the test with a 1 day lookback period and it worked fine. What hardware configuration do you recommend in order to be able to do an extensive backtesting?

    I need to backtest the system in batches of three months in order to be able to collect data for a minimum of 1 year.

    Thank you.

    Comment


      #17
      rperez, for backtesting on this much tickdata I would either recommend waiting on NinjaTrader 7 or testing this on 10-15 day chunks in NinjaTrader 6.5 on a performing PC (dual / quad with 4 GB RAM). Otherwise you easily run into Windows limitations for a 32 bit process (about 1.3 GB RAM usage).
      BertrandNinjaTrader Customer Service

      Comment


        #18
        Hi Jason,

        For some reason my break even is not working. I've spent hours trying to find out why. Could you please check if there is something wrong? I used your SampleOnBarUpdate code for this purpose.

        Thank you.
        Attached Files

        Comment


          #19
          rperez, please add Prints to the section where you call your SetBreakEven() to see if the code makes it into this part as you would expect.
          BertrandNinjaTrader Customer Service

          Comment


            #20
            Hi Bertrand.... I did that and the code does enter the SetBreakEven() method and evaluates the condition, but the stopOrder is allways null.

            Comment


              #21
              Please also print this price portion of your breakeven, to see if the price you calculate is standing a chance to trigger the stop adjustment -

              Code:
               
              Position.AvgPrice + (bkEvenWhen*2-1 * (TickSize / 2)
              BertrandNinjaTrader Customer Service

              Comment


                #22
                I tried both:

                Position.AvgPrice + (bkEvenWhen*2-1 * (TickSize / 2)and:
                Position.AvgPrice + bkEvenWhen * TickSizeand the condition should trigger the BkEven.

                In this last instruction, if I change the value of the break even to a value smaller than the target, all the entries dissapear from the screen.
                Last edited by rperez; 11-19-2009, 11:49 AM.

                Comment


                  #23
                  rperez, you would really need to print out those values to be sure they calculate as you think they would. Try for example just to trigger the stops if Close[0] > Position.AvgPrice, does the logic after this then hit home?
                  BertrandNinjaTrader Customer Service

                  Comment


                    #24
                    Bertrand, I inserted the Prints and when the setBreakEven() method is supposed to modify the BE it looses the track of the target value and whatever long position is open never gets closed, as shown in the screenshot below. It shows a long position filled on 11/6/2009 and never closes.

                    I also send another copy of the program for you to run.
                    Attached Files

                    Comment


                      #25
                      rperez, will look into and get back to you.
                      BertrandNinjaTrader Customer Service

                      Comment


                        #26
                        rperez, first I would change the Prints to PrintWithTimeStamp, thus giving you more insight when the last modification was done / called, you can see it's getting 'stuck' in your SetBreakEven() call, for example when I test here on ES 1 min charts. Please also just call SetStopLoss again to change your stop losses set for the trail, you current attempt to submit fresh Exit() methods which bring you into trouble with our Internal Order Handling rules -

                        BertrandNinjaTrader Customer Service

                        Comment


                          #27
                          Bertrand....thanks again.... I'm sorry I didn't quite follow what you mean by:

                          "Please also just call SetStopLoss again to change your stop losses set for the trail,..."

                          Should I use the code that I commented out in the program that is below the SetBreakEven() call, instead of using the SetBreakEven()method?

                          SetStopLoss does not return any value, so how do I manage the stopOrder variable?

                          Sorry.

                          Comment


                            #28
                            rperez, please check into the link I posted in my previous post and scroll to the bottom section of it, it will explain the issues you run into when attempting to combine Set() and Exit() together - for example when working with the IOrders like you want in the code to go down the Advanced Order Handling route...please comment out the SetStopLoss / SetProfitTarget calls you have in the Initialize() and then debug order placement from this point forward.
                            BertrandNinjaTrader Customer Service

                            Comment


                              #29
                              Hi Bertrand,

                              I replaced the SetBreakEven() code with the following one, and apparently it is working fine. Does it make sense to you? And please know that I am deeply thankful with you for your patience and time devoted to this matter.

                              // Resets the stop loss to the original value when all positions are closed
                              if (Position.MarketPosition == MarketPosition.Flat )
                              {
                              SetStopLoss("Short:"+myPeriodTypeLegend,Calculatio nMode.Ticks, stop, true);
                              SetStopLoss("Long:"+myPeriodTypeLegend,Calculation Mode.Ticks, stop, true);

                              SetProfitTarget("Long:"+myPeriodTypeLegend, CalculationMode.Ticks, target);
                              SetProfitTarget("Short:"+myPeriodTypeLegend, CalculationMode.Ticks, target);

                              //PrintWithTimeStamp("Bars InP: "+BarsInProgress);
                              }

                              // If a long position is open, allow for stop loss modification to breakeven
                              else if (Position.MarketPosition == MarketPosition.Long )
                              {
                              // Once the price is greater than entry price+12 ticks, set stop loss to breakeven
                              //PrintWithTimeStamp("Close[0] >= Position.AvgPrice + bkEvenWhen * TickSize : "+(Close[0] >= Position.AvgPrice + bkEvenWhen * TickSize ));
                              if (Close[0] >= Position.AvgPrice + bkEvenWhen * TickSize )
                              {
                              SetStopLoss("Long:"+myPeriodTypeLegend,Calculation Mode.Price, Position.AvgPrice + 1 * TickSize ,true );
                              //stopOrder = ExitLongStop(myTimeframe, true, stopOrder.Quantity, Position.AvgPrice+1*TickSize, "StopEnBE", "Long:"+myPeriodTypeLegend);
                              //PrintWithTimeStamp("stopOrder : "+stopOrder);
                              }
                              }

                              Comment


                                #30
                                rperez, you're welcome - yes it does, using this part instead of the mixup with Exit() and Set() provides 'clean' handling of your stops and targets as far as the Internal Order Handling Rules are concerned.
                                BertrandNinjaTrader Customer Service

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by jclose, Today, 09:37 PM
                                0 responses
                                6 views
                                0 likes
                                Last Post jclose
                                by jclose
                                 
                                Started by WeyldFalcon, 08-07-2020, 06:13 AM
                                10 responses
                                1,414 views
                                0 likes
                                Last Post Traderontheroad  
                                Started by firefoxforum12, Today, 08:53 PM
                                0 responses
                                11 views
                                0 likes
                                Last Post firefoxforum12  
                                Started by stafe, Today, 08:34 PM
                                0 responses
                                11 views
                                0 likes
                                Last Post stafe
                                by stafe
                                 
                                Started by sastrades, 01-31-2024, 10:19 PM
                                11 responses
                                169 views
                                0 likes
                                Last Post NinjaTrader_Manfred  
                                Working...
                                X