Announcement

Collapse
No announcement yet.

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 Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        599 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        344 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        103 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        558 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        557 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X