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

Fixed stop loss

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

    Fixed stop loss

    Hello ,
    I have a fixed 6 tick stop. Still, he doesn't close the market after 6 ticks, why? (Backtest) I didn't have the problem with other strategies. Tried a lot of settings, but couldn't solve the problem Thanks!

    #2
    Hi Burak, thanks for your note.

    Is the stop never created or is it passed up by the price? Are there any errors in the Log tab of your Control Center about the strategy?

    I look forward to hearing from you.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Hello , I don't get an error message. The stop price is exceeded , it passed up by the price.

      Comment


        #4
        Hi Burak,

        If the Stop variable is set to 6, I would expect the order to be submitted.

        Please enable TraceOrders and re-run the backtest.


        Then, please include the output from the output window with your reply.

        At what time is the entry placed that is not being exited by the stop loss?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hello, here is the text / output (But unfortunately
          in German) :

          29.11.2019 18:40:00 Strategie 'MyFXdreamPserie/-1': Ausstehender Austiegsauftrag gelöscht, da die zugeordnete Position geschlossen wurde, orderId='NT-00107-2311' account='Backtest' name='Profit target' orderState=Working instrument='CL 04-20' orderAction=BuyToCover orderType='Limit' limitPrice=55.41 stopPrice=0 quantity=1 tif=Gtc oco='NT-00070-2311' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2019-11-29 18:06:00' gtd='2099-12-01' statementDate='2020-02-18'
          29.11.2019 18:40:00 Strategie 'MyFXdreamPserie/-1': OCO gepaarter Auftrag gelöscht: BarsInProgress=0, orderId='NT-00107-2311' account='Backtest' name='Profit target' orderState=Cancelled instrument='CL 04-20' orderAction=BuyToCover orderType='Limit' limitPrice=55.41 stopPrice=0 quantity=1 tif=Gtc oco='NT-00070-2311' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2019-11-29 18:06:00' gtd='2099-12-01' statementDate='2020-02-18'
          29.11.2019 18:49:00 Strategy 'MyFXdreamPserie/-1': Interne SubmitOrderManaged() Methode eingegeben bei 29.11.2019 18:49:00: BarsInProgress=0 Aktion=SellShort OrderTyp=Market Anzahl=1 LimitPreis=0 StopPreis=0 SignalName='' FromEntrySignal=''
          29.11.2019 19:00:00 Strategie 'MyFXdreamPserie/-1': Ausstehender Austiegsauftrag gelöscht, da die zugeordnete Position geschlossen wurde, orderId='NT-00119-2311' account='Backtest' name='Profit target' orderState=Working instrument='CL 04-20' orderAction=BuyToCover orderType='Limit' limitPrice=55.4 stopPrice=0 quantity=1 tif=Gtc oco='NT-00078-2311' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2019-11-29 18:49:00' gtd='2099-12-01' statementDate='2020-02-18'
          29.11.2019 19:00:00 Strategie 'MyFXdreamPserie/-1': OCO gepaarter Auftrag gelöscht: BarsInProgress=0, orderId='NT-00119-2311' account='Backtest' name='Profit target' orderState=Cancelled instrument='CL 04-20' orderAction=BuyToCover orderType='Limit' limitPrice=55.4 stopPrice=0 quantity=1 tif=Gtc oco='NT-00078-2311' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2019-11-29 18:49:00' gtd='2099-12-01' statementDate='2020-02-18'
          29.11.2019 19:03:00 Strategy 'MyFXdreamPserie/-1': Interne SubmitOrderManaged() Methode eingegeben bei 29.11.2019 19:03:00: BarsInProgress=0 Aktion=SellShort OrderTyp=Market Anzahl=1 LimitPreis=0 StopPreis=0 SignalName='' FromEntrySignal=''
          29.11.2019 19:18:00 Strategy 'MyFXdreamPserie/-1': Interne SubmitOrderManaged() Methode eingegeben bei 29.11.2019 19:18:00: BarsInProgress=0 Aktion=SellShort OrderTyp=Market Anzahl=1 LimitPreis=0 StopPreis=0 SignalName='' FromEntrySignal=''
          29.11.2019 19:20:00 Strategie 'MyFXdreamPserie/-1': Ausstehender Austiegsauftrag gelöscht, da die zugeordnete Position geschlossen wurde, orderId='NT-00121-2311' account='Backtest' name='Stop loss' orderState=Working instrument='CL 04-20' orderAction=BuyToCover orderType='Stop Markt' limitPrice=0 stopPrice=55.8 quantity=1 tif=Gtc oco='NT-00080-2311' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2019-11-29 19:03:00' gtd='2099-12-01' statementDate='2020-02-18'
          29.11.2019 19:20:00 Strategie 'MyFXdreamPserie/-1': OCO gepaarter Auftrag gelöscht: BarsInProgress=0, orderId='NT-00121-2311' account='Backtest' name='Stop loss' orderState=Cancelled instrument='CL 04-20' orderAction=BuyToCover orderType='Stop Markt' limitPrice=0 stopPrice=55.8 quantity=1 tif=Gtc oco='NT-00080-2311' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2019-11-29 19:03:00' gtd='2099-12-01' statementDate='2020-02-18'
          29.11.2019 19:28:00 Strategy 'MyFXdreamPserie/-1': Interne SubmitOrderManaged() Methode eingegeben bei 29.11.2019 19:28:00: BarsInProgress=0 Aktion=SellShort OrderTyp=Market Anzahl=1 LimitPreis=0 StopPreis=0 SignalName='' FromEntrySignal=''
          29.11.2019 19:29:00 Strategie 'MyFXdreamPserie/-1': Ausstehender Austiegsauftrag gelöscht, da die zugeordnete Position geschlossen wurde, orderId='NT-00128-2311' account='Backtest' name='Profit target' orderState=Working instrument='CL 04-20' orderAction=BuyToCover orderType='Limit' limitPrice=54.94 stopPrice=0 quantity=1 tif=Gtc oco='NT-00083-2311' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2019-11-29 19:28:00' gtd='2099-12-01' statementDate='2020-02-18'
          29.11.2019 19:29:00 Strategie 'MyFXdreamPserie/-1': OCO gepaarter Auftrag gelöscht: BarsInProgress=0, orderId='NT-00128-2311' account='Backtest' name='Profit target' orderState=Cancelled instrument='CL 04-20' orderAction=BuyToCover orderType='Limit' limitPrice=54.94 stopPrice=0 quantity=1 tif=Gtc oco='NT-00083-2311' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2019-11-29 19:28:00' gtd='2099-12-01' statementDate='2020-02-18'
          29.11.2019 19:32:00 Strategie 'MyFXdreamPserie/-1': Ausstehender Austiegsauftrag gelöscht, da die zugeordnete Position geschlossen wurde, orderId='NT-00125-2311' account='Backtest' name='Profit target' orderState=Working instrument='CL 04-20' orderAction=BuyToCover orderType='Limit' limitPrice=55.19 stopPrice=0 quantity=1 tif=Gtc oco='NT-00081-2311' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2019-11-29 19:18:00' gtd='2099-12-01' statementDate='2020-02-18'
          29.11.2019 19:32:00 Strategie 'MyFXdreamPserie/-1': OCO gepaarter Auftrag gelöscht: BarsInProgress=0, orderId='NT-00125-2311' account='Backtest' name='Profit target' orderState=Cancelled instrument='CL 04-20' orderAction=BuyToCover orderType='Limit' limitPrice=55.19 stopPrice=0 quantity=1 tif=Gtc oco='NT-00081-2311' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2019-11-29 19:18:00' gtd='2099-12-01' statementDate='2020-02-18'
          29.11.2019 19:39:00 Strategy 'MyFXdreamPserie/-1': Interne SubmitOrderManaged() Methode eingegeben bei 29.11.2019 19:39:00: BarsInProgress=0 Aktion=SellShort OrderTyp=Market Anzahl=1 LimitPreis=0 StopPreis=0 SignalName='' FromEntrySignal=''
          29.11.2019 19:41:00 Strategie 'MyFXdreamPserie/-1': Ausstehender Austiegsauftrag gelöscht, da die zugeordnete Position geschlossen wurde, orderId='NT-00131-2311' account='Backtest' name='Profit target' orderState=Working instrument='CL 04-20' orderAction=BuyToCover orderType='Limit' limitPrice=55.28 stopPrice=0 quantity=1 tif=Gtc oco='NT-00086-2311' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2019-11-29 19:39:00' gtd='2099-12-01' statementDate='2020-02-18'
          29.11.2019 19:41:00 Strategie 'MyFXdreamPserie/-1': OCO gepaarter Auftrag gelöscht: BarsInProgress=0, orderId='NT-00131-2311' account='Backtest' name='Profit target' orderState=Cancelled instrument='CL 04-20' orderAction=BuyToCover orderType='Limit' limitPrice=55.28 stopPrice=0 quantity=1 tif=Gtc oco='NT-00086-2311' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2019-11-29 19:39:00' gtd='2099-12-01' statementDate='2020-02-18'

          Comment


            #6
            Hi Burak,

            As a tip, you can save the output from the output window to a text file by right-clicking the NinjaScript Output window > select Save As > give the file a name > click Save.
            Then you can attach the text file with your post.

            Below is a link to a forum post that demonstrates using prints to understand behavior that discusses this.


            I am only seeing one stop loss that was placed but then was cancelled.

            29.11.2019 19:20:00 Strategie 'MyFXdreamPserie/-1': Ausstehender Austiegsauftrag gelöscht, da die zugeordnete Position geschlossen wurde, orderId='NT-00121-2311' account='Backtest' name='Stop loss' orderState=Working instrument='CL 04-20' orderAction=BuyToCover orderType='Stop Markt' limitPrice=0 stopPrice=55.8 quantity=1 tif=Gtc oco='NT-00080-2311' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2019-11-29 19:03:00' gtd='2099-12-01' statementDate='2020-02-18'

            29.11.2019 19:20:00 Strategie 'MyFXdreamPserie/-1': OCO gepaarter Auftrag gelöscht: BarsInProgress=0, orderId='NT-00121-2311' account='Backtest' name='Stop loss' orderState=Cancelled instrument='CL 04-20' orderAction=BuyToCover orderType='Stop Markt' limitPrice=0 stopPrice=55.8 quantity=1


            The text provided starts with a profit target that is cancelled but there is no stop loss.

            29.11.2019 18:40:00 Strategie 'MyFXdreamPserie/-1': Ausstehender Austiegsauftrag gelöscht, da die zugeordnete Position geschlossen wurde, orderId='NT-00107-2311' account='Backtest' name='Profit target' orderState=Working instrument='CL 04-20' orderAction=BuyToCover orderType='Limit' limitPrice=55.41 stopPrice=0 quantity=1 tif=Gtc oco='NT-00070-2311' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2019-11-29 18:06:00' gtd='2099-12-01' statementDate='2020-02-18'

            29.11.2019 18:40:00 Strategie 'MyFXdreamPserie/-1': OCO gepaarter Auftrag gelöscht: BarsInProgress=0, orderId='NT-00107-2311' account='Backtest' name='Profit target' orderState=Cancelled instrument='CL 04-20' orderAction=BuyToCover orderType='Limit' limitPrice=55.41 stopPrice=0 quantity=1

            This profit target should not be possible as there is no entry order being submitted before it..

            Are you seeing the first filled order is a profit target and not an entry order?

            Is 18:40 when the price traveled through the stop?

            If so, it looks like the issue was that there was no entry entry submitted, but somehow a profit target was submitted, but a stop loss was never submitted.

            If this is correct, I would like to test the script on my end to find why profit target was submitted without an entry and why no stop loss was submitted.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Hello, thanks for your reply.

              Here again the (full) output as a file:
              And also the strategy
              Attached Files

              Comment


                #8
                Hello Burak,

                The first stop loss cancelled is at 17:30 on November 27th.

                27.11.2019 17:30:00 Strategie 'MyFXdreamPserie/-1': OCO gepaarter Auftrag gelöscht: BarsInProgress=0, orderId='NT-00010-76' account='Backtest' name='Stop loss' orderState=Cancelled instrument='CL 04-20' orderAction=BuyToCover orderType='Stop Markt' limitPrice=0 stopPrice=58.27 quantity=1 tif=Gtc oco='NT-00006-76' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2019-11-27 17:05:00' gtd='2099-12-01' statementDate='2020-02-18'

                Is your inquiry about why this order was cancelled?

                I am not able to import the file you have provided.
                Is this exported from Tools > Export > NinjaScript Addon?

                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Hello ,

                  I exported the file again as you explained above.

                  The stop in back testing (TickReplay) is greater than selected. In the same way, the profits were not right.
                  I use a fixed stop and profit target

                  Attached Files

                  Comment


                    #10
                    Hello Burak,

                    When you mention:

                    "The stop in back testing (TickReplay) is greater than selected.", are you asking about why a stop loss filled at a specific price?

                    Which order is the order in question?
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      Hello ,

                      I uploaded a picture again so that they can understand the problem better.
                      You can see that the stop of 9 points is not met.
                      The profit target is also greater than 30 points.
                      Attached Files

                      Comment


                        #12
                        Hello Burak,

                        Ok, you would like to know why a stop order has filled at a specific price.

                        It may be that the next value price to fill the order is further past the stop price of the order.

                        What is the submission price of this order?
                        What is the open, high, low, and close of the fill bar?

                        Are the orders submitted to a 1 tick added series for intra-bar granularity for order fill accuracy?
                        Chelsea B.NinjaTrader Customer Service

                        Comment


                          #13
                          Hello ,

                          I added the additional 1 tick series because of the BlockVolume indicator.

                          If I run the backtest without TickReplay, the results are suddenly correct again.
                          Shouldn't it be more accurate/exact with TickRepaly?

                          Best Regards

                          Comment


                            #14
                            Hello Burak,

                            From the help guide:
                            "Tick Replay is not intended to function in NinjaScript strategy backtests, and will not provide the same results as running a strategy on live data with Tick Replay enabled. For greater order-fill resolution in strategy backtests, you can use the High Fill Resolution in the Strategy Analyzer."


                            I've also mentioned this in the forum post I have linked you about intra-bar granularity.

                            No, it should not be more accurate with only TickReplay.
                            Chelsea B.NinjaTrader Customer Service

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by sidlercom80, 10-28-2023, 08:49 AM
                            168 responses
                            2,261 views
                            0 likes
                            Last Post sidlercom80  
                            Started by Barry Milan, Yesterday, 10:35 PM
                            3 responses
                            10 views
                            0 likes
                            Last Post NinjaTrader_Manfred  
                            Started by WeyldFalcon, 12-10-2020, 06:48 PM
                            14 responses
                            1,428 views
                            0 likes
                            Last Post Handclap0241  
                            Started by DJ888, 04-16-2024, 06:09 PM
                            2 responses
                            9 views
                            0 likes
                            Last Post DJ888
                            by DJ888
                             
                            Started by jeronymite, 04-12-2024, 04:26 PM
                            3 responses
                            41 views
                            0 likes
                            Last Post jeronymite  
                            Working...
                            X