Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Repeating EnterLongLimit in Realtime

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

    #31
    what time should I set my PC to?

    I've changed the time interval to 1 minute ... using the exact code I posted this is what I get:

    Click image for larger version

Name:	chart10.png
Views:	90
Size:	19.1 KB
ID:	1221052

    Comment


      #32
      sell signal has now disappeared but the line continues to follow the bars:

      Click image for larger version

Name:	chart11.png
Views:	88
Size:	4.5 KB
ID:	1221056

      do you think my NT8 installation is corrupted?

      Comment


        #33
        not sure why but the sell signal has reappeared and stopped moving to the right?

        Click image for larger version

Name:	chart12.png
Views:	92
Size:	5.8 KB
ID:	1221058

        Comment


          #34

          Hello dibDab,

          Your PC clock should be set to the current time by syncing it using windows.

          Again the logic you provided should not be happening in the same bar, the BarsSinceEntryExecution only reports a positive value when bars elapse after an entry is filled. The screenshot you had shown is showing a sell order exiting the long position so there is still some issue with your logic.

          If you have other conditions for sell orders or short orders please remove those for the time being.


          Comment


            #35
            the code I sent is all there is. I created this simple strategy to test the issue. What can I do?

            Comment


              #36
              Hello dibDab,

              I would suggest to try and use a Print and make sure the exit condition is happening when expected. I see this type of logic working fine on my end when using a 5 second chart, it waits 5 bars and then exits.

              Code:
              if(State == State.Realtime && Position.MarketPosition == MarketPosition.Flat)
              {
                  EnterLongLimit(Close[0], "MyEntry");
              }
              if(BarsSinceEntryExecution("MyEntry") >= 5)
              {
                  ExitLong("MyEntry");
              }

              Comment


                #37
                ok thanks will do

                Comment


                  #38
                  getting same problem using your code.

                  Click image for larger version

Name:	chart20.png
Views:	92
Size:	5.5 KB
ID:	1221080

                  tomorrow I'll try and debug using print and reinstall NT8

                  Comment


                    #39
                    Hello dibDab,

                    I don't see that happening on my end, are you certain that you are compiling the code after making changes?

                    With the sample that I provided You should see a entry and exit order in 1 bar when using OnEachTick because you have a generic entry condition that can happen as soon as the position is flat again. The first entry will happen and the exit should occur 5 bars after the entry it targets. Then you would see another entry on the same bar as that exit. 5 bars later you would see another exit and immediately have another entry. To avoid that you would have to make a more specific entry condition.

                    Comment


                      #40
                      that's why in my original code I had "entryCnt;" to allow only one entry (see Test.zip in previous attachment)

                      maybe that method doesn't work OnEachTick?
                      Last edited by dibDab; 10-26-2022, 03:18 PM.

                      Comment


                        #41
                        Hello dibDab,

                        The sample that I provided was simply to demonstrate using BarsSinceEntryExecution in realtime. This method works for both OnBarClose or OnEachTick. If you choose to use OnEachTick in realtime then it would be expected that a simple condition like that would allow another entry as soon as it was flat again so you would see an entry and exit on a single bar after the first exit had closed the first entry. Every time an exit happened after that an entry would be placed on the bar with the exit because you are using OnEachTick and it was flat again.

                        In your original script you had logic to make a single entry which is something you could still do if you wanted to test something one time in realtime.

                        Comment


                          #42
                          I really appreciate your help but I just can't get to the bottom of this.

                          I've attached Test_v2.zip (Calculate.OnEachTick) which has one entry and prints 1 submitted and 1 filled.

                          Yet the chart signal keeps on moving to the right on each new bar?​

                          Comment


                            #43
                            Hello dibDab,

                            It looks like you added quite a bit of code to this sample. If you are having trouble with that I would suggest using prints to identify how your code is working when you run it. You may also want to avoid using OnEachTick until you have your idea working as you wanted. I can see on my end that BarsSinceEntryExecution works as expected and waits 5 bars before doing an exit.



                            Comment


                              #44
                              ok thanks, will start again using OnBarClose and try and understand what's happening.

                              can I ask if the realtime trade moving right with each new bar away from the entry bar it was submitted/filled on is correct given the Test_v2 code?



                              Comment


                                #45
                                Hello dibDab,

                                If you mean a working order that has not filled, that should remain working until filled. An unfilled order has no associated bar because it has not filled yet. The "entry bar" or where you condition happened is not a guarantee of where a limit order will fill, limit orders have specific price requirements to fill and if that requirement is not met it would keep working until filled.

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by NullPointStrategies, Yesterday, 05:17 AM
                                0 responses
                                62 views
                                0 likes
                                Last Post NullPointStrategies  
                                Started by argusthome, 03-08-2026, 10:06 AM
                                0 responses
                                134 views
                                0 likes
                                Last Post argusthome  
                                Started by NabilKhattabi, 03-06-2026, 11:18 AM
                                0 responses
                                75 views
                                0 likes
                                Last Post NabilKhattabi  
                                Started by Deep42, 03-06-2026, 12:28 AM
                                0 responses
                                45 views
                                0 likes
                                Last Post Deep42
                                by Deep42
                                 
                                Started by TheRealMorford, 03-05-2026, 06:15 PM
                                0 responses
                                50 views
                                0 likes
                                Last Post TheRealMorford  
                                Working...
                                X