Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

PROBLEM when detecting start and end of session in ES

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

    PROBLEM when detecting start and end of session in ES

    I am trying to write a very simple code in NT8 that detects the begin and end time of current session of ES future, by only drawing a vertical line when the session starts, and I found a quite rare thing, the indicator works fne if I don't have any plot configured but if I add any Plot it doesn't work.

    Find the behaviour in the following video to better understand what I mean:



    You can see as the "example" indicator works fine and it draws the vertical line, but the "examplewithplots" indicator (with the only difference of adding 2 plots" doesn't work.

    I attach also the 2 codes.

    Please, let me know what I am doing wrong.

    Thanks

    Attached Files

    #2
    Hello Sangui,

    Thanks for opening the thread.

    I was not able to see results testing the script as is so I took the following steps:

    1. Changed Contract month to ES 03-19
    2. Moved Draw.VerticalLine() to your Session method.
    3. Tested without plots added and with plots added.

    After making the above changes, I did not encounter any issue. As for troubleshooting steps to help identify what may be happening in your script, you can add debugging prints to show the values used to evaluate the conditions in your logic. You should expect that running in the Playback Connection, if you see a print for "START SESSION" the Draw.VerticalLine is reached and the line should be displayed. If you do not see a line and this print is missing, we know that the logic did not become true and the values used to evaluate each condition would need to be debugged to find out why that condition did not become true.

    Please let me know if you have any additional questions on setting up debugging prints.

    Comment


      #3
      Hi Jim,

      Thanks about the quick answer. But what I don't understand if why the indicator works and detects "begin" and "end" well if I don't add any plot but it doesn't detect it when I simply add a plot (it is the only difference between the 2 codes). I don't know if you know what I mean?. Is there anything that I am doing wrong?. What can I do to make it work?.

      Thanks again.

      Regards,

      Comment


        #4
        Hello Sangui,

        I was unable to observe any difference in behavior testing with/without plots.

        An issue with the drawing object not appearing would be due to:

        1. Logically it is not getting called
        2. RemoveDrawObject is occurring before this object is seen on the chart.

        My recommendation remains to use debugging prints to confirm the Drawing method is getting reached and the the drawing object is not getting removed by your RemoveDrawObjects call.

        Do you see your print for "START SESSION?" This would indicate the drawing tool method is reached and we should expect the drawing object to appear on the chart unless RemoveDrawObjects removes it. If you see this print but no drawing objects are listed in the Charts Draw Objects collection when you test, then this would be further evidence that RemoveDrawObjects has removed the drawing tool.

        Confirming the above should be all that is necessary, but if you do not see a print for START SESSION, then we know that the code is not getting reached and the following conditions may not be coming true. The following conditions will then need to be debugged.

        if(IsFirstTickOfBar)

        if (Time[0] >= Begin && Time[1] < Begin)

        if (Time[0]<Begin || Time[0]>End)

        if(BarsInProgress==0)

        The debugging prints will need to monitor the values used to evaluate these conditions so you can see why a condition is not becoming true and can make the appropriate correction.

        Please let us know if we can be of further assistance.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        648 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        369 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        108 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        572 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        573 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X