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

Indicator within Indicator.. Slow. Too many calculations?

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

    Indicator within Indicator.. Slow. Too many calculations?

    Hi

    I am building an inidcator that uses the last 3 Zig Zag Highs and Lows... I have constructed a simple loop at the beginning of my indicator that will update the ZZ points and store them in an array. (see below for loop code)

    The issue is that the indicator takes about 10 to 15 seconds to load on my 1 minute chart and i cant work out why...

    I suspect it may be because everytime this loop checks, the Zig Zag indicator has to run from beginning to end (or at least from beginning up until the point necessary)..... Therefor making this way of calling the ZZ to find the points to do the same calculations over and over again....

    Can anyone confirm that my suspicions are correct and maybe offer a solution? If i am correct, then the only answer i can think of is to add my code into the ZZ indicator, but i would rather keep them separate.

    Thanks in advance for any kind help.


    for (int x = 3; x >= 1; x--)
    {

    int zzLBar = ZigZag(DeviationType.Points, zZDeviation1, true).LowBar(0,x,100);
    int zzHBar = ZigZag(DeviationType.Points, zZDeviation1, true).HighBar(0,x,100);
    zzLow[x] = Low[zzLBar];
    zzHigh[x] = High[zzHBar];
    zzLB[x] = zzLBar;
    zzHB[x] = zzHBar;

    }

    #2
    Hi Marty, yes from your description I would also believe the loop / zz point storage would lead to the performance 'hit' you've seen. It might be quicker to simply update the points as they are formed / confirmed in the orignal indicator.

    What would also of course contribute is the amount of data loaded, so please keep an eye on your lookback settings for the data series this is applied to.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Thanks again Bertrand.

      Can strategies be used to display data in real time on screen?

      Eg. Could I code a strategy that uses the Add() function to display the zig zag and then put my code in there that could then display my calculated lines on the chart............ Or cannot strategies be used like this?

      Comment


        #4
        Yes, Strategies could Add() an indicator for display / visualization benefits:



        For then plotting strategy calculated values you could use the Strategy Plot technique shown here -

        When running a strategy on a chart you may find the need to plot values onto a chart. If these values are internal strategy calculations that are difficult to migrate to an indicator, you can use the following technique to achieve a plot. NinjaTrader 8 With NinjaTrader 8 we introduced strategy plots which provide the ability


        However there are some limitations with this technique, so for your setup working this directly from the original indicator and storing references values as they are found would be likely the best way to proceed.
        BertrandNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by DJ888, 04-16-2024, 06:09 PM
        6 responses
        18 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Started by Jon17, Today, 04:33 PM
        0 responses
        1 view
        0 likes
        Last Post Jon17
        by Jon17
         
        Started by Javierw.ok, Today, 04:12 PM
        0 responses
        6 views
        0 likes
        Last Post Javierw.ok  
        Started by timmbbo, Today, 08:59 AM
        2 responses
        10 views
        0 likes
        Last Post bltdavid  
        Started by alifarahani, Today, 09:40 AM
        6 responses
        41 views
        0 likes
        Last Post alifarahani  
        Working...
        X