Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Stop Not Working

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

    Stop Not Working

    I am trying to implement a dynamic stop system but it doesn't ever place the stop. Here is the code I am using:

    Code:
    			if (Position.MarketPosition == MarketPosition.Long
    				&& Close[0] < Open[0] && Close[1] < Open[1]) //&& (Close[0] < Low[1] || Close[0] <= Low[0]))
    				{
    				ExitLongStop(Low[1] + -2 * TickSize, "", "");
    				}
    				
    			if (Position.MarketPosition == MarketPosition.Short
    				&& Close[0] > Open[0] && Close[1] > Open[1])//&& (Close[0] > High[1] || Close[0] >= High[0]))
    				{
    				ExitShortStop(High[1] + 2 * TickSize, "", "");	
    				}
    This strategy compiles just fine and there is no other stop order or stop management command in the strategy. This is it. Also there are no error statements in the log regarding placing a stop. Is there something wrong with this stop order? I tried tying it to a named entry, and not tying it to a named entry, in either case it doesn't work.
    Thanks
    DaveN
    Last edited by daven; 07-16-2013, 01:00 PM. Reason: correct grammar

    #2
    Hello daven,

    Thanks for your note.

    I have created a simple script to test your code.

    I have run this on an ES 09-13 1 Min chart. I am seeing the stops placed causing the order to exit.

    Please import my file and let me know of anything you would like me to change and test.
    Attached Files
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thanks Chelsea, I see now that I had my stop order improperly constructed. I will correct the syntax and try it in my strategy. Your sample code really helped.
      DaveN

      Comment


        #4
        Stop doesn't work on other bars

        Chelsea,
        I've been working with the test script you supplied and stops are working fine once I figured out what was going on. I have two questions. In the format you supplied, the stops execute, but never show up on the DOM as a resident stop. That seems weird, but perhaps there is a logical explanation for that. The other question I have is the stops don't work at all on Better Renko or Hybrid Renko bars. Why is that?
        Accepting that is true, can I implement stops by adding a minute or shorter time duration bar, and execute the stop on that bar, instead of the hybrid renko bar? Is it possible to enter a trade based on the hybrid renko data, but exit the trade based on the 2nd minute data?
        Thanks
        DaveN

        Comment


          #5
          Hello Dave,

          I can confirm that the sample I provided using your stop logic does work on 4 Renko bars. I am unsure of why it would not work on Better Renko or Hybrid Renko. It may be that the conditions are not being met or that they are and the stops are not being hit.

          May I have the output of your Output window?
          • Right-click Output window -> select Save As... -> select a location you will find -> click Save
          • Attach this output
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            Will the output from a small period backtest be okay?

            Comment


              #7
              Perhaps that won't work. If I run a back test, the Output box show's a lot of activity, but when the backtest completes, the output box clears. Is there a way to preserve the backtest output file?

              Comment


                #8
                Hello Dave,

                I have been testing using the Market Replay.

                I think you may have better luck with this.

                YouTube Video - http://www.youtube.com/watch?v=cgB1y...D7105&index=10

                Help Guide - http://www.ninjatrader.com/support/h...ket_replay.htm
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Stop Not Working - continued

                  Your are right, works on Renko bars or minute bars, not on Hybrid Renkos or Better Renkos.
                  I'm attaching an output file on your test script, running on 10 sec bars so I would get some activity easily. I the strategy on the chart , and attaching it here. I then cleared the output file, changed the data to HybridRenko 2 brick setting, re-enabled the strategy, and captured that output it is the second output file, labeled ....HybridRenko.
                  Thanks
                  DaveN

                  Also, could you comment on my question about the work-around for hybrid renko charts, detect the trade conditions on the Hybrid Renko bars, but actually implement it on minute or second bars as a second data set on the chart?

                  Had to limit the attachment to one file, because it exceeds your Mb file size limit.
                  I'll attach the second file in a second post.

                  output File_Chelsea.txt

                  Comment


                    #10
                    I can't even attach the second file, it is 2.67 Mb, which exceeds your 1 Mb limit. Is there another way to send you the file?
                    Thanks
                    DaveN

                    Comment


                      #11
                      Hello Dave,

                      It is possible to enter on one time frame and exit on another.

                      To do this, you will need to have a multi-time frame script. Then use the BarsInProgress in the call for the exit order.

                      For example on a script with a secondary time frame:

                      if (BarsInProgress == 0 && Position.MarketPosition == MarketPosition.Long)
                      {
                      ExitLongStop(1, true, 1, Low[1]-2*TickSize, "", "");
                      }

                      ExitLongStop(int barsInProgressIndex, bool liveUntilCancelled, int quantity, double stopPrice, string signalName, string fromEntrySignal)
                      http://www.ninjatrader.com/support/h...itlongstop.htm
                      Chelsea B.NinjaTrader Customer Service

                      Comment


                        #12
                        Hello Dave,

                        The issue looks like the stops are not being accepted and being cancelled a bar later.

                        Try using the liveUntilCancelled true in the call for the exit order as in the example of my last post.
                        Chelsea B.NinjaTrader Customer Service

                        Comment


                          #13
                          Just wanted to provide some feedback for all your help. I implemented the new stop system you recommended, and it has dramatically improved the performance of my trading system. Perhaps more importantly, I can now see the profit target and the stop on the DOM, when the system is running so if I need to make adjustments because of what the market is doing, I can.
                          Thank you Chelsea for all your assistance.
                          DaveN

                          Comment


                            #14
                            Hi Dave,

                            Thanks for letting me know you've got everything working great.

                            Let me know if I can be of any further assistance for you.
                            Chelsea B.NinjaTrader Customer Service

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by AttiM, 02-14-2024, 05:20 PM
                            12 responses
                            213 views
                            0 likes
                            Last Post DrakeiJosh  
                            Started by cre8able, 02-11-2023, 05:43 PM
                            3 responses
                            237 views
                            0 likes
                            Last Post rhubear
                            by rhubear
                             
                            Started by frslvr, 04-11-2024, 07:26 AM
                            8 responses
                            116 views
                            1 like
                            Last Post NinjaTrader_BrandonH  
                            Started by stafe, 04-15-2024, 08:34 PM
                            10 responses
                            47 views
                            0 likes
                            Last Post stafe
                            by stafe
                             
                            Started by rocketman7, Today, 09:41 AM
                            3 responses
                            12 views
                            0 likes
                            Last Post NinjaTrader_Jesse  
                            Working...
                            X