Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Strategy does not stay in Sync

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

    Strategy does not stay in Sync

    All,

    I have the following strategy that is always in the market. It works fine with the Sim101 account, but with the FOREX.com live account it does not stay in sync.

    Any ideas as to why this is the case? Ninjatrader should close the SHORT before going LONG and vice-versa.

    protected override void OnBarUpdate()
    {
    if (BarsInProgress != 0)
    return;

    if (CurrentBars[0] < 1)
    return;

    // Set 1
    if (Close[0] > MAX(High, length)[1])
    {
    EnterShort();
    }

    // Set 2
    if (Close[0] < MIN(Low, length)[1])
    {
    EnterLong();
    }

    }

    #2
    Hello omermirza,

    Thank you for the post.

    When you say it does not stay in sync what specifically are you referring to? Are you seeing that it is reversing the position instead of waiting for a target to fill?

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      It did not close my long position - it just left it open. I have a long position in my broker and a short position in Ninjatrader. And the strategy says "False" under Sync.

      Comment


        #4
        Hello omermirza,

        The strategy has an independent position from the account, did you manually enter a position on the account before starting the strategy? If so the strategy by default won't know about that and may start out of sync from the account. Your strategy will process historical bars and enter historical positions before entering realtime. if the strategy had entered short before realtime but the account was already long then it would be out of sync.

        The easiest solution is to start with the account flat. If you are specifically trying to assume the account position then you would need to manually program the script to utilize the PositionAccount object and its position and if wanted the IsAdoptAccountPosition.

        https://ninjatrader.com/support/help..._positions.htm

        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          No, I did not enter any manual position. The strategy was working fine and was in sync for about a day and then went out of sync by itself. Nothing was done on my end.

          Comment


            #6
            Hello omermirza,

            Had you disabled and re enabled the strategy or seen a connection loss?

            If the sync is false that means the strategy became out of sync with the account. To find out more about why that is you would need to use the details from your account statement to see what that order that was in comparison to the strategies performance report.

            I look forward to being of further assistance.
            JesseNinjaTrader Customer Service

            Comment


              #7
              There was no connection loss and the strategy was not disabled/enabled. I don't think this is possible with NinjaTrader, I think you need to have one strategy for long and one for short.

              Comment


                #8
                Hello omermirza,

                Having two separate strategies will cause the sync to be false. A strategy only knows about orders and positions it made.

                I look forward to being of further assistance.
                JesseNinjaTrader Customer Service

                Comment


                  #9
                  I mean with two different accounts. I've never been able to get this type of strategy to work with ninjatrader, one which always stays in the market, long or short.

                  Comment


                    #10
                    Hello omermirza,

                    A single strategy can only use one account at a time, it could however stay long or short in that market for any period of time it runs without interruption.

                    I look forward to being of further assistance.
                    JesseNinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Stanfillirenfro, Today, 07:23 AM
                    2 responses
                    9 views
                    0 likes
                    Last Post Stanfillirenfro  
                    Started by rexsole, Today, 08:39 AM
                    2 responses
                    6 views
                    0 likes
                    Last Post NinjaTrader_Erick  
                    Started by cmtjoancolmenero, Yesterday, 03:58 PM
                    6 responses
                    29 views
                    0 likes
                    Last Post NinjaTrader_ChelseaB  
                    Started by gbourque, Today, 06:39 AM
                    2 responses
                    14 views
                    0 likes
                    Last Post gbourque  
                    Started by trilliantrader, Yesterday, 03:01 PM
                    3 responses
                    31 views
                    0 likes
                    Last Post NinjaTrader_Clayton  
                    Working...
                    X