• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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 vivekniwas, Today, 04:56 PM
          0 responses
          6 views
          0 likes
          Last Post vivekniwas  
          Started by dtl-saw, Today, 03:36 PM
          1 response
          10 views
          0 likes
          Last Post NinjaTrader_ChrisL  
          Started by williamzz, Today, 02:04 PM
          2 responses
          11 views
          0 likes
          Last Post williamzz  
          Started by jtrading82, Today, 01:55 PM
          3 responses
          27 views
          0 likes
          Last Post NinjaTrader_Tyler  
          Started by StevenNelson, Today, 01:00 PM
          4 responses
          19 views
          0 likes
          Last Post StevenNelson  
          Working...
          X