Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Time filter: entry works can't get exit to work.

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

    Time filter: entry works can't get exit to work.

    It makes more sense to place the exit time filter in a different set, like one of the exit sets. But in Chelseas video he's demonstrating it as a stand-alone, no other conditions. Whereas a real situation would have other sets and how to apply with other sets instead of all by itself.

    The entry works great but exit I need to tell it to stop, not to start. I want to have this in there before I copy & unlock it so I can add a reversal to the trailing condition.
    Unless I can't in the builder and need to add that in an unlocked script? But rather do it in builder if I can.

    Thank you, everyone. B
    Attached Files

    #2
    Hello trdninstyle,

    The image you provided is for the entry set which wont help to let us know about the exit. What problem are you having with the set that contains the exit?


    Comment


      #3
      It wasn't exiting. Sense then I removed them but just put them back on but not getting the enter to enter at a specific time in the am. 9am for now.

      Would it be easier in the unlocked script to do this?

      Comment


        #4
        Hello trdninstyle,

        If it was not exiting we would need more details on what your scripts conditions in the sets that control the exit are.

        If the changes you made are now preventing it from also entering you will need to review the entry conditions that you made. The time condition is checking for a window of time between 9am and 4 AM. That is not a valid time span because it crosses midnight . The time will never be both greater than 9am and less than 4am within 24 hours.

        It won't be any easier manually coding unless you know how to manually code the script, if you don't have experience in coding manually I would suggest to continue to work out the problem using the builder.

        Comment


          #5
          Here's a look at the script and two views of the same builder, one in set 2 and set 4, the exit condition. Should it be working the way I have it?

          I made a slew of indicators in the past manually coding them, I'm not an expert but I get it enough to be dangerous.
          Attached Files

          Comment


            #6
            Hello trdninstyle

            There are a few issues from what I can see in the image.

            Set 3 you have close equals current trigger price. In NinjaScript/C# checking if two double numbers are equal can fail, you should use Greater equals instead of just equals so that set works correctly.

            Set 5 is not clear what you are doing. The variable "StopPrice" is not used in any of the other sets, what is "StopPrice"? If you are trying to modify the stops price you need to make sure that the exit order is in the very last set. You also need to set CurrentStopPrice to change that stop.

            Comment


              #7
              Set 5 is for ensuring that my stop stays below the bid, sometimes I would get an issue with that. Here's a screenshot (2nd pic) of what I was running into bout a week ago.

              I made that adjustment now. Do u see any other issues?
              Attached Files

              Comment


                #8
                Hello trdninstyle

                The set 5 you made does not currently do anything. StopPrice is not used anywhere else in any of the other sets. That also comes after the important set which is set 4, the conditions/actions in set 4 should always be the last set so any price changes are observed. If you wanted to change the stops price you need to set the CurrentStopPrice variable.

                The error you are getting relates to the trail distance you used and the Calculate setting being used. If you are using OnBarClose the trailing is modified for each bar close. That can lead to incorrect pricing if you have a large price movement between bars when the target is modified. The price that was calculated based on the bar closed price was on the opposite side of the market so it was rejected.

                Comment


                  #9
                  'The price that was calculated based on the bar closed price was on the opposite side of the market so it was rejected'

                  Thats why then, I just changed it to on each tick. Before on each tick it would get me long again as soon as the trade would close & by changing it to the close, it fixed that.
                  I was getting into trades I didn't want.

                  Chelsea had me do that set 5. (Had it in wrong spot)

                  Here's a link to those post, around a week ago.

                  Cannot do a sell stop or a sell stop limit order notice - NinjaTrader Support Forum

                  Set 4 has to be the last one regardless of anything else, okay I understand.
                  Attached Files
                  Last edited by trdninstyle; 12-01-2022, 02:17 PM.

                  Comment


                    #10
                    Hello trdninstyle

                    StopPrice is not used in what you have pictured, its just a user variable but won't control anything. The stop order is using the variable named CurrentStopPrice. In that other thread you linked to that strategy has a variable named StopPrice, that is different from what you pictured in this thread, this strategy is using a variable named CurrentStopPrice.

                    Comment


                      #11
                      I moved set 5 in front of set 4 so it will be included. But isn't this doing as Chelse suggested it will do?
                      That is to keep the Bid from getting under the stop.


                      Click image for larger version

