• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Calculating difference between 2 EMA's

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

    Calculating difference between 2 EMA's

    I am writing a strategy that includes checking the distance between 2 EMA's. I am only having one problem: being able to make the actual calculation. Every time I try anything I get an error related to incorrect field type.

    All I need to be able to do is set a numeric variable to the value of an EMA.

    Conceptually I need to be able to do the following:

    EMASlow = EMA(34)

    I have searched for hours for a solution for what I know is a simple problem but I had no luck. I'm an old VB programmer and finding all the details for C# is problematic.

    If anyone can provide me the one or two script lines I would need, I would appreciate it.

    #2
    Originally posted by gcaldridge View Post
    I am writing a strategy that includes checking the distance between 2 EMA's. I am only having one problem: being able to make the actual calculation. Every time I try anything I get an error related to incorrect field type.

    All I need to be able to do is set a numeric variable to the value of an EMA.

    Conceptually I need to be able to do the following:

    EMASlow = EMA(34)

    I have searched for hours for a solution for what I know is a simple problem but I had no luck. I'm an old VB programmer and finding all the details for C# is problematic.

    If anyone can provide me the one or two script lines I would need, I would appreciate it.
    What is the exact error message?

    Comment


      #3
      Hello gcaldridge,
      Please open the output window (Tools>Output Window) and see if there is any error messages. If so can you please let me know.

      Also please make sure you have enough bars to calculate on historical bars. Please refer to this post to know more
      http://ninjatrader.com/support/forum...ead.php?t=3170
      JoydeepNinjaTrader Customer Service

      Comment


        #4
        Originally posted by gcaldridge View Post
        I am writing a strategy that includes checking the distance between 2 EMA's. I am only having one problem: being able to make the actual calculation. Every time I try anything I get an error related to incorrect field type.

        All I need to be able to do is set a numeric variable to the value of an EMA.

        Conceptually I need to be able to do the following:

        EMASlow = EMA(34)

        I have searched for hours for a solution for what I know is a simple problem but I had no luck. I'm an old VB programmer and finding all the details for C# is problematic.

        If anyone can provide me the one or two script lines I would need, I would appreciate it.
        This is the code I have:

        variable9 = EMA(14) [0];
        variable8 = EMA(34) [0];

        and it compiles clean.

        When I add the following line:

        variable7=variable9-variable8

        I get the following error:

        the name variable7 does not exist in the current context

        Thanks

        Geoff

        Comment


          #5
          Hello gcaldridge,
          To assist you further can you please send a toy NinjaScript code* replicating the behavior to support[AT]ninjatrader[DOT]com

          Please append Attn:Joydeep in the subject line of the email and give a reference of this thread in the body of the email.

          I look forward to assisting you further.

          *The "toy" just means something that is a stripped down version that isn't necessarily the whole logic. It makes things easier to rout out.
          JoydeepNinjaTrader Customer Service

          Comment


            #6
            Originally posted by gcaldridge View Post
            This is the code I have:

            variable9 = EMA(14) [0];
            variable8 = EMA(34) [0];

            and it compiles clean.

            When I add the following line:

            variable7=variable9-variable8

            I get the following error:

            the name variable7 does not exist in the current context

            Thanks

            Geoff
            Where have you declared variable7?

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by YevhenShynkarenko, Today, 02:55 AM
            0 responses
            21 views
            0 likes
            Last Post YevhenShynkarenko  
            Started by pjsmith, Today, 02:20 AM
            0 responses
            8 views
            0 likes
            Last Post pjsmith
            by pjsmith
             
            Started by faisamtrader, Yesterday, 10:03 PM
            0 responses
            8 views
            0 likes
            Last Post faisamtrader  
            Started by johnnybegoode, Yesterday, 08:11 PM
            0 responses
            4 views
            0 likes
            Last Post johnnybegoode  
            Started by Bionian, Yesterday, 02:47 PM
            2 responses
            26 views
            0 likes
            Last Post Bionian
            by Bionian
             
            Working...
            X