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

if historical return

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

    if historical return

    I am confused when using "wait until flat position" plus sync position etc.

    Given that I will all ways use the SYNC position TRUE (my strategy all ways carry an open posisition),
    In case I use if (historical) return; along with SYNC TRUE I can be sure :
    1-system will not generate any past position.
    2-system will understand I am longo or short (due to sync) and respects all stop gains and losses, exit orders, etc.

    Am I correct?

    #2
    Hello dafonseca,

    Yes, by having if (Historical) return; in your script this ensures that there are no historical orders which causes your strategy to start flat.

    By having the Sync Account set to true, the first order should cause your account position to match your strategy position.

    (This will not cancel any working orders that were previously placed either manually or by this or another script. This will only change the position to match the strategy position.)
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      I am still in doubt, Supposing this example:

      Strategy has today entered a 1 NQ 06-15 short position.
      System will be turned off at midnight (IB disconnect every day).

      tomorrow in the morning I run the same position.

      without using if (historical) return;
      I use SYNC TRUE, strategy will consider the short position and not short it again.

      using if (historical) return ;
      I use SYNC TRUE the system will recognize the short and only act in case of exitshort or set stop gain and loss a new order will be triggered.

      So, in case of SYNC TRUE using if (historical) return makes no differnce. Am i right/

      Comment


        #4
        Hello dafonseca,

        With if (Historical) return; there will not be any historical trades. This means that your strategy will start flat.

        If the Sync is off, the account will not be synced to the first live trade. If the Sync is on, the account will be synced to the first live trade.

        So, changing the Account Sync settings will cause different behavior if the account is not flat and this strategy is starts flat.

        However, when you say you use Sync true to recognize the short position, this is not making sense to me. If your strategy is starting flat, there is no short position to sync.

        The account is synced to the strategies position, your strategy will never be synced to the account position.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          I am getting your point. If there is a short position to be synced the strategy is short on historical 'terms'.
          my question would be :


          my position this morning is short, meaning the strategy is on short position (not flat, or long).
          Butif I do not Sync position if (historical) return will force the system to not recognize any position until it becomes live.
          In the other hand, if I Sync the short position, if (historical) return; let the strategy to recognize this short position, therefore some short term historical is recognized.
          My point is, in order to understand:. When SYNC is true if( historical) return; performs in a different way as if it was not using SYNC.

          Comment


            #6
            Hi Chelsea

            Is there any effective difference between:

            Code:
            if (Historical) return;
            and

            Code:
            if (CurrentBar < Count - 2) return;
            I've assumed that both these methods exclude all completed bars except the most recent one but do they accomplish precisely the same thing or is there a subtle difference?

            I'd be very interested to read your reply.

            Thanks.

            Comment


              #7
              Hello arbuthnot,

              That should achieve the same behavior as if (Historical) return;. The Count will be the bar total of historical data, until the first real-time bar. At that time it will start to increment. So that code should work fine.


              dafonseca,

              I'm still not quite understanding. You say the strategy has if (Historical) return; at the beginning of OnBarUpdate. You also say that the strategy is starting with a short position. If you are talking about a historical position, this is impossible. The point of using if (Historical) return; is so that the strategy does not start with a historical position.

              The Sync should cause your account to match the strategy position after the first live trade.

              Lets say your account is Long 5 before you start the strategy.
              Then the strategy is started and a few minutes later the strategy takes its first real-time trade.
              If the Sync is on, the account will be brought to Long 1 by submitting an order to sell 4.
              If the Sync is off, the account will be brought to Long 6 by submitting an order to buy 1.
              Chelsea B.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by fx.practic, 10-15-2013, 12:53 AM
              5 responses
              5,406 views
              0 likes
              Last Post Bidder
              by Bidder
               
              Started by Shai Samuel, 07-02-2022, 02:46 PM
              4 responses
              98 views
              0 likes
              Last Post Bidder
              by Bidder
               
              Started by DJ888, Yesterday, 10:57 PM
              0 responses
              8 views
              0 likes
              Last Post DJ888
              by DJ888
               
              Started by MacDad, 02-25-2024, 11:48 PM
              7 responses
              160 views
              0 likes
              Last Post loganjarosz123  
              Started by Belfortbucks, Yesterday, 09:29 PM
              0 responses
              9 views
              0 likes
              Last Post Belfortbucks  
              Working...
              X