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

running strategy on market replay

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

    running strategy on market replay

    my stratgy should start buy sell from second bar of session onwards.it works perfect in strategy analyser but in market replay it starts buying selling on fisrt bar of session onwards.
    please advise whats wrong here...
    Code:
      protected override void OnBarUpdate()
            {
                if (Historical)
             return; 
                
                if (BarsInProgress != 0)
                    return;
                    
                    
                    
                    if (Bars.FirstBarOfSession)
                    return;    
                
                if(    Bars.BarsSinceSession >= 1    )
                    
                {
                    
                
                    // Condition set 1
                    if (
                        Open[0] > Close[0] 
                        
                        )
                    {
                        EnterShort(DefaultQuantity, "");
                    }
    
                    // Condition set 2
                    else if (
                        Open[0] < Close[0] 
                        
                        )
                    {
                        EnterLong(DefaultQuantity, "");
                    }
            }
                
            }

    #2
    Hello easyfying,

    Thank you for your post.

    Are you using CalculateOnBarClose set to true or false when running on Market Replay?
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      thanks for taking note of my problem.here is my Initialize code
      Code:
      protected override void Initialize()
              {
                  TraceOrders = true;
                  CalculateOnBarClose = true;
              }

      Comment


        #4
        easyfying,

        What time interval on the chart are you running this? Minute, Tick, etc

        Can you provide a screenshot or the output of the first order being submitted before the 3rd bar for the FirstBarOfSession?
        Cal H.NinjaTrader Customer Service

        Comment


          #5
          its a 15 min fdax chart .default session settings.
          Attached Files

          Comment


            #6
            easyfying,

            I have tested your OnBarUpdate on my end and I am not running into the same issue.

            I recommend that you add Print()'s to your if statements for the BarsSinceSession().

            This is obviously becoming true and we need to see where from.

            Print(Bars.BarsSinceSession);
            Cal H.NinjaTrader Customer Service

            Comment


              #7
              the logic is working in strategy analyser but it fails in market replay.
              here r two images one from strategy analyser and second from market replay.
              i also tried instrument resetting.but nothing seems to work.
              Attached Files

              Comment


                #8
                Easyfying,

                Would be willing to send me your strategy so I can test this on my end?
                Cal H.NinjaTrader Customer Service

                Comment


                  #9
                  objective of strategy is to go long or short starting from second bar onwards
                  Attached Files

                  Comment


                    #10
                    easyfying,

                    I am not able to reproduce the issue with your script on my end.

                    At this point I would like you to send me a note to platform support so we can setup a remote session

                    Help -> Mail to support

                    Put Attn Cal in the subject and reference this thread in the body
                    Cal H.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by arvidvanstaey, Today, 02:19 PM
                    4 responses
                    11 views
                    0 likes
                    Last Post arvidvanstaey  
                    Started by samish18, 04-17-2024, 08:57 AM
                    16 responses
                    60 views
                    0 likes
                    Last Post samish18  
                    Started by jordanq2, Today, 03:10 PM
                    2 responses
                    9 views
                    0 likes
                    Last Post jordanq2  
                    Started by traderqz, Today, 12:06 AM
                    10 responses
                    18 views
                    0 likes
                    Last Post traderqz  
                    Started by algospoke, 04-17-2024, 06:40 PM
                    5 responses
                    47 views
                    0 likes
                    Last Post NinjaTrader_Jesse  
                    Working...
                    X