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

SetStopLoss() in multi timeframes

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

    SetStopLoss() in multi timeframes

    Hi,

    I'm asking myself if using the SetStopLoss(..) method is working, when using multi timeframes during backtesting my strategies.

    First of all I had only a M10 and using CalculateOnBarClose = True. Then after placing an order a stoploss was set and during backtesting tested after every M10-Bar, thats ok ...

    Now, I want to test the stop after every minute, so I add a M1 timeframe to the strategy. I'm entering the trade in M10 and then the stoploss is set. After that ten M1-bars running with the close-price through the strategy. Does NT test the stoploss for every M1-bar or only for the higher M10 timeframe?

    Thx,
    DT

    #2
    Hello,

    Where is your SetStoploss located in your code?
    It will work for the timeframe you have submitted it. If you did not specify, then it will be on the 0 bar in progress. This link may help:
    DenNinjaTrader Customer Service

    Comment


      #3
      It is located in the Initialize-Method. So, if I understand you right, I need to move it to the

      Code:
      if (BarsInProgress == 1) {
         ...
         SetStopLoss (this.Name, CalculationMode.Ticks, stopLossTicks, false);
         ...
      }
      part of the code, if I want submit it to the M1 Timeframe when using normally a M8 Timeframe as primary Series?

      The stoploss in initialize (actual code) is only checked in M8 on every close of the primary bar?

      DT
      Last edited by DarthTraderson; 11-02-2009, 01:01 AM.

      Comment


        #4
        Correct DT, you would need to move the code to the relevant sections in the OnBarUpdate, or work with the Exit() methods that offer a BIP paramter directly - http://www.ninjatrader-support.com/H...tLongStop.html
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Ok, thanks for the response ... I have to test it ...

          In my yesterday evaluations I had a M8 as primary and M1 as secondary timeframe. I still set SetStopLoss(..) in the initialize-method() and the trades where entered and exit in secondary timeframe.

          Entered with EnterLongLimit(1, ....) and exit worked, I thought, wit setStopLoss ... because I see the trade enter and exit time in the trade overview panel .... very strange ... that doesn't fit with you explanations ....

          DT

          Comment


            #6
            DT, are you linking entries and exits together with signal naming?
            BertrandNinjaTrader Customer Service

            Comment


              #7
              Yes I do.

              In Initialize-Method ...
              Code:
              SetStopLoss("MyEntry", CalcutationMode.Ticks, stopLossTicks, false);
              In OnBarUpdate-Method ....
              Code:
              EntryLongLimit (1, false, quantity, Lows[0][0], "MyEntry");
              Is it relevant?

              DT
              Last edited by DarthTraderson; 11-02-2009, 07:12 AM.

              Comment


                #8
                Yes, this would 'link' them together, so you stop loss is submitted as soon as the BIP 1 entry fills.
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  Sorry, Betrand ... what is the meaning of BIP ...

                  So, to sum it up ... my code works as expected and I did not need to move the SetStopLoss() - statement?

                  DT

                  Comment


                    #10
                    I'm sorry DT, BIP = Bars In Progess, you should be good with this code for intrabar backtesting as you already submit entries and by entry signal naming linked exits on a finer granularity than you primary chart.
                    BertrandNinjaTrader Customer Service

                    Comment


                      #11
                      Can anyone confirm if this can be done or not???

                      Because of the NT backtest deficiency, we have to go the extra miles to add 1min timeframe for order execution. Now you're telling me, oh by the way, set stoploss does not work and I will have to write my own stoploss code?

                      And this is claimed to be the best auto-trading platform??


                      I asked this to support:
                      >>>
                      If I have two timeframes, say 10m is primary and 2min is added.

                      If I do EntryLongLimit (1, false, quantity, Lows[0][0], "MyEntry"); in BIP ==0,
                      can do SetStopLoss(price) at the 2min (BIP is 1) to make it effective?

                      During backtest, the stop will be eval every 2min's cycle, or every 10min bar?

                      Also, how can I tell if the order is stop-out?

                      Thanks.
                      >>>

                      i got answer like
                      >>>

                      Hello,

                      Thanks for writing in.



                      The SetStopLoss function will only set the stop for the primary data series. For other data series you will want to place a ExitLong/ExitShort order at the proper prices.

                      Below is a link to the help guide on the usage of SetStopLoss.

                      >>>

                      Comment


                        #12
                        balancenv, your understanding is unfortunately correct - the Set's would be evaluated on the primary series only. As they also do not expose IOrder access, checking for their states would need to be done via the approach offered in this sample - http://www.ninjatrader.com/support/f...ead.php?t=5790

                        We're are also looking into enhancing this area and backtest handling for our next major platform update.
                        BertrandNinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by thread, Yesterday, 11:58 PM
                        1 response
                        8 views
                        0 likes
                        Last Post NinjaTrader_ChelseaB  
                        Started by stafe, Yesterday, 08:34 PM
                        1 response
                        16 views
                        0 likes
                        Last Post NinjaTrader_ChelseaB  
                        Started by jclose, Yesterday, 09:37 PM
                        1 response
                        11 views
                        0 likes
                        Last Post NinjaTrader_Gaby  
                        Started by firefoxforum12, Yesterday, 08:53 PM
                        1 response
                        15 views
                        0 likes
                        Last Post NinjaTrader_BrandonH  
                        Started by kmunroe478, Yesterday, 05:39 PM
                        2 responses
                        15 views
                        0 likes
                        Last Post NinjaTrader_Jesse  
                        Working...
                        X