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

Triggering OnBarUpdate when their is no more bars

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

    Triggering OnBarUpdate when their is no more bars

    Hi,

    I use Kinetick real time data and I'm writing a strategy that use EOD data.
    Each morning I'm analyzing the data from yesterday close and produce a report.
    Every day is working correctly but on Saturday or Sunday when I want to analyze the data for Friday close I don't get the report, only on Monday morning I can view the data of Friday.
    Is there a way so call OnBarUpdate although their is no more data to trigger the call normally?

    Tx in advance!

    #2
    Hello freewind,
    Since I am not aware of the exact code you are using, I can give you a couple of directions.

    If you are using CalculateOnBarClose = true, then on Saturday and Sunday, make the same set to false, this will let the strategy to calculate on the last bar too.

    If your strategy works one bar behind (like Close[1] instead of Close[0], since you mentioned previous day), then you may put a check like this

    Code:
    if (DateTime.Now.DayOfWeek == DayOfWeek.Saturday || DateTime.Now.DayOfWeek == DayOfWeek.Sunday)
    {
            //COBC should be false, but i still write the additional check
    	if (CalculateOnBarClose = true)
    	{
    		if (BarsArray[0].Count - 2 == CurrentBar)
    		{
    			//print out strategy result
    		}
            }
    	else if (CalculateOnBarClose = false)
    	{
    		if (BarsArray[0].Count - 1 == CurrentBar)
    		{
    			//print out strategy result
    		}
    	}
    }
    This are just some basic ideas, so do build upon the same.

    Please do let me know if I can be of further help.

    Regards,
    Joydeep.
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      Tx Joy,

      But I don't understand what will trigger my strategy on Sunday(before future market opens) to enter the OnBarUpdate().The strategy is running on real time data, not backtest.
      I'm working with Close[0], which on EOD data gives me the last close.

      Comment


        #4
        Hello freewind,
        have you set CalculateOnBarClose to true or false?

        Also you said you are analyzing the data on the weekends, right. Please provide me the details so that I can guide you any further.

        Regards,
        Joydeep.
        JoydeepNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by helpwanted, Today, 03:06 AM
        1 response
        11 views
        0 likes
        Last Post sarafuenonly123  
        Started by Brevo, Today, 01:45 AM
        0 responses
        9 views
        0 likes
        Last Post Brevo
        by Brevo
         
        Started by aussugardefender, Today, 01:07 AM
        0 responses
        5 views
        0 likes
        Last Post aussugardefender  
        Started by pvincent, 06-23-2022, 12:53 PM
        14 responses
        242 views
        0 likes
        Last Post Nyman
        by Nyman
         
        Started by TraderG23, 12-08-2023, 07:56 AM
        9 responses
        387 views
        1 like
        Last Post Gavini
        by Gavini
         
        Working...
        X