• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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

            http://ninjatrader.com/support/helpG...htsub=firstbar

            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 johnnybegoode, Today, 07:02 PM
                  0 responses
                  4 views
                  0 likes
                  Last Post johnnybegoode  
                  Started by YevhenShynkarenko, Today, 05:02 PM
                  1 response
                  11 views
                  0 likes
                  Last Post YevhenShynkarenko  
                  Started by lahabatha, Today, 04:42 PM
                  0 responses
                  8 views
                  0 likes
                  Last Post lahabatha  
                  Started by explorer101, Today, 03:39 PM
                  1 response
                  10 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Started by faisamtrader, Today, 03:32 PM
                  1 response
                  12 views
                  0 likes
                  Last Post NinjaTrader_Jesse  
                  Working...
                  X