Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Executing a strategy avoiding previous take positions

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

    Executing a strategy avoiding previous take positions

    Hi,

    there is a situation I don't know how to solve. I enable a strategy and I see on the chart that yesterday a long position should have been taken. A buy arrow appears.

    If I leave the strategy enabled the position will be sold. So, I will be on the short side because I didn't have a previous open position.

    If I disable the strategy, I cannot see on the chart when it will be closed following the strategy.

    It is possible to enable the chart only in a watch mode without allowing it to open or close positions?

    thanks

    #2
    Hello,

    Thanks for the note.

    What you are facing is whats called your strategy being out of sync.

    From what you describe it looks like your account position and the strategy position is not in sync.

    Strategy Position vs. Account Position:


    1st solution:

    You can include the following statement in your code to avoid the strategy to be calculated on historical data.

    // Only run on real-time data
    if (Historical)
    return;
    Add the statement to the top of OnBarUpdate()

    2nd solution:
    You can set 'On starting a real-time strategy' to 'Wait until flat before executing live'.
    This option can be found at Tools-->Options-->Strategies-->NinjaScript-tab.

    3rd solution, would be submitting manual orders to sync the strategy and account positions described in the link

    4th solution, would be to enable Sync account position to true.






    If you just want to put a strategy in watch mode you would need to start it on the Sim101 account so that the trades it makes are only to the simulated account then you can choose to go live if you choose.

    Let me know if I can be of further assistance.

    Comment


      #3
      Executing a strategy with open account position

      Thanks for this detailed reply.

      I think that for the case I proposed the most cautious is to set 'Wait until flat before executing live', 'Sync account position'=false and wait for the strategy position to be closed.

      There is another case I don't see a clear solution. 'Wait until flat before executing live' is a setting that globally affects all symbols and strategies. If I leave this setting active and 'Sync account position'=false, when I execute a strategy and there is an open account position the strategy will wait until the strategy position is flat but it won't close the account position. I'm wrong?

      So, if I set 'Sync account position'=true would be in that case the right solution to match the strategy and account positions? I don't think that with Sync=true NT will launch a new extra position, I'm wrong?

      Comment


        #4
        Hello guillembm,

        "when I execute a strategy and there is an open account position the strategy will wait until the strategy position is flat but it won't close the account position. I'm wrong?"

        Please note that using these settings, NinjaTrader will assume your account position is flat. So if your account position is not flat when the strategy position reaches a flat state, your account position and strategy position will not be in synch. So yes, it could close your account position.

        If you set it to True, NinjaTrader will submit market orders to flatten your account position. Subsequently, it will wait for your strategy to reach a flat state before submitting orders.
        JasonNinjaTrader Customer Service

        Comment


          #5
          So, what are the right settings if I want my strategy to recognize an open account position?

          - I have an open account position.
          - I have an open strategy position.
          - I have a stop and target orders launched by the strategy
          - In the options dialog box is set to "wait until flat before submitting live"

          everything has to be synchronized when re-starting the strategy. What are the right settings?

          Comment


            #6
            If the strategy and account position reflect the same position, you can set 'Synch account position' to False.

            If not and the strategy and account position reflect different positions, I suggest to set 'Synch account position' to True, that way your strategy and account position will be put in synch if you have an open account position.
            JasonNinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_Jason View Post
              If the strategy and account position reflect the same position, you can set 'Synch account position' to False.

              If not and the strategy and account position reflect different positions, I suggest to set 'Synch account position' to True, that way your strategy and account position will be put in synch if you have an open account position.
              THanks,

              and what about the stop and target orders?

              Comment


                #8
                You can find all details for each setting at the link below.


                Wait until flat before executing live, Sync account position = false
                When your strategy starts it will check for any active orders previously generated by the strategy on your account and cancel those first. Should the strategy be unable to cancel and receive confirmation on the cancellation of these orders within 40 seconds the strategy will not start and an alert will be issued.

                Wait until flat before executing live, Sync account position = true
                When your strategy starts it will check for any active orders previously generated by the strategy on your account and cancel those first. Should the strategy be unable to cancel and receive confirmation on the cancellation of these orders within 40 seconds the strategy will not start and an alert will be issued. After the strategy is successful in cancelling any orders that required action it will check your current Account Position and compare it to a flat state. On multi-instrument strategies it will perform this check for all instruments used by the strategy.
                JasonNinjaTrader Customer Service

                Comment


                  #9
                  I already read this before. It's clear that stop and target orders are cancelled when re-executing the strategy.

                  The question is: after cancelling these orders are them launched again or I have to do it manually? If the stop order is simulated will it be enabled on the strategy again?

                  Comment


                    #10
                    ATM orders are submitted after the strategy position reaches a flat state and the strategy conditions occur to submit ATM orders.

                    Virtual orders are submitted before the strategy reaches a flat state. After the strategy reaches a flat state, it will submit ATM orders again if the strategy conditions are met.
                    JasonNinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by algospoke, Yesterday, 06:40 PM
                    2 responses
                    18 views
                    0 likes
                    Last Post algospoke  
                    Started by ghoul, Today, 06:02 PM
                    3 responses
                    14 views
                    0 likes
                    Last Post NinjaTrader_Manfred  
                    Started by jeronymite, 04-12-2024, 04:26 PM
                    3 responses
                    44 views
                    0 likes
                    Last Post jeronymite  
                    Started by Barry Milan, Yesterday, 10:35 PM
                    7 responses
                    20 views
                    0 likes
                    Last Post NinjaTrader_Manfred  
                    Started by AttiM, 02-14-2024, 05:20 PM
                    10 responses
                    180 views
                    0 likes
                    Last Post jeronymite  
                    Working...
                    X