Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ExitOnClose

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

    #16
    Hi,

    My issue with ExitOnClose is slightly different but I thought it may still be appropriate for this thread.

    What I want to do is set ExitOnClose (EOC), outside of the Initialize routine.
    - OnBarUpdate called; if hour is 0-7; set EOC=true else=FALSE

    In backtesting the Corn market (ZC) the log statements I get are as expected. So this leads me to the following quesitons;

    - Must ExitOnClose be set TRUE prior to entering a trade in order for it to work on that order?

    - Is there a callback like OnMarketClose() so I can handle this myself?


    Any other ideas or suggestions would be appreciated.

    Thanks.

    Comment


      #17
      Hi eplum, unfortunately setting this property dynamically outside of Initialize() would not be supported - I suggest you then code this out manually by checking the current / barstamp time against the session templates close :

      Comment


        #18
        Thanks Bertrand, I will try the barstamp time then.

        Just to comment; when I did use the OnExitClose dynamically as described in my previous post, it did take effect. However, it closed out any open position just prior to 12:00 AM EST, which is not a session ending time for the ZC contract. I'm not sure why it does that or if it's expected to.

        Comment


          #19
          Do you remember which session templates you used on this chart then? ExitOnClose is tied to those hours in the templates used.

          Comment


            #20
            Yeah - I used the "Default 24/7".

            Comment


              #21
              I just printed out some logs from the Session Template call;

              Bars.Session.GetNextBeginEnd(timeNow, out timeBegin, out timeEnd);

              And I see that using the 24/7 default template, the begin and end time of each session is at 12:00 AM EST. So that explains what I was seeing and why. Not what I was expecting, but hey that's what logs are for!

              So, correct me if I'm wrong but it looks like I need to make a custom session template in order to get the ExitOnClose to work for what I'm trying to do.

              Comment


                #22
                OK, sorry for the rapid fire multiple replies, but I just implemented what I was trying to accomplish.
                Is all I had to do was use the "CBOT Agriculturals ETH" session template. This then enabled the ExitOnClose parameter to work as expected.

                Note: ExitOnClose can be successfully set dynamically outside of the Initialize routine.

                Comment


                  #23
                  Sorry for me late reply, but glad to hear you were able to make it work for you.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                  0 responses
                  652 views
                  0 likes
                  Last Post Geovanny Suaza  
                  Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                  0 responses
                  370 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by Mindset, 02-09-2026, 11:44 AM
                  0 responses
                  109 views
                  0 likes
                  Last Post Mindset
                  by Mindset
                   
                  Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                  0 responses
                  574 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by RFrosty, 01-28-2026, 06:49 PM
                  0 responses
                  577 views
                  1 like
                  Last Post RFrosty
                  by RFrosty
                   
                  Working...
                  X