Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Opening a virtual position

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

    Opening a virtual position

    Hi,

    I have an issue that I don't know how to solve.

    I have a strategy running on regular trading hours and I want to set a safety stop out of regular hours. So far this is not a problem.

    The problem is that I have several indicators and calculating indicators out of regular time distorts them because of low volume and high volatility. If I do this I have silly buy-sell signals at the beginnning of the regular session. I would like to find a solution for the indicators to be calculated only based on bars executed during regular time but on a chart displaying data all time.

    I think this is not possible but a possible solution is to create 2 strategies, one on regular hours and the other out of regular hours. The trouble is that, in order to set an ExitLongStopLimit() on the out of regular hours strategy I need to have an open position. If I already have a position on the main strategy I cannot launch it again. Is there a way to set a kind of virtual position at real time without creating a real position on the market only to be able to set a ExitLongStopLimit?

    Another solution is to automatically start the second strategy so I can set a position on an historical bar and then I can launch an ExitLongStopLimit. Auto-starting a strategy is not featured on NT, I think.

    Another option, if possible, is to calculate indicators only based on regular time bars avoiding out of regular hours bars. (I think it's not possible but asking is free)

    What can I do?

    #2
    Hi there, I will have someone get back to you on Monday.
    AustinNinjaTrader Customer Service

    Comment


      #3
      Originally posted by guillembm View Post
      Hi,

      I have an issue that I don't know how to solve.

      I have a strategy running on regular trading hours and I want to set a safety stop out of regular hours. So far this is not a problem.

      The problem is that I have several indicators and calculating indicators out of regular time distorts them because of low volume and high volatility. If I do this I have silly buy-sell signals at the beginnning of the regular session. I would like to find a solution for the indicators to be calculated only based on bars executed during regular time but on a chart displaying data all time.

      I think this is not possible but a possible solution is to create 2 strategies, one on regular hours and the other out of regular hours. The trouble is that, in order to set an ExitLongStopLimit() on the out of regular hours strategy I need to have an open position. If I already have a position on the main strategy I cannot launch it again. Is there a way to set a kind of virtual position at real time without creating a real position on the market only to be able to set a ExitLongStopLimit?

      Another solution is to automatically start the second strategy so I can set a position on an historical bar and then I can launch an ExitLongStopLimit. Auto-starting a strategy is not featured on NT, I think.

      Another option, if possible, is to calculate indicators only based on regular time bars avoiding out of regular hours bars. (I think it's not possible but asking is free)

      What can I do?
      You want to use a time filter on your indicator, so that it only calculates between your desired times.

      Pseudocode:

      Code:
      if (Time[0] >= StartTime && Time[0] < EndTime)
      {
      // Do stuff
      }

      Comment


        #4
        Are you coding your own strategy or using the builder?

        Can you do the standard time check and run code for regular hours and in the other part of the else use code for after hours?

        protected override void OnBarUpdate()
        {
        if (Historical) return;


        if ( ToTime(Time[0]) >= ToTime( 9, 30, 00)
        && ToTime(Time[0]) <= ToTime( 16, 00, 00))
        {
        //market hours
        }

        else
        //after hours
        {

        }

        Originally posted by guillembm View Post
        Hi,

        I have an issue that I don't know how to solve.

        I have a strategy running on regular trading hours and I want to set a safety stop out of regular hours. So far this is not a problem.

        The problem is that I have several indicators and calculating indicators out of regular time distorts them because of low volume and high volatility. If I do this I have silly buy-sell signals at the beginnning of the regular session. I would like to find a solution for the indicators to be calculated only based on bars executed during regular time but on a chart displaying data all time.

        I think this is not possible but a possible solution is to create 2 strategies, one on regular hours and the other out of regular hours. The trouble is that, in order to set an ExitLongStopLimit() on the out of regular hours strategy I need to have an open position. If I already have a position on the main strategy I cannot launch it again. Is there a way to set a kind of virtual position at real time without creating a real position on the market only to be able to set a ExitLongStopLimit?

        Another solution is to automatically start the second strategy so I can set a position on an historical bar and then I can launch an ExitLongStopLimit. Auto-starting a strategy is not featured on NT, I think.

        Another option, if possible, is to calculate indicators only based on regular time bars avoiding out of regular hours bars. (I think it's not possible but asking is free)

        What can I do?

        Comment


          #5
          Both suggestions below are good ones.

          Thanks Guys.

          Comment


            #6
            Thanks for your help, guys.

            I'll try to explain it better with an example. I already tried the same solution you propose.

            Imagine you have:
            - A chart with the Default 24/7 template for a stock and a 5 min. time frame
            - An indicator that is calculated on a 15 bar period.

            Following your solution, if the indicator is calculated at 9:00 AM it will be using bars from the out of regular trading hours and this is faking the value of the indicator. On my tests indicators calculated during out of regular hours or at the start of the session give false buy-sell signals due to its high volatility and low volume.

            The same effect I find in low volume periods as August, Christmas or Eastern (much lower on this one) holidays.

            So, this solution is not suitable for this.

            Comment


              #7
              Originally posted by guillembm View Post
              Thanks for your help, guys.

              I'll try to explain it better with an example. I already tried the same solution you propose.

              Imagine you have:
              - A chart with the Default 24/7 template for a stock and a 5 min. time frame
              - An indicator that is calculated on a 15 bar period.

              Following your solution, if the indicator is calculated at 9:00 AM it will be using bars from the out of regular trading hours and this is faking the value of the indicator. On my tests indicators calculated during out of regular hours or at the start of the session give false buy-sell signals due to its high volatility and low volume.

              The same effect I find in low volume periods as August, Christmas or Eastern (much lower on this one) holidays.

              So, this solution is not suitable for this.
              Sorry, but I do not quite get your point. 9AM is outside trading hours, so if you calculate the indicator at that time, it will use bars outside trading hours. If you only want to use bars during trading hours, then limit your calculations to trading hours.

              Comment


                #8
                This is exactly the point. To trade out of regular hours without affecting the indicators calculated on regular ones the only option I see is to create a new strategy that only works out of the session.

                But I'm trying to automate systems and I would like this to be automatic. Automatically starting a strategy would be a nice feature to include. Till this happens the only option I have is to wait till the session ends and start the second strategy.

                Comment


                  #9
                  This is the only option I could provide as well.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by GussJ, 03-04-2020, 03:11 PM
                  11 responses
                  3,228 views
                  0 likes
                  Last Post xiinteractive  
                  Started by andrewtrades, Today, 04:57 PM
                  1 response
                  13 views
                  0 likes
                  Last Post NinjaTrader_Manfred  
                  Started by chbruno, Today, 04:10 PM
                  0 responses
                  7 views
                  0 likes
                  Last Post chbruno
                  by chbruno
                   
                  Started by josh18955, 03-25-2023, 11:16 AM
                  6 responses
                  440 views
                  0 likes
                  Last Post Delerium  
                  Started by FAQtrader, Today, 03:35 PM
                  0 responses
                  12 views
                  0 likes
                  Last Post FAQtrader  
                  Working...
                  X