Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Session Template

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

    Session Template

    How can I specify which session template I want a strategy to use in code? I would expect to add something like this in the Initialize() method... SessionTemplate = "session template" But, I can't find anything resembling that.

    Thanks,
    Mike

    #2
    Hi Mike, unfortunatelty there's no property available to dictate the chart / series what template specifically to use, you could check for which template is applied though and inform the user that another one one would be preferred.

    Comment


      #3
      Thanks...That's what I thought as well but it doesn't seem to work that way. This is the code I put in OnStartUp() and it just doesn't seem to work.
      Code:
      if (Instrument.MasterInstrument.SessionTemplate == Session.UseInstrumentSettings)//"Nymex Metals / Energy ETH")
      {
      	DrawTextFixed("session","Must use Session Template 'Nymex Metals / Energy ETH'",TextPosition.Center,Color.White,textFont,Color.Black,Color.Black,10);
      	return;
      }

      Comment


        #4
        Would have rather used something along those lines -

        Code:
        protected override void OnStartUp()
        		{
        			if (Bars.Session.TemplateName != "Nymex Metals / Energy ETH")
        			{
        				DrawTextFixed("session", "Must use Session Template 'Nymex Metals / Energy ETH'", TextPosition.Center);
        				return;
        			}
        			
        		}
        If the session is not the default Nymex ETH, the DrawTextFixed will plot asking user to change as needed.

        Comment


          #5
          Sorry I sent you the wrong code snippet. That one was just one of the iterations I used trying to get something to print in the output window. However, using your code snippet still does not work. I can change the session template for the strategy to something other than "Nymex Metals / Energy ETH" and no DrawFixedText message appears.

          Comment


            #6
            Works in my strategy test script just as posted when I select an 'incorrect' session. What market / chart do you exactly run it on? If you add a print to OnStartUp, is it triggerd at all in your scenario?

            Comment


              #7
              nope nothing prints in the output window regardless what session template I use on the chart.

              I run it on CL with a minute chart. This is the snippet I'm using.

              Code:
              			
              if (Instrument.MasterInstrument.SessionTemplate != "Nymex Metals / Energy ETH")
              {
              	Print(Session.UseInstrumentSettings);
              	DrawTextFixed("session","Must use Session Template 'Nymex Metals / Energy ETH'",TextPosition.Center,Color.White,textFont,Color.Black,Color.Black,10);
              	return;
              }

              Comment


                #8
                Please run with this code used for checking the sessions -

                if (Bars.Session.TemplateName != "Nymex Metals / Energy ETH")

                Any change?

                Comment


                  #9
                  yes that works...I think I understand why. However, the return does not stop the strategy from running. Moved the code to OnBarUpdate() and return works.

                  Comment


                    #10
                    Correct, the return would only work from OnBarUpdate() since there's is your processing then.

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                    0 responses
                    647 views
                    0 likes
                    Last Post Geovanny Suaza  
                    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                    0 responses
                    368 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
                    571 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