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

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.
    JimNinjaTrader Customer Service

    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.
        JimNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by r68cervera, Today, 05:29 AM
        0 responses
        2 views
        0 likes
        Last Post r68cervera  
        Started by geddyisodin, Today, 05:20 AM
        0 responses
        3 views
        0 likes
        Last Post geddyisodin  
        Started by JonesJoker, 04-22-2024, 12:23 PM
        6 responses
        33 views
        0 likes
        Last Post JonesJoker  
        Started by GussJ, 03-04-2020, 03:11 PM
        12 responses
        3,239 views
        0 likes
        Last Post Leafcutter  
        Started by AveryFlynn, Today, 04:57 AM
        0 responses
        6 views
        0 likes
        Last Post AveryFlynn  
        Working...
        X