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

CurrentBar and BarsRequiredToTrade

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

    CurrentBar and BarsRequiredToTrade

    Hi, I had a strange issue today
    I have a strategy running which has BarsRequiredToTrade set to 50. I have this Strategy running from the Control Center and not from the Chart. The TimeFrame is Daily and Calculate set to OnPriceChange. Though the condition to go Long/Short was satisfied, the Strategy was not triggering the trades. Analysing it, I noticed that CurrentBar of the Daily Candle is 35 so obviously the strategy was not going past if( CurrentBar < BarsRequiredToTrade) return; condition(First line of the strategy). So would like to know why was CurrentBar not going past 35 ? If I manually load up a chart , I can load more than 100 Historical Bars.


    Thanking you,
    SurenForex



    #2
    Hello SurenForex,

    Thanks for your post.

    After replying to your post I will be moving this thread to the NinjaTrader8 strategy Forum.

    If I understand correctly you directly installed the strategy in the Strategies tab of the NinjaTrader8 Control center. When you install the strategy in this manner, you need to specify not just the bar type (day) but also the "Days to load". Please check the parameter Days to load and adjust if/as needed.

    When you add a strategy to the chart, the strategy adopts the chart's primary series so you do not have to set that when applying to a chart that already has data.



    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Sorry could not get back to you on this. After your feedback, I set the Days to Load to 100 but still the CurrentBar count stops at 35 and that is the reason it doesn't go past the CurrentBar < BarsRequiredToTrade condition. I have tried to enable the strategy from the chart and it works without any issues since its able to load more than 100 Bars on the Chart.

      So not able to figure out what is the issue running it from the Control Center . Need your help.

      Comment


        #4
        Hello SurenForex,

        Thanks for your reply, no worries.

        I would add a print statement that is just above your current bars check to print out the date-time of the bar along with the current bar number: Print (Time[0] + "CurrentBar = "+CurrentBar);

        Placing it above the current bar check should show all of the bars that the script has access to.
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Thank you for your response. I exactly did what you have suggested when I mentioned the count stops at 35. The good news is I increased the Days To Load from 100 to 500 and it auto magically started working.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by kaywai, 09-01-2023, 08:44 PM
          5 responses
          601 views
          0 likes
          Last Post NinjaTrader_Jason  
          Started by xiinteractive, 04-09-2024, 08:08 AM
          6 responses
          22 views
          0 likes
          Last Post xiinteractive  
          Started by Pattontje, Yesterday, 02:10 PM
          2 responses
          19 views
          0 likes
          Last Post Pattontje  
          Started by flybuzz, 04-21-2024, 04:07 PM
          17 responses
          230 views
          0 likes
          Last Post TradingLoss  
          Started by agclub, 04-21-2024, 08:57 PM
          3 responses
          17 views
          0 likes
          Last Post TradingLoss  
          Working...
          X