Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

does NT7 offer similar function of iMAOnArray from MT4?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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");

    #2
    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.
    Adam P.NinjaTrader Customer Service

    Comment


      #3
      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); }

      Comment


        #4
        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.
        Adam P.NinjaTrader Customer Service

        Comment


          #5
          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.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          61 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          40 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          21 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          23 views
          0 likes
          Last Post TheRealMorford  
          Started by Mindset, 02-28-2026, 06:16 AM
          0 responses
          51 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Working...
          X