Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

sync strategy with account

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

    sync strategy with account

    I have a multi-day strategy. Let's say a simple SMA crossover. The strategy is enabled and running.
    When I get the signal, the strategy buys and enter long position.

    Now, let's say I disable the strategy [during the day, or at the end of it]. When I re-enable it, the strategy sells the existing position, and buys to open again.

    Is there a way to sync the position without selling the existing, but to update the strategy that right now, it's in 'Long'?

    Thanks.

    #2
    Hello,

    Thanks for your forum post.

    What are you using for the setting Sync Account Position in the Strategies tab when you start the strategy?

    I look forward to assisting you further.

    Comment


      #3
      You mean in the strategy properties? I use

      Sync Account Position = True

      Comment


        #4
        Hello,

        Ok, this would be the expected in this case as the account sync will occur. An account sycn will always take and action needed to sync the current account position to the current strategy position.

        I would need to verify in the log whats going on here but the sync would not sell the position unless your strategy position was flat.

        If you feel this is what its doing I would need to take a look at your log file so that I can see whats going on. Best way to send in is via Control Center->Help->Mail To Support. and reference this forum post in email.

        Then please let me know what time and date you tried to disable the strategy and reinable it so I can see what occured.

        I look forward to assisting you further.

        Comment


          #5
          Here's is what I have done

          1. This is the current strategy, with current position [attachment #1, with postfix _02]

          2. This is how to Position window looks like [attachment #2, postfix _03]

          3. Now I click disable strategy [attachment #3, postfix _04]

          4. There shouldn't be any executions, but I get 3 [attachment #4, postfix _06]

          5. And this is new Position window [attachment #5, postfix _07]

          I have sent the log in mail to support.
          Attached Files

          Comment


            #6
            Hello,

            So this strategy. Does it run on historical or does it not run on historical.

            As heres whats happenening. When you first run the strategy and enable it.

            The synconize occurs.:

            3/7/2011 10:25:40 PM|1|128|Syncing account position on starting strategy 'RSI4/9769d171abda4db6846e24f0b593140d'. Account position='35S IDX' Strategy position=''

            Here is the line that causes the sync order to close out the current position.

            As the strategy position is calculated in historical and found to be flat. This in sync's the account to flat.

            Then your strategy then submits another short order.

            What we need to isolate is why is the Sync call finding the strategy position to be flat when it is called. The only thing I can think of is the strategy does not have a position on historical data.

            Your ticket number for your log files in case I need it again for my reference: 447510

            Let me know if I can be of further assistance.

            Comment


              #7
              Originally posted by NinjaTrader_Brett View Post
              Hello,

              So this strategy. Does it run on historical or does it not run on historical.
              What so you mean? it should work on historical? are there any other options?

              Comment


                #8
                gogetit, Brett was curious if you used the historical property perhaps to return out of any OnBarUpdate() calls on historical data, this would mean the strategy is flat as it starts to see realtime bars then coming in after enabling.
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_Bertrand View Post
                  gogetit, Brett was curious if you used the historical property perhaps to return out of any OnBarUpdate() calls on historical data, this would mean the strategy is flat as it starts to see realtime bars then coming in after enabling.
                  Is there a way for me to know in OnBarUpdate() is i'm working off historical vs. realtime bars?

                  Thanks.

                  Comment


                    #10
                    Hello,

                    Yes, Historical is a bool that will be true or false if the strategy is running on historical.

                    if (Historical)
                    {
                    //Run on Historical Data
                    }

                    if (!Historical)
                    {
                    //Run on Live data only
                    }

                    Let me know if I can be of further assistance.

                    Comment


                      #11
                      Originally posted by NinjaTrader_Brett View Post
                      Hello,

                      Yes, Historical is a bool that will be true or false if the strategy is running on historical.

                      if (Historical)
                      {
                      //Run on Historical Data
                      }

                      if (!Historical)
                      {
                      //Run on Live data only
                      }

                      Let me know if I can be of further assistance.

                      I'm not using Historical property, but I do use DateTime.Now... I will make some modifications to use DateTime.Now only if !Historical and see if it helps.
                      Thanks for the help.

                      Comment


                        #12
                        Hello,

                        This still will not work as your strategy is not submitting orders until realtime since your using the DateTime.Now property.

                        You would need to use Time[0].

                        If you want to continue to use DateTime.Now property you will need to turn off the sync position and set to false and do a manual sync of the strategy.

                        Or know that it will close the current open position all the time and return the position to flat. Since your strategy does not run on historical data and does not have a position in the past, so when it starts it will always start with a position of flat which your account will sync too. Its only after this sync does the strategy place a live trade and continue on from their.

                        Let me know if I can be of further assistance.

                        Comment


                          #13
                          Yes, I think this is the issue.
                          I use DateTime.Now because I want realtime orders to fill only before the close.
                          For example, let's say I use the SMA crossover strategy. I would like to buy if daily SMA(10)>SMA(20). but I don't want to wait for EOD and buy at the opening in the following morning.

                          So I set Calculate on bar close = False. However I want to buy only if the signal is valid at the end of day. so I use:
                          Code:
                                              if (DateTime.Now < DateTime.Parse("15:00") ){
                                                  return;
                                              }
                          And this is what caused the historical state to be flat when I enabled the position. I changed the code to:
                          Code:
                                      if (!Historical) {
                                          //Run on Live data only
                                              if (DateTime.Now < DateTime.Parse("15:00") ){
                                                  return;
                                              }
                                      }
                          And I think that should solve it. What do you think?

                          Comment


                            #14
                            Hello,

                            This will still cause the same thing to happen if I'm reading the code correctly:

                            if (DateTime.Now < DateTime.Parse("15:00") ){
                            return;

                            Is still there and if this evaluates true it will return out of OnBarUpdate() and not place any trades.

                            This is the same as if you had put and your overriding your historical check.
                            if(Historical)
                            {
                            if (!Historical)

                            Comment


                              #15
                              Okay, so do you have any suggested solution?
                              Here's the challenge again:

                              Let's assume the strategy runs on daily bars. But I would like to execute only at a certain time of day, let's say after 3p.
                              Also I might disable/enable the strategy during the day or at day close, and I wouldn't want new signals if already in position. I would like to keep the last entry, so I'll be able to see the date/price of entry and also get a valid exit.


                              Thanks!

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by judysamnt7, 03-13-2023, 09:11 AM
                              4 responses
                              53 views
                              0 likes
                              Last Post DynamicTest  
                              Started by ScottWalsh, Today, 06:52 PM
                              4 responses
                              33 views
                              0 likes
                              Last Post ScottWalsh  
                              Started by olisav57, Today, 07:39 PM
                              0 responses
                              5 views
                              0 likes
                              Last Post olisav57  
                              Started by trilliantrader, Today, 03:01 PM
                              2 responses
                              19 views
                              0 likes
                              Last Post helpwanted  
                              Started by cre8able, Today, 07:24 PM
                              0 responses
                              6 views
                              0 likes
                              Last Post cre8able  
                              Working...
                              X