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 saltminer, Yesterday, 01:43 PM
        1 response
        26 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by idude, Today, 05:06 AM
        0 responses
        8 views
        0 likes
        Last Post idude
        by idude
         
        Started by music_p13, 07-05-2025, 11:33 PM
        1 response
        29 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by gubbar924, 03-18-2018, 05:15 PM
        43 responses
        5,482 views
        0 likes
        Last Post ESMC377
        by ESMC377
         
        Started by siqalexcg, 06-30-2025, 08:06 PM
        1 response
        198 views
        0 likes
        Last Post Emma1
        by Emma1
         
        Working...
        X