Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

StopLimit, Unmanaged strategy problem with sessions

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

    StopLimit, Unmanaged strategy problem with sessions

    I have a strategy that needs to be unmanaged because I am placing simultaneous StopLimit orders in order to stop myself into the market without picking a direction. My issue is on overnight. I want my indicator to be calculated on regular session time, however, for trading I'd like to see all bars. So that I can see if a StopLimit was filled overnight historically without having the indicator change overnight.

    So my question is; is it possible to have a strategy with two different periods that also have different session times? And if not, what do you think an applicable solution might be?

    Thanks.

    #2
    Hi zwentz, this is unfortunately not possible, you would then need to run the strategy for the full session including overnight and limit calcs overnight for your indicator, so it's basically persisting the regular session end value then.

    Comment


      #3
      Hey Bertrand,

      Yeah I started to think the same. Out of interest, if I limited my indicator to the session times, it would still calculate on out of session bars would it not?

      Thanks,
      Zach

      Comment


        #4
        You could apply time filters to indicator calcs as well, for example the SMA below only plots / returns values for the cash session in Mountain time -

        Code:
         
        protected override void OnBarUpdate()
        {
        if (ToTime(Time[0]) >= 073000 && ToTime(Time[0]) <= 141500)
        Plot0.Set(SMA(Close, 20)[0]);
        }

        Comment


          #5
          Right, but at 7:30 it's taking the SMA of 20 bars that were not in the cash session.

          Comment


            #6
            True zwentz, for this then you would need to run it on a custom dataseries / array providing the needed calculation base.

            Comment


              #7
              Oh man, it has been a long night. But yes of course you're right, that's precisely what I would need to do. Thanks Bertrand.

              Comment


                #8
                Well after a fair amount of trying I can't seem to grok it. I can make an indicator that only holds the values for the session, and thereby a DataSeries only holding values for the session, but there are still a bunch of zero/null values in between.

                I also tried using a List<double> and casting that to a double array via the ToArray() method, but that isn't an allowable input for an indicator.

                Another thing I tried was, being that this is on a specified period, just counting the bars out of session and skipping them with my period call, but it fluctuates too much. It ranges anywhere from 40-30. And while I could just go back and find out which bar is the last of the previous session via Time, I'm beginning to think this skipping idea isn't a viable solution anyway.

                Forgive me for being a bother but can you elaborate on how I would go about doing this with a custom DataSeries? You don't have to code it up or anything like that, just a general idea will suffice.

                Thanks.

                Comment


                  #9
                  zwentz, unfortunately I wouldn't know of a code sample existing on this to get you started - you have to create the needed array and custom sma calcs yourself so you can point to the proper bars back for the calcs to use at the session break where you wanted them to reach back until the last bar of the prior session...which is definitely an advanced programming task. I thought of workarounds for you, you could definitely let it run on session hrs and then just monitor a second chart for execution set to your account and the full session, which might suffice.

                  Comment


                    #10
                    Would something like this help?

                    Code:
                     
                    CalculateOnBarClose = false;
                    PeriodType ID = BarsPeriod.Id;
                    int VAL = BarsPeriod.Value;
                    Add(ID,VAL*2);//Scale 1
                    Add(ID,VAL*4);//Scale 2
                    Add(ID,VAL*8);//Scale 3
                    Add(ID,VAL*16);//Scale 4
                    Add(ID,VAL*32);//Scale 5
                    Add(ID,VAL*64);//Scale 6
                    Add(ID,VAL*128);//Scale 7
                    Add(ID,VAL*256);//Scale 8
                    Add(ID,VAL*512);//Scale 9
                    Add(ID,VAL*1025);//Scale 10
                    Add(ID,VAL*4096);//Scale 11
                    Add(ID,VAL*8192);//Scale 12
                    or a variation thereof?

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                    0 responses
                    649 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
                    576 views
                    1 like
                    Last Post RFrosty
                    by RFrosty
                     
                    Working...
                    X