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

Optimize indicator with "IF"

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

    Optimize indicator with "IF"

    Hi all,
    I would like to know in a 1-minute chart the total of the three previous candles at 15:33 and that at 22:00 that data will be erased.
    I have tried with an "if" but it takes a long time to load the chart and it crashes....
    Can you help me how it could be programmed in another way so as not to use so many resources?
    Thank you

    if (ToTime(Time[1]) == 153300)
    {
    vol= VOL()[1]+VOL()[2]+VOL()[3];
    }

    else if (ToTime(Time[1]) == 220000)
    {
    vol= 0;
    }

    #2
    Hello anmir55,

    Are you getting an index error on the Log tab of the Control Center?
    Hello, I want to create an indicator that show data in a chart but calculate in other charttime different to the time of the chart where is showed. For example:


    Is CurrentBar greater than 3?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello, there iisn't error in the control center and the Currentbar is at 5. I have this indicator in 4 charts and each chart with 4 days of history and of course it takes a long time to load...it was in case there is a way to program so that be faster.

      Comment


        #4
        Hello anmir55,

        The suggested code does not appear to be cpu intensive.
        To confirm, there is no other code in the script?

        Make a copy of this workspace, remove all other charts, and remove all other indicators from the chart. Be sure only this one script is being tested.

        Further test the SMA by itself. Does the SMA take a shorter amount of time to load on the same data (same chart with no other indicators applied)?

        I would not know of any other way of switching logic without using if statements.
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by RubenCazorla, 08-30-2022, 06:36 AM
        3 responses
        77 views
        0 likes
        Last Post PaulMohn  
        Started by f.saeidi, Yesterday, 12:14 PM
        9 responses
        23 views
        0 likes
        Last Post f.saeidi  
        Started by Tim-c, Today, 03:54 AM
        0 responses
        3 views
        0 likes
        Last Post Tim-c
        by Tim-c
         
        Started by FrancisMorro, Today, 03:24 AM
        0 responses
        4 views
        0 likes
        Last Post FrancisMorro  
        Started by Segwin, 05-07-2018, 02:15 PM
        10 responses
        1,772 views
        0 likes
        Last Post Leafcutter  
        Working...
        X