Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Using EMA in an array

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

    Using EMA in an array

    Hi ,

    I am trying to use EMA function to enter values in an array in the following way
    for (i=-24 ;i==0;i++)
    {
    EMA_val[i]=EMA(480)[i];
    EMA_sum[1]+=EMA_val[i];
    }

    getting an error saying that I am trying to use a field like a mathod , I looked in documantion and I am using the script as I should.

    Can someone explain what I am doing worng.

    Thanks

    #2
    Hello,

    Since you are using [indx], I assume you are trying to enter values that you can then access later via bar references. Here is a better way to do it:
    DenNinjaTrader Customer Service

    Comment


      #3
      Hi Ben,

      I tried to do what you instructed but , I am stil l getting the same error when compiling. I attached a screen shot of what I see.

      Thanks.
      Attached Files

      Comment


        #4
        Hello Sharkie,

        Ben's suggestion was to create a DataSeries object.
        This tutorial may help illustrate this concept.

        Create a data series and you could then run sum method against the data series you created.



        Using arrays is outside of NinjaScript support. I did notice you're trying to access negative index values. If you pursue this array approach, this is one thing to change. Current bar is accessed with index [0]. The bar prior to this (on the left) is accessed with [1]
        Close[0]
        Close[1]
        Ryan M.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by TradeForge, 04-19-2024, 02:09 AM
        2 responses
        28 views
        0 likes
        Last Post TradeForge  
        Started by aprilfool, 12-03-2022, 03:01 PM
        3 responses
        327 views
        0 likes
        Last Post NinjaTrader_Adrian  
        Started by giulyko00, Today, 12:03 PM
        1 response
        5 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Started by f.saeidi, Today, 12:14 PM
        1 response
        5 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by AnnBarnes, Today, 12:17 PM
        1 response
        2 views
        0 likes
        Last Post NinjaTrader_Zachary  
        Working...
        X