Question about indicators in Testing Mode

How to create strategies and indicators
Message
Author
User avatar
Tantalus
Posts: 302
Joined: Fri Mar 23, 2007 3:51 pm
Contact:

Question about indicators in Testing Mode

#1 Postby Tantalus » Tue Jun 30, 2009 6:25 pm

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-
Tantalus Research - Developing 21st Century Trading Systems.

User avatar
Terranin
Site Admin
Posts: 833
Joined: Sat Oct 21, 2006 4:39 pm

Re: Question about indicators in Testing Mode

#2 Postby Terranin » Wed Jul 01, 2009 10:27 am

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

dackjaniels
Posts: 151
Joined: Tue Feb 24, 2009 1:03 pm

#3 Postby dackjaniels » Wed Jul 01, 2009 5:33 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...

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 :P

User avatar
Tantalus
Posts: 302
Joined: Fri Mar 23, 2007 3:51 pm
Contact:

#4 Postby Tantalus » Thu Jul 02, 2009 1:34 pm

I found the prob... just a module level variable used to track past data.. works OK in MT4 but must be converted to an IndexBuffer in FT. I gotta watch closely for that one when making my conversions....
Tantalus Research - Developing 21st Century Trading Systems.

dackjaniels
Posts: 151
Joined: Tue Feb 24, 2009 1:03 pm

#5 Postby dackjaniels » Thu Jul 02, 2009 3:25 pm

Tantalus wrote:I found the prob... just a module level variable used to track past data.. works OK in MT4 but must be converted to an IndexBuffer in FT. I gotta watch closely for that one when making my conversions....


Glad you found it :)


Return to “FT API”

Who is online

Users browsing this forum: No registered users and 34 guests