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

Recalculation

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

    Recalculation

    Hi,

    short question, how do i force an indicator to recalculate programmatically?

    Regards and thanks in advance.

    #2
    Hello,

    Thank you for the question.

    There is no built in method for this, so this would be an unsupported item.

    What is the reason that the indicator needs refreshed programmatically?

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hi Jesse,
      i am trying to build an indicator which begins its calculation on the first bar of the current trading session. i then want to select bars manually, which divide the charthistory of the current day in parts, e.g. form bar 0 to 50, then from 50 to 150, a.s.o.and calculate the indicator output between these bars. as these bars will be historical i think i have to force recalculation or does the indicator automatically start from bar 1 when it updates onbarupdate and onmarketdata?

      Comment


        #4
        Hello,

        The indicator will run from bar 0 to the the Current bar or farthest right bar on the chart and then moves into Realtime.

        After it has hit realtime, the historical data would not be looped through again for each iteration so it would only be the current bar being processed.

        You can certainly loop through all the bars again without refreshing, for example you could watch for !Historical which would indicate you are in realtime, once that happens whatever logic you need to do from bar 0 forward could be done in a for loop.

        If this is only from the start of the session, you would likely need to store the bar number for when the session begin is found, and then when needed use that bar as the start bar in logic for the loop.

        You might look into using Count also http://ninjatrader.com/support/helpG...lightsub=Count


        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          I looked at that, Jesse, might work, whould you mind giving me an example ( just the cliffnotes ) how you whould programmatically loop through a amount of bars, and how you whould store the barnumber for the session start, the loop should consider historical and realtime.

          Regards and thanks

          Comment


            #6
            Hello,

            For the looping through the bars, you could accomplish that by using the CurrentBar assuming this is a single series script, here is an example:

            Code:
            for(int i = 0; i < CurrentBar; i++)
            {
            	//go forwards from 0 to current bar
            	double closeValue = Close[i];
            	Print(closeValue);
            }
            This would only loop until the current bar so this way would prevent any sort of Index error if it were to be used historically, but keep in mind that if this were to be used historically it would loop X number of times for Every bar which may make the chart load very slow.

            A better use of the loop is in Realtime which would only need changed to the following:

            Code:
            if(!Historical)
            {
            	for(int i = 0; i < CurrentBar; i++)
            	{
            		//go forwards from 0 to current bar
            		double closeValue = Close[i];
            		Print(closeValue);
            	}
            }
            The same apply's if you did not want to loop through all but just X amount back from the current bar

            Code:
            if(!Historical)
            {
            	for(int i = CurrentBar; i > CurrentBar - 100; i--)
            	{
            		//go backwards from CurrentBar to CurrentBar - 100 bars
            		double closeValue = Close[i];
            		Print(closeValue);
            	}
            }
            For the storing of the session start, you could use the property Bars.FirstBarOfSession



            A simply condition could create this, something like the following:

            Code:
            if(Bars.FirstBarOfSession)
            {
            storedBar = CurrentBar;
            }
            the int variable storedBar would need to be declaired in the variables section near the top or outside of the OnBarUpdate method.

            The historical and realtime check is simply the property Historical, it is used just as shown in the above examples.

            I look forward to being of further assistance.
            JesseNinjaTrader Customer Service

            Comment


              #7
              Hi, Jesse, could we discuss this further via email, might send you some code a.s.o.

              Regards

              Comment


                #8
                Hello,

                You are free to email us at platform support @ ninjatrader.com any time you need assistance so please do so if you would like to communicate through email instead.

                I look forward to being of further assistance.
                JesseNinjaTrader Customer Service

                Comment


                  #9
                  Send email with subject thread.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by TraderBCL, Today, 04:38 AM
                  2 responses
                  8 views
                  0 likes
                  Last Post TraderBCL  
                  Started by martin70, 03-24-2023, 04:58 AM
                  14 responses
                  105 views
                  0 likes
                  Last Post martin70  
                  Started by Radano, 06-10-2021, 01:40 AM
                  19 responses
                  606 views
                  0 likes
                  Last Post Radano
                  by Radano
                   
                  Started by KenneGaray, Today, 03:48 AM
                  0 responses
                  4 views
                  0 likes
                  Last Post KenneGaray  
                  Started by thanajo, 05-04-2021, 02:11 AM
                  4 responses
                  471 views
                  0 likes
                  Last Post tradingnasdaqprueba  
                  Working...
                  X