PDA

View Full Version : Are multi-version compatible indicators possible ?


gomifromparis
10-11-2009, 01:25 PM
hi,

Is there an elegant recommended way to create a multi-NT version compatible indicator ?

As some classes have changed,some lines won't compile, so I guess the only way would be to use preprocessing directives in the code. Is there any preprocessor symbol defined that would allow things like #if NT7
some line of code for NT7
#else
some line of code for NT6.5
#endif

NinjaTrader_Ray
10-11-2009, 02:18 PM
hi,

Is there an elegant recommended way to create a multi-NT version compatible indicator ?

As some classes have changed,some lines won't compile, so I guess the only way would be to use preprocessing directives in the code. Is there any preprocessor symbol defined that would allow things like #if NT7
some line of code for NT7
#else
some line of code for NT6.5
#endif


What would your goal be in doing this? Apart from the code breaking changes which would require two versions of your script if the script utlized breaking code...The underlying fundamental logic between 6.5 and 7 is essentially the same.

gomifromparis
10-11-2009, 02:42 PM
we'll I'd like to be able to maintain only one source file of an indicator that would work on NT6.5 and NT7.

For instance, in NT6.5 I use ChartControl.GetXByBarIdx(index), ChartControl.ChartControl.BarOutlinePen and TickSize.

in NT7, you have to use ChartControl.GetXByBarIdx(BarsArray[0],index), the BarOutlinePen is elsewhere in the Dataseries and TickSize must be accessed via Instrument.MasterInstrument.TickSize.

So either I duplicate the code and have to maintain 2 version of the source, one for NT6.5 and one for NT7, or either I am able to use preprocessing instructions to deal with those very specific changes and write:

#if NT7
x=ChartControl.GetXByBarIdx(BarsArray[0],index);
pen=WhereverTheNT7PensAre.Location();
ts= Instrument.MasterInstrument.TickSize;
#else
x= ChartControl.GetXByBarIdx(index);
pen=ChartControl.ChartControl.BarOutlinePen;
ts=TickSize;
#endifFor that to work I think that a /define NT7 would have to be sent on the command line to the compiler when compiling indicators, but maybe you do it already with another symbol name.

NinjaTrader_Dierk
10-11-2009, 11:27 PM
I edited my post, since I reconsidered your suggestion:

Next NT7 update will support the pre-compiler switch "NT7" which would allow you doing what you wanted to do. In addition we will amend the code generator which generated the "don't touch" region at the very bottom of the indicator files so
- you could use NT7 to generate your NT7 and NT6.5 compatible indicators
- however, you can NOT use NT6.5 to generate NT7 indicators. They will compile in NT7 but will exhibit unexpected behavior in some situations. You should NOT do this.

gomifromparis
10-12-2009, 02:16 AM
OK, thanks very much !