Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Session manager and template help please.

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

    Session manager and template help please.

    Hi there,
    I have created a session template for Forex trading that starts at 7 am Monday morning and finishes at 7 am Saturday. During back testing I apply that template as the session template in the strategy analyser and all works well i.e. trades that haven't hit their profit or loss targets are closed and shown as "exit at close" just prior to the end of the session on Saturday morning my time. However when a strategy is running on live chart with Exit at close set to True, any open trades are being closed at 7 am the next morning no matter what day it is, even though the Session Template in the Data Series box has been set to the template I created. Can you please advise what the problem is.

    Thanks

    Chris

    #2
    Hi Chris, thanks for the post - what you've run into is unfortunately a known limitation for ExitOnClose working on a multiday session setup in non backtesting mode. We have this on our list do look into and review for the next major platform update.

    For now, I would set ExitOnClose to false in the live trading version and exit the trades at your desired day / time directly via code.

    For example consider this snippet tied to your day / times as desired -

    Code:
    if (Time[0].DayOfWeek == DayOfWeek.Friday && ToTime(Time[0]) == 160000)
    {
    	if (Position.MarketPosition == MarketPosition.Long)
    		ExitLong();
    	if (Position.MarketPosition == MarketPosition.Short)
    		ExitShort();
    }
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Thanks Bertrand, once again quick and accurate customer service. Unfortunately I have zero expertise when it comes to coding and so I need to ask the dumb questions like ...I presume to make it 7 am Saturday morning I change your code to

      "if (Time[0].DayOfWeek == DayOfWeek.Satday && ToTime(Time[0]) == 070000)"

      and also would I cut and paste it into the cs file where I have put the question marks below? This is after the second condition set of a very simple strategy

      {
      EnterShort(10000, "");
      }
      ??????

      }

      Thanks

      Chris

      p.s. I can see I'm going to have to learn coding

      Comment


        #4
        Yes, that looks good Chris, except it needs to be DayOfWeek.Saturday.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Thanks again Bertrand really appreciate your help

          Chris

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by gentlebenthebear, Today, 01:30 AM
          2 responses
          13 views
          0 likes
          Last Post gentlebenthebear  
          Started by Kaledus, Today, 01:29 PM
          2 responses
          7 views
          0 likes
          Last Post Kaledus
          by Kaledus
           
          Started by frankthearm, Yesterday, 09:08 AM
          13 responses
          45 views
          0 likes
          Last Post frankthearm  
          Started by PaulMohn, Today, 12:36 PM
          2 responses
          16 views
          0 likes
          Last Post PaulMohn  
          Started by Conceptzx, 10-11-2022, 06:38 AM
          2 responses
          56 views
          0 likes
          Last Post PhillT
          by PhillT
           
          Working...
          X