NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


Go Back   NinjaTrader Support Forum > Application Technical Support > Miscellaneous Support

Miscellaneous Support Miscellaneous support issues.

Reply
 
Thread Tools Display Modes
Old 06-30-2012, 12:46 PM   #1
futuretrader8
Junior Member
 
Join Date: Feb 2011
Posts: 29
Thanks: 3
Thanked 1 time in 1 post
Question does NT7 offer similar function of iMAOnArray from MT4?

double iMAOnArray( double array[], int total, int period, int ma_shift, int ma_method, int shift) Calculation of the Moving Average on data stored in a numeric array. Unlike iMA(...), the iMAOnArray function does not take data by symbol name, timeframe, the applied price. The price data must be previously prepared. The indicator is calculated from left to right. To access to the array elements as to a series array (i.e., from right to left), one has to use the ArraySetAsSeries function. Parameters:
array[] - Array with data. total - The number of items to be counted. 0 means whole array. period - Averaging period for calculation. ma_shift - MA shift ma_method - MA method. It can be any of the Moving Average method enumeration value. shift - Index of the value taken from the indicator buffer (shift relative to the current bar the given amount of periods ago). Sample:
double macurrent=iMAOnArray(ExtBuffer,0,5,0,MODE_LWMA,0); double macurrentslow=iMAOnArray(ExtBuffer,0,10,0,MODE_LWM A,0); double maprev=iMAOnArray(ExtBuffer,0,5,0,MODE_LWMA,1); double maprevslow=iMAOnArray(ExtBuffer,0,10,0,MODE_LWMA,1 ); //---- if(maprev<maprevslow && macurrent>=macurrentslow) Alert("crossing up");
futuretrader8 is offline  
Reply With Quote
Old 06-30-2012, 12:57 PM   #2
NinjaTrader_AdamP
NinjaTrader Customer Service
 
NinjaTrader_AdamP's Avatar
 
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
Default

Futuretrader,

Yes, this is indicator of indicator essentially.

For example, you could use :

SMA ( MyIndicator(input), 16)

Every indicator allows you to specify the input series to be something other than the default chart series as defined by an overridden method.
NinjaTrader_AdamP is offline  
Reply With Quote
Old 07-01-2012, 11:34 AM   #3
futuretrader8
Junior Member
 
Join Date: Feb 2011
Posts: 29
Thanks: 3
Thanked 1 time in 1 post
Question

thanks for the info. tried to find equivalent function in NT for the following but failed. just wonder if there is one.

int IndicatorCounted( ) The function returns the amount of bars not changed after the indicator had been launched last. The most calculated bars do not need any recalculation. In most cases, same count of index values do not need for recalculation. The function is used to optimize calculating.

Note: The latest bar is not considered to be calculated and, in the most cases, it is necessary to recalculate only this bar. However, there occur some boundary cases where custom indicator is called from the expert at the first tick of the new bar. It is possible that the last tick of the previous bar had not been processed (because the last-but-one tick was being processed when this last tick came), the custom indicator was not called and it was not calculated because of this. To avoid indicator calculation errors in such situations, the IndicatorCounted() function returns the count of bars minus one. Sample:
int start() { int limit; int counted_bars=IndicatorCounted(); //---- check for possible errors if(counted_bars<0) return(-1); //---- the last counted bar will be recounted if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; //---- main loop for(int i=0; i<limit; i++) { //---- ma_shift set to 0 because SetIndexShift called abowe ExtBlueBuffer[i]=iMA(NULL,0,JawsPeriod,0,MODE_SMMA,PRICE_MEDIAN,i) ; ExtRedBuffer[i]=iMA(NULL,0,TeethPeriod,0,MODE_SMMA,PRICE_MEDIAN,i ); ExtLimeBuffer[i]=iMA(NULL,0,LipsPeriod,0,MODE_SMMA,PRICE_MEDIAN,i) ; } //---- done return(0); }
futuretrader8 is offline  
Reply With Quote
Old 07-01-2012, 12:15 PM   #4
NinjaTrader_AdamP
NinjaTrader Customer Service
 
NinjaTrader_AdamP's Avatar
 
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
Default

Futuretrader,

I am not aware of any function that does the same thing here. OnBarUpdate() is called for each bar (or each tick) only once, but there is no repainting in Ninjatrader without specifically going back and doing so. Basically the plot's data series get set once per bar (or per tick) and never again so I am not sure where this function would be useful.
NinjaTrader_AdamP is offline  
Reply With Quote
Old 07-01-2012, 01:27 PM   #5
koganam
Senior Member
 
Join Date: Feb 2008
Location: Durham, North Carolina, USA
Posts: 3,201
Thanks: 24
Thanked 1,228 times in 999 posts
Send a message via Skype™ to koganam
Default

Quote:
Originally Posted by futuretrader8 View Post
thanks for the info. tried to find equivalent function in NT for the following but failed. just wonder if there is one.

int IndicatorCounted( ) The function returns the amount of bars not changed after the indicator had been launched last. The most calculated bars do not need any recalculation. In most cases, same count of index values do not need for recalculation. The function is used to optimize calculating.

Note: The latest bar is not considered to be calculated and, in the most cases, it is necessary to recalculate only this bar. However, there occur some boundary cases where custom indicator is called from the expert at the first tick of the new bar. It is possible that the last tick of the previous bar had not been processed (because the last-but-one tick was being processed when this last tick came), the custom indicator was not called and it was not calculated because of this. To avoid indicator calculation errors in such situations, the IndicatorCounted() function returns the count of bars minus one. Sample:
int start() { int limit; int counted_bars=IndicatorCounted(); //---- check for possible errors if(counted_bars<0) return(-1); //---- the last counted bar will be recounted if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; //---- main loop for(int i=0; i<limit; i++) { //---- ma_shift set to 0 because SetIndexShift called abowe ExtBlueBuffer[i]=iMA(NULL,0,JawsPeriod,0,MODE_SMMA,PRICE_MEDIAN,i) ; ExtRedBuffer[i]=iMA(NULL,0,TeethPeriod,0,MODE_SMMA,PRICE_MEDIAN,i ); ExtLimeBuffer[i]=iMA(NULL,0,LipsPeriod,0,MODE_SMMA,PRICE_MEDIAN,i) ; } //---- done return(0); }
An NT indicator is calculated on every bar, unless you specifically exclude calculation using a filter of some kind; in which case, you can count those bars as part of the filter conditions themself.
koganam is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
error/bug in add() function in initialise function PolarBear Strategy Development 15 10-29-2011 06:42 AM
MouseMove() or similar function David Lean Indicator Development 1 05-09-2011 05:51 AM
Does NT7 have this function? Avn_0903 Miscellaneous Support 1 04-20-2010 03:01 AM
NT7 function suggestions. protran Suggestions And Feedback 1 10-29-2009 02:22 AM
Bid/Offer gbrandme Miscellaneous Support 3 03-09-2009 04:56 PM


All times are GMT -6. The time now is 08:05 AM.