Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Calculation Question about compiler.

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

    Calculation Question about compiler.

    The question is in Regards to Both NT7 and NT8. My Calculation is much more complicated that this and very slow. I am trying to speed it up
    It is of the form.

    WMA(A) == 0 ? 0 : B / WMA(A)

    Is WMA(A) calculated a second time for B / WMA(A) in other words is the Compiler smart enough to Re-substitute WMA(A) it already calculated.
    or Should I.

    #2
    Hello JerryWar,

    Thank you for your note.

    It would always be suggested that you save the value of WMA(A) to a variable to ensure that it is not run a second time in your statement.

    You could do the following,

    double xWmaVar = WMA(A); //Save the value to a variable

    xWmaVar == 0 ? 0 : B / xWmaVar; //Pass the variable into your statement.

    Please let us know if you need further assistance.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      Alan
      I know I can add that but I am trying to simply the code not add to it. If the compiler already
      does this I am adding an extra statement to what is already a slow calculation. If it doesn't, It is
      clear what you suggest is warranted. Do you have a definitive source for checking this ?

      Comment


        #4
        Hello Jerrywar,

        We can only provide support based only based on what’s documented. Providing information on undocumented code and how things worked under the hood could present an issue should development make any changes.

        You may look at the auto-generated code at the bottom of an indicators source if you’re interested in an indicators internals.

        Thank you for your understanding.

        Please let us know if you need further assistance.
        Alan P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Rapine Heihei, Today, 08:19 PM
        1 response
        8 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by Rapine Heihei, Today, 08:25 PM
        0 responses
        6 views
        0 likes
        Last Post Rapine Heihei  
        Started by f.saeidi, Today, 08:01 PM
        1 response
        9 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by Rapine Heihei, Today, 07:51 PM
        0 responses
        8 views
        0 likes
        Last Post Rapine Heihei  
        Started by frslvr, 04-11-2024, 07:26 AM
        5 responses
        98 views
        1 like
        Last Post caryc123  
        Working...
        X