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

CalculateOnBarClose in live trading

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

    CalculateOnBarClose in live trading

    I have an issue with CalculateOnBarClose.


    I am using inside bar to trigger entry. The current bar [0] is being eventuated to see if it finishes as an inside bar.


    I set CalculateOnBarClose = true.


    When backtested, the strategy works perfectly, submitting entries as desired. However, when the strategy goes live, it evaluates the current bar still in painting and submit stop orders immediately before the [0] bar completes. I can only conclude the CalculateOnBarClose = true has no effect in live trading.


    The pieces of code are pasted to demo the logic.

    Any suggestions are welcome.


    protectedoverridevoid Initialize()
    {


    … .......

    CalculateOnBarClose = true;
    }


    protectedoverridevoid OnBarUpdate()
    {
    ....

    if (High[0]<=High[1] && Low[0]>=Low[1])
    {
    lowTrigger = Low[1];
    highTrigger = High[1];
    entryOrder=EnterLongStop(3*minUnits,highTrigger+1*TickSize,"Long1");

    }
    ....
    }

    #2
    You may need to remove the CalculateOnBarClose = true statement from the indicator and then set the CalculateOnBarClose = false for the strategy. You will then need to rework the strategy code to check 1 bar ago once the first tick of a new bar arrives. It was confusing for me until I understood the process. Now everything works as expected.

    Comment


      #3
      Your way works. Thanks a lot.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by f.saeidi, Today, 10:19 AM
      0 responses
      2 views
      0 likes
      Last Post f.saeidi  
      Started by kujista, Today, 06:23 AM
      4 responses
      14 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by traderqz, Yesterday, 09:06 AM
      2 responses
      16 views
      0 likes
      Last Post traderqz  
      Started by traderqz, Today, 12:06 AM
      3 responses
      6 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by RideMe, 04-07-2024, 04:54 PM
      5 responses
      28 views
      0 likes
      Last Post NinjaTrader_BrandonH  
      Working...
      X