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 CarlTrading, 03-31-2026, 09:41 PM
                  1 response
                  68 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Started by CarlTrading, 04-01-2026, 02:41 AM
                  0 responses
                  37 views
                  0 likes
                  Last Post CarlTrading  
                  Started by CaptainJack, 03-31-2026, 11:44 PM
                  0 responses
                  61 views
                  1 like
                  Last Post CaptainJack  
                  Started by CarlTrading, 03-30-2026, 11:51 AM
                  0 responses
                  62 views
                  0 likes
                  Last Post CarlTrading  
                  Started by CarlTrading, 03-30-2026, 11:48 AM
                  0 responses
                  53 views
                  0 likes
                  Last Post CarlTrading  
                  Working...
                  X