Mike, I'm uncertain about how an indicator is called when using it in Testing Mode.
You've said that in Testing Mode, the Calculate() procedure is called once every tick, instead of once every bar as it is in Edit Mode. In this case what does the value of the 'index' argument represent?
My understanding is that the index argument represents the number of the current bar. That would mean that if you had a bar with 35 ticks in it, the Calculate() procedure would be called 35 times, but each time the index argument would remain the same, because the bar would not change until all the ticks for that bar were processed.
I ask because I have an indicator I'm working on which is malfunctioning in Testing Mode and I'm assuming that the index argument is always representing the bar, no matter how many ticks are in that bar. If I'm wrong and the index argument is different for every tick, I'll have to rewrite the indy.
Thanks in advance for your help.
Brian-
Question about indicators in Testing Mode
- Tantalus
- Posts: 302
- Joined: Fri Mar 23, 2007 3:51 pm
- Contact:
Question about indicators in Testing Mode
Tantalus Research - Developing 21st Century Trading Systems.
- Terranin
- Site Admin
- Posts: 833
- Joined: Sat Oct 21, 2006 4:39 pm
Re: Question about indicators in Testing Mode
Tantalus wrote:Mike, I'm uncertain about how an indicator is called when using it in Testing Mode.
You've said that in Testing Mode, the Calculate() procedure is called once every tick, instead of once every bar as it is in Edit Mode. In this case what does the value of the 'index' argument represent?
My understanding is that the index argument represents the number of the current bar. That would mean that if you had a bar with 35 ticks in it, the Calculate() procedure would be called 35 times, but each time the index argument would remain the same, because the bar would not change until all the ticks for that bar were processed.
I ask because I have an indicator I'm working on which is malfunctioning in Testing Mode and I'm assuming that the index argument is always representing the bar, no matter how many ticks are in that bar. If I'm wrong and the index argument is different for every tick, I'll have to rewrite the indy.
Thanks in advance for your help.
Brian-
You understood correctly. When bar changes indicator recalculates on this bar with its index. Basically you will always have index = 0 because only last bar changes.
Hasta la vista
Mike
Mike
-
- Posts: 151
- Joined: Tue Feb 24, 2009 1:03 pm
Brian,
I'm sure Mike will correct me if I'm wrong but there are a couple of exceptions. Whether it will help or not I don't know...
If data already exists in a chart in testing mode and you drop an indicator onto the chart the existing data will be calculated with one tick per bar, using the values at the close of the bar. This means that if you program an indicator to find entries on say, the first tick of a new bar, the results will always be 'inaccurate' if you simply drop the indicator on the chart. You will need to run a live test to ensure that the calculate procedure is executed on every tick.
Yes, basically this is true, but if data already exists in the chart then of course index will begin at bars-1 and move down to zero as the chart is calculated. All new bars will be index zero.
Also, something that has helped me before is to click start test with no indicators on the chart (check box to pause). The chart clears and I stop the test and add my indicators to the blank chart. Once added I start the test again and see how the indicator reacts. Sometimes I've had problems due to some global variable not being reset when the start test button is pressed and the chart clears. A simple test for this would be:
If index = bars-1 then [reset global variables] //We're on first bar so initialise variables
Hope it helps.
Steve
EDIT: Brian, if you are free to post or PM the suspect portion of code I would be happy to take a look
I'm sure Mike will correct me if I'm wrong but there are a couple of exceptions. Whether it will help or not I don't know...
You've said that in Testing Mode, the Calculate() procedure is called once every tick, instead of once every bar as it is in Edit Mode. In this case what does the value of the 'index' argument represent?
If data already exists in a chart in testing mode and you drop an indicator onto the chart the existing data will be calculated with one tick per bar, using the values at the close of the bar. This means that if you program an indicator to find entries on say, the first tick of a new bar, the results will always be 'inaccurate' if you simply drop the indicator on the chart. You will need to run a live test to ensure that the calculate procedure is executed on every tick.
Basically you will always have index = 0 because only last bar changes.
Yes, basically this is true, but if data already exists in the chart then of course index will begin at bars-1 and move down to zero as the chart is calculated. All new bars will be index zero.
Also, something that has helped me before is to click start test with no indicators on the chart (check box to pause). The chart clears and I stop the test and add my indicators to the blank chart. Once added I start the test again and see how the indicator reacts. Sometimes I've had problems due to some global variable not being reset when the start test button is pressed and the chart clears. A simple test for this would be:
If index = bars-1 then [reset global variables] //We're on first bar so initialise variables
Hope it helps.
Steve
EDIT: Brian, if you are free to post or PM the suspect portion of code I would be happy to take a look
- Tantalus
- Posts: 302
- Joined: Fri Mar 23, 2007 3:51 pm
- Contact:
-
- Posts: 151
- Joined: Tue Feb 24, 2009 1:03 pm
Who is online
Users browsing this forum: No registered users and 19 guests