Announcement

Collapse
No announcement yet.

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 CarlTrading, 03-31-2026, 09:41 PM
      1 response
      152 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      89 views
      1 like
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      131 views
      2 likes
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      127 views
      1 like
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      107 views
      0 likes
      Last Post CarlTrading  
      Working...
      X