Name:	2022-12-01 18_13_12-2022_12_01_18_03_42_Chart_MES_12_22 - Paint.png
Views:	214
Size:	111.8 KB
ID:	1225890


                      This pic below w/ the arrow was just me saying, is this where u mean?


                      Attached Files

                      Comment


                        #12
                        Hello trdninstyle,

                        You are using the incorrect variable.

                        In post 7 where you show the code of the script the stop it has uses a variable named "CurrentStopPrice" for the stop order price.

                        Adding a variable named "StopPrice" and setting it will not change how the script works, you aren't using the right variable. The stop is expecting that CurrentStopPrice has a price set to it so that is used for the stop. If you wanted to change the stop you would add another set and set CurrentStopPrice, not "StopPrice". StopPrice is not used in your code besides where you set it so its not doing anything.

                        To continue please remove the set that you made with StopPrice, then remove the variable StopPrice from the variables page so that it won't confuse you. If you wanted to change the stop price you could then add a new set and set CurrentStopPrice to a different price.

                        The set which has ExitLongStopMarket needs to be the last set so any price changes you make to the variable CurrentStopPrice can be used with the order.

                        Comment


                          #13
                          Took me a little bit to get back.

                          After yesterday I understood about keeping set 4 always at the end, so whatever gets added stays included.

                          The idea behind that "StopPrice" was to stay beneath the bid so I wouldn't get that message. But u was saying, because I was using 'Close' it sometimes caused the bid to get behind the stop. Giving me that message. Then with 'on each tick' that most likely shouldn't happen?

                          If I wanted to ensure the bid stays above my stop, what would I add? Like what Chelsea showed me.

                          ps. The start time is working, starting at 9am. It's the stop time that I can't get to work.

                          I added IsRising to my script to filter out some losses. I was going to start a new post for the IsFalling for the short side. Have the long side working but not the short side. I'll do a new post for that.
                          Attached Files
                          Last edited by trdninstyle; 12-02-2022, 11:43 AM.

                          Comment


                            #14
                            Hello trdninstyle,

                            After yesterday I understood about keeping set 4 always at the end, so whatever gets added stays included.

                            The last set needs to be the exit order because the exit order is being resubmitted on each bar. If you make a price change that needs to happen in a set before the exit order's set.


                            The idea behind that "StopPrice" was to stay beneath the bid so I wouldn't get that message.
                            You can do that but you need to use the right variable. The link you had posted to the other forum post is a different strategy that has different variables. You can use that information from that post but you need to make sure you are accurately taking away the information being displayed. It shows how to use a variable in general, the name of that variable was StopPrice. In this post and with the strategy you posted in post 7 that doesn't use a variable named StopPrice so you have to make sure you are changing the variable names as needed to match your script. To change the stop price for the stop in the strategy from post 7 you use the variable CurrentStopPrice because that is what this strategy has as its stop price variable.

                            But u was saying, because I was using 'Close' it sometimes caused the bid to get behind the stop. Giving me that message. Then with 'on each tick' that most likely shouldn't happen?
                            I mentioned that the price that is used at the time of the bar close was not valid for the type of order. It was on the wrong side of the market. Using OnEachTick you may see that less frequently because the bar update events happen more frequently so the price used is more accurate to the current market. As an example if you use OnBarClose calculate mode and a 10 minute bar the prices used are going to be delayed by 10 minutes. Using a very close offset would mean that the order is likely going to be placed on the wrong side of the market.




                            If I wanted to ensure the bid stays above my stop, what would I add? Like what Chelsea showed me.

                            ps. The start time is working, starting at 9am. It's the stop time that I can't get to work.

                            I added IsRising to my script to filter out some losses. I was going to start a new post for the IsFalling for the short side. Have the long side working but not the short side. I'll do a new post for that.
                            I would suggest to look at the script you have as it is now before making changes base on other posts. The information from the other post can be used but you need to change the variable name being used. Your script uses the name CurrentStopPrice to control its stop order. If you plan to make any changes based on other information keep in mind that to change your stop you need to use CurrentStopPrice .

                            Comment


                              #15
                              Okay, I'm definitely following you on all of those points now, and some of it was edifying for me. I'm tracking things a lot better than I did a month ago.

                              I have to keep everything in context to the script at hand, not mix & match info from other post for those scripts because it won't fit.

                              That was awesome thank you.

                              ps. I went away from time charts because of the close of bars, now using a UniRenko and I could get that range tighter to the #'s I'm using and works good. When the #'s is proportionally off from the range of the candles it gives me that awkward reading then I adjust it then gives me a good result.

                              Not necessary a good strategy but a good result. Another words it works proper so I can determine the strategy.

                              ******
                              One other thing I'm figuring out, by having it OnBarClose it doesn't get me into unwanted trades as soon as a current trade ends.
                              And, instead of saying Close[0] > Open[0] if I say Close[0] CrossesAbove Open[0] it does it only once & not continually, I think even when it's on each tick, don't remember for sure but I think it does it only once & not continually when it's on the tick.

                              Instead of greater sometimes use crossabove. Depending.
                              Last edited by trdninstyle; 12-03-2022, 11:31 AM.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by NullPointStrategies, Today, 05:17 AM
                              0 responses
                              50 views
                              0 likes
                              Last Post NullPointStrategies  
                              Started by argusthome, 03-08-2026, 10:06 AM
                              0 responses
                              126 views
                              0 likes
                              Last Post argusthome  
                              Started by NabilKhattabi, 03-06-2026, 11:18 AM
                              0 responses
                              69 views
                              0 likes
                              Last Post NabilKhattabi  
                              Started by Deep42, 03-06-2026, 12:28 AM
                              0 responses
                              42 views
                              0 likes
                              Last Post Deep42
                              by Deep42
                               
                              Started by TheRealMorford, 03-05-2026, 06:15 PM
                              0 responses
                              46 views
                              0 likes
                              Last Post TheRealMorford  
                              Working...
                              X