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 Kaledus, Today, 01:29 PM
        1 response
        4 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by frankthearm, Yesterday, 09:08 AM
        13 responses
        45 views
        0 likes
        Last Post frankthearm  
        Started by PaulMohn, Today, 12:36 PM
        2 responses
        16 views
        0 likes
        Last Post PaulMohn  
        Started by Conceptzx, 10-11-2022, 06:38 AM
        2 responses
        53 views
        0 likes
        Last Post PhillT
        by PhillT
         
        Started by yertle, Yesterday, 08:38 AM
        8 responses
        37 views
        0 likes
        Last Post ryjoga
        by ryjoga
         
        Working...
        X